In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
I. Preface
Before there was no package manager, users installed the software through source code. However, it is easy to find that the operating system environment and compiled parameters must be compiled every time the software is installed, and the operation process is very complicated, which is really difficult for friends who are not familiar with the operating system. So is there a software that allows users to easily install the required software?
With the vigorous development of free software and the rapid development of Linux system, many software developers, enterprises and communities begin to collect, organize, compile and publish these software into distributions to the commonly used Linux operating system, but later found that a lot of operations need to be done in future software updates and system updates. In order to solve this problem, some communities and enterprises begin to think about the software management way of Linux.
Through the joint efforts of the community and enterprises, Linux developers compile the fixed hardware platform and the software that the operating system needs to install or upgrade, and package the software into a file of a special format through a specific package. The files of these software contain scripts that can detect the operating system environment and software dependencies, and provide information about all the files provided by the software. Finally, the software is released for users to use. Then users get this software package, through specific commands, they will be able to detect the system environment and install the software according to the requirements of the environment. This is the birth of the software manager.
At present, there are two common ways to install Linux software.
2.1 、 dpkg
This software installation method is developed through the Debian Linux community. Through the dpkg mechanism, the software provided by Debian can install the software through a very simple method and record the software information after installation. Only most of Debian's Linux distributions uses this method to manage software. For example, B2D, Ubuntu
2.2 、 RPM
This software installation method is developed by Red Hat company, because it is very simple and practical, many distributions use this mechanism to install and manage software. For example: CentOS, SuSe, etc.
Package Manager
Function: package the compiled program into a file or a limited number of files, which can be used to install, uninstall, upgrade, query and other functions.
Contains:
1. Database
Program name and version
Dependency: X-> YMagazine
Functional description (rpm-qi bash)
Install the generated file paths and check codes
2. the composition list of the program.
List of documents
Install the script that runs when you uninstall
IV. Introduction to RPM
RPM (RedHat Package Manager), RPM installs the software you need on your Linux system as a database record. Before you install the software, it is compiled, packaged into RPM format files, database records to search for the corresponding dependencies of the software, then when you install the software, RPM will check your system environment and dependencies to determine whether you can install the software. If it is satisfied, installation is allowed. Otherwise, no installation will be given. And at the time of installation, the information of the software is written into the database of RPM for future query, verification and upgrade.
5. Naming format of RPM package
Format:
Name-version-release.arch.rpm
For example:
Bash-4.2.3-3.centos5.x86_64.rpm # stands for bash-4.2.3, third release, supports CentOS5 system, supports hardware platform x86mm 64-bit system
How to get the rpm package:
1. Issued CD or site server
Mirror:
Http://mirrors.163.com
Http://mirrors.sohu.com
Http://mirros.aliyun.com
2. Official website of the project
source code
Rpm package
3. Many third-party organizations or individuals produce and publicly release many rpm packages
Http://rpmfind.net
Http://rpm.pbone.net/
VI. Subcontracting mechanism of packaging tools
Suppose a program has 20 functions: 8 common functions, 3 special functions, 6 special functions, and 3 secondary development related functions. If users only need common functions, but must install all of them, it will take up a lot of space, and other functions will not be used at all, and then there will be a subcontracting mechanism.
Subcontracting mechanism:
Core package (main package) + subpackage (subpackage)
Core package: the command is consistent with the source program
For example: bash-4.2.3-3.centos7.x86_64.rpm
Subpackage: (core package must be installed before installing subpackage)
For example: bash-a-4.2.3-3.centos7.x86_64.rpm
Bash-devel-4.2.3-3.centos7.x86_64.rpm # devel represents the development function
7. The use of RPM package
7.1. installation (combination option:-ivh)
Rpm [option] Package_file-i:install installation operation-v: display details during installation-vv: display more details during installation-h:hash code, use # during installation to show installation progress-test: test only, do not install-- nodeps: ignore dependencies, force installation if a package depends on other packages, either resolve all dependencies or ignore dependencies and force installation. However, if the forced installation is completed, the software may not work properly. -- replacepkgs: reinstall package Note: if the original configuration file is modified, it is very likely that the newly generated configuration file will be renamed with the suffix .rpmnew instead of executing the replacement file.
Example:
# Test and install RPM package [root@localhost mnt] # mount / dev/cdrom / mnt # Mount CD image to / mnt directory mount: block device / dev/sr0 is write-protected Mounting read-only [root@localhost mnt] # cd / mnt/Packages/ # enter the CD directory [root@localhost Packages] # rpm-ivh zsh-4.3.10-7.el6.x86_64.rpm # install zsh-4.3.10-7.el6.x8664.rpm package warning: zsh-4.3.10-7.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY # here is the prompt key Unable to verify the validity of the package Preparing... # [100%] # use # to represent installation progress A # represents 2% 1:zsh # [100%] # for testing only No installation [root@localhost Packages] # rpm-q zsh package zsh is not installed [root@localhost Packages] # rpm-- test-ivh zsh-4.3.10-7.el6.x86_64.rpm# is only for test installation, warning: zsh-4.3.10-7.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEYPreparing... is not actually installed # [100%] [root@localhost Packages] # rpm-q zsh package zsh is not installed
7.2. Uninstall
Rpm [option] Package_name-e:erase deletion
There will also be dependencies when uninstalling, if dependent on other packages:
1. Uninstall all packages that depend on this package
2. Ignoring dependencies can be uninstalled, but depending on this package may not work properly
-nodeps ignores dependencies
Exercise:
[root@localhost Packages] # rpm-Q zsh # check whether the software is installed, showing the package information certifying that zsh-4.3.10-7.el6.x86_64 [root@localhost Packages] # rpm-e zsh # uninstalls the zsh software [root@localhost Packages] # rpm-q zshpackage zsh is not installed # indicating that the software is not installed
Note: if the configuration file of the package has been changed after installation, the file will not be uninstalled when uninstalled, but will be renamed and saved, and the following fields will appear
Warning: / etc/zshrc saved as / etc/zshrc.rpmsave
For example:
[root@localhost Packages] # rpm-e zshwarning: / etc/zshrc saved as / etc/zshrc.rpmsave [root@localhost Packages] # ls / etc/ | grep "zsh*" zshrc.rpmsave
7.3. Upgrade (generally speaking, the new version replaces the old version)
Rpm [option] Package_file
(1), upgrade or install (upgrade if there is an old version, install if not)
Combination-Uvh
(2) upgrade directly (install the new version if there is an old version)
Combination-Fvh
Problems such as version conflicts may also occur when upgrading, so if you want to force an upgrade, you can use-- force
Note: you should not upgrade the kernel, but install it (because the Linux system allows many kernels to coexist)
7.4. Query
(1) query whether a package is installed
Rpm-Q package_name... ..
(2) query all installed packages
Rpm-qa # a stands for all
Filter by condition: rpm-qa | grep 'PATTERN'
(3) query the description information of the package
Rpm-qi package_name (only installed packages are queried here)
(4) query which files are generated by a certain package
Rpm-ql package_name
① queries which configuration files are generated by a package
Rpm-qc package_name
② queries which help files are generated by a package
Rpm-qd package_name
Scripts related to the ③ query package
Rpm-Q-scripts package_name
There are four types of scripts
Preinstall: pre-installation script
Postinstall: post-installation script
Preuninstall: pre-uninstall script
Postuninstall: script after uninstall
(5) query which package installed and generated a file
Rpm-qf / path/to/some_file
(6) query the capabilities provided by a package
Rpm-Q provides PACKAGE_NAME
(7) query the capabilities on which a package depends
Rpm-Q-- requires PACKAGE_NAME
(8) execute queries on packages that have not yet been installed
Rpm [option] / path/to/package_file-q: check whether the package is installed-qpi: package information-qpl: what files will be generated after installation-qpc: what configuration files will be generated after installation-qpd: what help files will be generated after installation
(9) query which package provides the specified CAPABILITY
Rpm-Q-- whatprovides CAPABILITY
(10) query which package the specified CAPABILITY is dependent on
Rpm-Q-- whatrequires CAPABILITY
(11) query the changelog information that changes with version when a package is made
Rpm-Q-- changelog PACKAGE_NAME
(12) Preview the documents in the package
Rpm2cpio package file | cpio-itv # needs to define the path of the package
(13) release the files in the package
Rpm2cpio package file | cpio-id "* .conf" # need to define the path of the package
Exercise:
[root@localhost Packages] # rpm-Q zsh # check whether zsh software is installed zsh-4.3.10-7.el6.x86_64 [root@localhost Packages] # rpm-qa | grep zsh # check whether zsh software installs zsh-4.3.10-7.el6.x86_64 [root@localhost Packages] # rpm-qd zsh # query which zsh packages are generated Help file [root@localhost Packages] # rpm-qpl httpd-2.2.15-29.el6.centos.x86_64.rpm # when httpd is not installed Query what file will be generated by installing httpd [root@localhost Packages] # rpm-qf / etc/bashrc # query bashrc this file is generated by what package installation setup-2.8.14-20.el6_4.1.noarch
7.5. Check (used to check whether the file attributes have changed after packaging)
Rpm-V Package_name S file Size differs size M Mode differs (includes permissions and file type) permission, file type change 5 digest (formerly MD5 sum) differs md5 check code changed D Device major/minor number mismatch if it is a device file Then the primary and secondary numbers change L readLink (2) path mismatch path changes U User ownership differs ownership changes G Group ownership differs group changes T mTime differs modification time changes P caPabilities differ capabilities change (can be understood as function)
If an attribute has not changed, it is displayed as follows:
[root@localhost Packages] # tail-5 / etc/zshrc} _ src_etc_profile_dunset-f _ src_etc_profile_d#test file # added the last paragraph [root@localhost Packages] # rpm-V zsh # to the last line of / etc/zshrc file to query whether the configuration file of the zsh software has changed S.5T. C / etc/zshrc # see the file size MD5 check, the modification time has changed.
7.6. RPM database reconstruction
Database directory of rpm: / var/lib/rpm
Rpm-- initdb: initialize if there is no library in advance, a new one will be created; if so, it will not be overwritten
Rpm-- rebuilddb: rebuild directly, overwrite the original database
7.7. Verify the validity and integrity of the source of the RPM package
After the package maker finished, the digital signature will be attached to the package; the package maker uses one-way encryption to extract the signature of the original data, and then uses his own private key to encrypt the signature, adding to the original data.
The process of verifying the legitimacy and integrity of the package source:
Premise: there must be a reliable mechanism to obtain the public key of the package author
1. Use the producer's public key to decrypt the encrypted signature, and decryption means that the source is legal.
2. Use the same encryption algorithm as the producer to extract the signature of the original data, and compare it with the decrypted signature, which means that the integrity is fine, so we must import the public key of the maker of the package on the current system.
Import the public key:
Rpm-import / path/to/key_file
Tip: centos6's key is in the "RPM-GPG-KEY-CentOS-6" file on the CD.
Displays all imported public keys in gpg format:
Rpm-qa gpg-pubkey*
Displays the details of the public key:
Rpm-qi gpg-pubkey-name
The check package is automatically performed during installation. To detect it manually, do the following:
Manual check:
Rpm-K / path/to/package_filerpm-- checksig / path/to/package_file
Do not check package integrity:
Rpm-K-nodigest
Do not check the legality of the source:
Rpm-K-nosignature
Experiment:
Mistakenly delete rpm repair method:
1. Enter rescue mode
two。 Create a mount directory:
Mkdir / mnt/cdrom
3. Mount the CD image:
Mount-r / dev/sr0 / mnt/cdrom
4. Enter the package directory:
Cd / mnt/cdrom/Packages/
5. Install rpm:
Rpm- ivh rpm-4.11.3-17.el6.x861464-root=/mnt/sysp_w_picpath/
Exercise:
[root@localhost Packages] # rpm-ivh zsh-4.3.10-7.el6.x86_64.rpm # will prompt you when installing that you do not have a public key Unable to verify the integrity and validity of the package warning: zsh-4.3.10-7.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature Key ID c105b9de: NOKEY [root@localhost Packages] # rpm-- import / mnt/RPM-GPG-KEY-CentOS-6 # Import key [root@localhost Packages] # rpm-qa gpg-pubkey* # View the imported key gpg-pubkey-c105b9de-4e0fd3a3 [root@localhost Packages] # rpm-qi gpg-pubkey in gpg format -c105b9de-4e0fd3a3 # View key details [root@localhost Packages] # rpm-ivh-- replacepkgs zsh-4.3.10-7.el6.x86_64.rpm # after the key can be imported, the installation software will automatically perform a check Install Preparing... directly after passing # [100%] 1:zsh # [100%] [root@localhost Packages] # rpm -K zsh-4.3.10-7.el6.x86_64.rpm # manually check the integrity and validity of the package zsh-4.3.10-7.el6.x86_64.rpm: rsa sha1 (md5) pgp md5 OK 8. Summary of key points of knowledge
8.1. Understand the source and use of the package manager
8.2. Be familiar with the naming format name-version-release.arch.rpm of the RPM package
8.3. Be familiar with packaging and subcontracting mechanism
Familiar with the use of RPM commands, including installation, uninstallation, query, upgrade, verification, public key import, validity verification, RPM database reconstruction
Although there are other better names when installing the software, such as yum (described later), yum is also derived from RPM, and it is very useful in the query package, and this command will be often used in the future, so you must be very familiar with the RPM command, especially the query command, which is of great help to the maintenance of the Linux system in the future. It is recommended to practice more.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.