When a Linux system administrator manages the operating system, managing the software on the operating system is almost an essential feature of the system administrator. In the early Debain release, Debain developers developed a package manager named Dpkg. Later, Redhat's developers modeled dpkg on a package manager named RPM, which is similar to the DPKG function, but more powerful than its own. The RPM Package Manager is now the industry standard for the Linux industry Package Manager. Because most of the complex software in Linux is implemented by a combination of many functional and single software. So when we use the RPM Manager to install packages to Linux. Often generate dependencies. For example: When we install a, a relies on b,b relies on the C,c and relies on D, so when you install a, you have to put B, C, d are all their own manually installed. What's even more interesting is that when we install a, a relies on the b,b dependency on the c,c dependency D,d and A, which forms a cyclic dependency that causes a package to be installed. Obviously we need a way to solve the dependencies generated by the Linux installation package, and the Apt-get tools on CentOS and Debain will solve the dependencies that are generated when the software is installed. Let's take a detailed look at the rpm and Yum Tools on CentOS.
RPM is the Package Manager: Software packages management tools on Linux operating systems such as Redhat and CentOS, which have become the industry standard for the Linux industry Package Manager. Mainly provides the installation, uninstall, upgrade, query, calibration, database management and other functions. The RPM usage scenarios and their specific usage are as follows:
RPM Package naming format:
name-[subname]-major-minor-src_release.rpm_release.arch.rpm
Name: Package names
SubName: Package's Child package name
Major: The major version number of the source package used to compile this RPM package
Minor: the minor version number of the source package used to compile this RPM package
Src_release: The revision number of the source package used to compile this RPM package
Rpm_release: Compile revision number for this RPM (indicates that the first time you compile a package with the same source code, which also includes the OS used by this package)
Arch: Represents the CPU architecture used for this package compilation (common with I386, x86_64)
Example: httpd-2.2.3-91.el5.centos.i386.rpm
Install packages
RPM [option]/path/to/package_file
-I: Installation
-V: Displays installation details
-H: Displays the installation progress with the # sign, each # number represents 2% of the installation progress
Combination usage: rpm-ivh/path/to/package_file
--nodeps: Ignore dependencies when installing. (software installed in this way may not work)
--test: Test installation, not a real installation.
--replacepkgs: Reinstall (if the original configuration file is modified, it is very likely that the replacement will not be performed, instead the configuration file that should install the build is renamed to. rpmnew)
Uninstalling Packages
RPM [option] Package_name
-E: Uninstall (if the package configuration file has been modified since it was uninstalled, the file will not be uninstalled, but is renamed and retained, for example warning:/etc/zprofile saved as/etc/zprofile.rpmsave.)
--nodeps: Ignore dependencies when uninstalling (the programs that depend on the secondary package may not function correctly after uninstallation)
Upgrade Packages
RPM [option]/path/to/package_file
-UVH: Upgrade or install if the older package does not exist, install the package, or upgrade the old package if the old package exists.
-FVH: Pure upgrade, if the old version of the package does not exist, the package is not installed, if the old package exists, then upgrade the old package.
Note: You should not perform an upgrade operation on the kernel, but install it. System allows multiple cores to coexist
Querying Package-related information
RPM [option] Package_name
-Q Query Whether a package is installed
-qa to query all installed packages
-qi description information for the query package
-QL query which files are generated by a package installation
-QC query which configuration files are generated for a package installation
-qd query which help files are generated by a package installation
Rpm-q--scripts package_name Query package related scripts
There are four types of scripts:
Preinstall: Pre-installation script
Postinstall: Post-installation script
Preuninstall: Pre-uninstall script
Postuninstall: Scripts before and after the year
RPM [option]/path/to/package_file
-QF query which package the file was built by.
-QPI: Querying for descriptions of packages that are not installed
-QPL: Querying the list of installation files for packages that are not installed
-QPC: Querying configuration files and their paths for packages that are not installed
-QPD: Querying the Help files and their paths for packages that are not installed
checksum: Used to check whether the file attributes generated by the package installation have changed
Rpm-v package_name
S file Size differs
M Mode differs (includes 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 has no change and is displayed as.
RPM package source legality and completeness test:
Prerequisite: The public key of the creator of the package is imported on the current system
Import:
RPM--import/path/to/key_file
Rpm-qa gpg-pubkey*: Displays the public key of all imported GPG formats Rpm-qi gpg-pubkey-name: Displays the details of the key
Check package: Automatic execution during installation
Manual Check:
Rpm-k/path/to/package_file
RPM--checksig/path/to/package_file
Rpm-k--nodigest: Package integrity is not checked:
Rpm-k--nosignature: No check of source legitimacy
RPM Database rebuild:
Database directory:/var/lib/rpm
RPM--INITDB: Initialization
If there is no library in advance, a new one will be created; rpm--rebuilddb: rebuilding
Direct reconstruction, overwriting the original database
Yum (yellowdog Update Manager): Yum is a tool that automatically resolves dependencies when packages are installed on a CentOS or redhat system. Its working principle such as
650) this.width=650; "title=" Yum.png "alt=" wkiom1wbuvuc6qgoaab0f1p1vm4669.jpg "src=" http://s3.51cto.com/wyfs02/M01 /6e/a6/wkiom1wbuvuc6qgoaab0f1p1vm4669.jpg "/>
first the Yum client executes the Yum command installer on the command line, and then the client finds the Yum repository based on the BaseURL in its locally defined Yum profile, and downloads its repodata metadata to cache locally. Analyze it locally and resolve dependencies on the software that will be installed to determine which dependent packages are installed to install this program. Finally, according to the results of the analysis to the specified yum repository download the package and its dependent package to the local, and call the RPM Package Manager to install.
usage of yum client commands:
Yum list: List of packages in the Yum repository and warehouse
Yum Repolist: List of locally available Yum repositories without listing yum repositories packages
Yum Install Package_name: Installs the package (CentOS 6 and above, automatically resolves dependencies when installing packages in the warehouse. The option for CentOS 5 is Localinstall)
Yum Reinstall package_name: Reinstall package
Yum grouplist package_name: Installing package Groups
Yum Remove Package_name: Uninstalling Packages
Yum Update package_name: Upgrade Package
Yum downgrade Package_name: Downgrading packages
Yum Info package_name: View the description of the package
Yum Clean {Metadata|packages|all}: Clear Yum Cache
Note: The client's yum cache is in the/var/cache/yum/$basearch/$releasever Directory
$basearh: Represents the CPU base platform of the current system, which is common (i386, x86_64).
$releasever: Represents the major version number of the current system release.
These two variables can also be used in the Yum client's configuration file
The basic format of the Yum client configuration file
[Repo-id]
Baseurl=http://mirrors.163.com/centos/5/os/i386/#yum仓库的url路径 (to refer to the parent directory of the Repodata directory)
Enabled={1|0} #配置此yum仓库是否启用. Enabled for 1, not enabled for 0
Gpgcheck={1|0} #配置是否启用gpg来验证软件包的来源合法性和完整性. Enabled as 1, not enabled for 0 (used with Gpgkey)
Gpgkey=http://mirrors.163.com/centos/5/os/i386/rpm-gpg-key-centos-5 #指定当前仓库中软件包制作者的公钥的url路径
cost=1000 #访问此仓库的花销, default is 1000, the smaller the value, the higher the priority
How to configure a Yum source
The first thing to do is to complete the same function of the package into the specified directory, and then use the createrepo/rpm/dir/command to create metadata for the package in the directory, the metadata is stored in the directory of the package stored in the Repodata directory, which holds the name of each package in the current warehouse, Information that describes the information, whether it has been installed, the package group and its descriptive information, and the dependencies between the individual packages. Then install HTTP or FTP or NFS services to publish the directory where the package is located.
This article is from "Chalet Technology" blog, please make sure to keep this source http://starli.blog.51cto.com/8813574/1662902
Installation and management of binary format packages on CentOS systems (RPM and Yum)