Installation and management of binary software packages on CentOS
When the linux System Administrator manages the operating system, the software on the operating system is almost a required function of the system administrator. In earlier debain releases, debain developers developed a software package manager named dpkg. Later, redhat developers developed a software Package Manager similar to dpkg, but more powerful than dpkg, called rpm (RPM is Package Manager. At present, rpm package manager is already the industrial standard of linux software package manager. Most of the software with complex functions in linux is implemented by combining multiple functions and single software. Therefore, when we use the rpm manager to install software packages for linux. Dependencies are usually generated. For example, when installing A, A depends on B, B depends on C, and C depends on D. Therefore, when installing, you have to manually install B, C, and D on your own. What's more interesting is that when installing A, A depends on B, B depends on C, C depends on D, and D depends on A, which forms A circular dependency and causes A package to be unable to be installed. Obviously, we need a way to solve the dependency generated when installing the linux software package, the yum on centos and the apt-get tool on debain can solve the dependencies generated during software installation. The rpm and yum tools on centos are described in detail below.
Rpm (RPM is Package Manager): It is a software Package management tool for linux operating systems such as redhat and centos. It has become an industrial standard for the software Package Manager in the linux Industry. It mainly provides functions such as installation, uninstallation, upgrade, query, verification, and database management. The usage of rpm is as follows:
Rpm Software Package naming format:
Name-[subname]-major-minor-src_release.rpm_release.arch.rpm
Name: package name
Subname: Package sub-package name
Major: Main version number of the source code package used to compile this rpm package
Minor: the minor version number used to compile the source code package of this rpm package
Src_release: revision number of the source code package used to compile this rpm package
Rpm_release: Compile the revision number of this rpm (indicating the number of times the same source code was compiled into a software package, including the OS used by the Software Package)
Arch: indicates the CPU architecture used for compiling this software package (common include i386 and x86_64)
Example: httpd-2.2.3-91.el5.centos.i386.rpm
Install software package
Rpm [option]/path/to/package_file
-I: Installation
-V: displays the installation details.
-H: displays the installation progress with #. Each # represents the installation progress of 2%.
Usage: rpm-ivh/path/to/package_file
-- Nodeps: The dependency is ignored during installation. (Software installed in this mode may not run)
-- Test: test and installation.
-- Replacepkgs: re-install (if the original configuration file is modified, it is very likely that it will not be replaced, but will rename the configuration file generated by the installation to. rpmnew)
Uninstall Software Package
Rpm [option] package_name
-E: uninstall (if the package configuration file has been changed after installation, it will not be uninstalled, but will be renamed and retained, for example, warning: /etc/zprofile saved as/etc/zprofile. rpmsave .)
-- Nodeps: The dependency is ignored during uninstallation. (After uninstallation, the program of the dependent software package may not run properly)
Upgrade Software Package
Rpm [option]/path/to/package_file
-Uvh: upgrade or install the software package. If the old version does not exist, install the software package. If the old software package exists, upgrade the old software package.
-Fvl: upgrade only. If the old version of the software package does not exist, the software package is not installed. If the old software package exists, the old software package is upgraded.
Note: You should not upgrade the kernel, but install it. The system allows coexistence of multiple kernels
Query software package information
Rpm [option] package_name
-Q: Check whether a package is installed.
-Qa: Query all installed packages
-Qi: query the Package Description
-Ql: query the files generated by a package installation
-Qc: query the configuration files generated by a package installation.
-Qd: query the help files generated by a package installation.
Rpm-q -- scripts package_name
There are four types of scripts:
Preinstall: script before installation
Postinstall: script after installation
Preuninstall: script before uninstallation
Postuninstall: scripts before and after the year
Rpm [option]/path/to/package_file
-Qf queries which package is generated by which a file is installed.
-Qpi: query the description of the uninstalled package
-Qpl: queries the list of installation files without installation packages.
-Qpc: query the configuration files and their paths without installation packages.
-Qpd: query the help files and their paths without installation packages.
Check: used to check whether the file attributes generated by package installation have changed
Rpm-V package_name
S file Size differs
M Mode differs (supported des permissions and file type)
5 digest (formerly MD5 sum) differs
D Device major/minor number mismatch
L readLink (2) path mismatch
U User ownership differs
G Group ownership differs
T mTime differs
P caPabilities differ
A property is displayed.
Check the legitimacy and integrity of the rpm package Source:
Premise: import the public key of the package producer on the current system
Import:
Rpm -- import/path/to/key_file
Rpm-qa gpg-pubkey *: displays the rpm-qi gpg-pubkey-NAME of all public keys in the imported gpg format: displays the details of the key.
Check package: automatically executed during installation
Manual check:
Rpm-K/path/to/package_file
Rpm -- checksig/path/to/package_file
Rpm-K -- nodigest: do not check the package integrity:
Rpm-K -- nosignature: do not check the source Validity
Re-build the rpm database:
Database Directory:/var/lib/rpm
Rpm -- initdb: initialization
If no database exists in advance, a new one will be created; If yes, no new one will be created; rpm -- rebuilddb: Rebuilding
Direct reconstruction, covering the original database
Yum (yellowdog update manager): yum is a tool that automatically resolves dependencies when installing software packages on centos or redhat systems. Its working principle is as follows:
First, when the yum client executes the yum command to install the program in the command line, the client will find the yum repository according to the baseurl In the yum configuration file defined locally, download the repodata metadata and cache it locally. decompress and analyze it locally and resolve the dependencies between the software to be installed. This determines which dependency packages need to be installed to install the program. Finally, download the package to be installed and its dependent package to the local device from the specified yum repository based on the analysis results, and call the rpm package manager for installation.
Yum client command usage:
Yum list: list the software packages in the yum repository and repository.
Yum repolist: List locally available yum repositories, but not the packages of yum repositories.
Yum install package_name: install the software package (centos 6 or later versions, which automatically resolves dependencies when installing packages in the repository. The corresponding option in centos 5 is localinstall)
Yum reinstall package_name: reinstall the Software Package
Yum grouplist package_name: install the software package Group
Yum remove package_name: uninstall the Software Package
Yumupdate package_name: upgrade software package
Yumdowngradepackage_name: downgrade the Software Package
Yum info package_name: view the description of the software package.
Yum clean {metadata | packages | all}: Clear yum Cache
Note: The client yum is cached in the/var/cache/yum/$ basearch/$ releasever directory.
$ Basearh: Basic CPU platform of the current system, which is commonly used (i386 and x86_64 ).
$ Releasever: The main version number of the current system release.
These two variables can also be used in the configuration file of the yum client.
Basic Format of the yum client configuration file
[Repo-id]
Baseurl = http://mirrors.163.com/centos/5/ OS /i386/ # url path of the yum repository (to indicate the parent directory of the repodata directory)
Enabled = {1 | 0} # configure whether the yum repository is enabled. Enabled to 1, not enabled to 0
Gpgcheck = {1 | 0} # configure whether to enable gpg to verify the source validity and integrity of the software package. Enabled as 1 and disabled as 0 (used together with gpgkey)
Gpgkey = http://mirrors.163.com/centos/5/ OS /i386/RPM-GPG-KEY-CentOS-5 # specify the url path of the public key of the package maker in the current Repository
Cost = 1000 # the cost of accessing this warehouse. The default value is 1000. The smaller the value, the higher the priority.
How to configure yum Source
First, you need to put the software packages that have completed the same function in the specified directory, and then use the createrepo/rpm/dir/command to create metadata for the software packages in the directory. The metadata is saved in the repodata directory of the software package, the name and description of each software package in the current Warehouse, whether the software package has been installed, the package group, its description, and the dependency between the software packages are saved. Install http, ftp, or nfs to publish the directory where the software package is located.