Linux Package Management: RPM and Yum

Source: Internet
Author: User
Tags centos server yum repolist

One, RPM package

RPM is named "RedHat package Manager" and is referred to as RPM. This mechanism was originally developed by Red Hat, the most important feature of RPM is the need to install the software has been compiled, and has been packaged into the RPM mechanism of the installation package, through the default database in the software installed in the required software. When installed on your Linux host, RPM will first follow the data in the software to query the Linux host dependency property software is satisfied, if it is satisfied to install, if not satisfied will not install.

1. RPM Advantages and disadvantages

Advantages:

1) The software has been compiled and packaged, so it is easy to transfer and install, so that users are exempt from compiling

2) before installation, the system will check the disk, operating system version, etc., to avoid wrong installation

3) software information has been recorded on the Linux host database, easy to query, upgrade and Uninstall

Disadvantages:

1) The package installation environment must be consistent or equivalent to the environment in which it is packaged

2) software dependent software must be installed

3) When uninstalling, the lowest software can not be removed first, otherwise it may cause the whole system not to use
To solve the problem of RPM attribute dependency, the following will also give you a detailed description of how Yum is used.

2, the meaning of the RPM package naming

The name format of the RPM package:

Software Name-version number-number of releases. Suitable for Linux systems. Hardware platform. rpm
Example: ftp-0.17-74.fc27.i686.rpm

Attention:

Package Full Name: RPM operation is not installed package, package uses the full name of the package

Package Name: RPM operation of the installed software, package using the package name

For example above, the full name of the package is ftp-0.17-74.fc27.i686.rpm and the package name is FTP.

3. The default path for RPM installation software

/etc configuration File placement Directory

/usr/bin some executable files

/usr/lib dynamic link libraries used by some programs

/usr/share/doc some basic software manuals and documentation

/usr/share/man some man page files

4, RPM installation schematic diagram

Second, RPM user manual

1, Software Installation (install)

rpm -ivh package-name

Parameter description (in English after parentheses):

-i:install means that the installation

-V: View more detailed installation Information screen (provide more detailed output)

-H: Displays the installation progress in the installation Information Bar

2. Software upgrade

rpm –Uvh foo-2.0-1.i386.rpm

Parameter description (in English after parentheses):

-u:upgrade means, update the software, if the system does not have the software installed (upgrade package (s))

-f:freshen, update one of the software installed on the system (upgrade package (s) if already instaalled)

3. Query mode

RPM in the query, in fact, the location of the query is/var/lib/rpm/this directory of database files. In addition, RPM can also query for non-installed

The query syntax for RPM is:

RPM {-q|--query} [select-options] [query-options] Description of common parameters (in parentheses in English):

-a:all, list all software that is already installed on this computer (Query all instaled packages.)

-p:package, query the information for a RPM file (query an (uninstalled) package. )

-f:file, the name of the file to find out which Hujiahuwei installed software (Query package owning file).

-i:information, listing the details of the software, including the developer, version and description (Display package information, including name, version, and description.)

-l:list, lists the full file name of all files and directories in the software (list file in the package)

-c:configuration, list all the settings files for the software (find out the file name under/etc/) (list only in configuration files)

-d:documentation, list all help documents for the software (list only documentation files)

-r:required, lists the files contained in the dependent software associated with the software (list capabilities on which this depends.)

Note: In the part of the query, all parameters should be preceded by-Q is the so-called query.

4. Uninstalling the Software

Use RPM unloading process must be from the top down to unload, take Rp-pppoe as an example, the software is mainly based on the PPP software to install, so when you want to uninstall PPP, you must first uninstall Rp-pppoe!

The deleted command is very simple and can be done with the-e parameter. However, it is very common for software attribute dependencies to cause problems with some software that cannot be Shan WA.

rpm -e gcc

Third, Yum use

Introduction: Yum can be seen as a CS architecture software, Yum's existence is a good solution to the RPM attribute dependency problem; Yum extends the functionality of the RPM Package Manager by relying on the RPM Package manager, so Yum cannot run independently from RPM.

2. Features of Yum

1) Multiple Yum repositories can be configured at the same time (Repository)

2) Concise configuration file (/etc/yum.conf)

3) automatically resolve dependency issues when adding or removing RPM packages

4) Easy to use

5) Maintain consistency with RPM database

3. Yum Principle Description

The server side first classifies the packages and stores them in different repository containers; Then, by collecting the dependency data between the packages in the database file of RPM, generate the corresponding dependency and the document (. xml format) of the local storage location of the required files, and store them in the local Repodata directory for client-side access;

The cilent side discovers that some dependency packages are missing when installing the software through the Yum command, and the client locates the specified server side based on the local configuration file (/etc/yum.repos.d/*.repo). Obtain the description file from the server-side repo directory xxx.xml stored in the local/var/cache/yum for later reading, through the Xxx.xml file to find the dependencies that need to be installed on the server side of the storage location, Then get the required packages in the specified repository container in the server-side Yum Library, and implement the installation locally after the download is complete.

Note: Yum is an online software management tool, so most of the operations that are done with Yum need to be used in a networked environment.

Iv. Yum configuration file

1. Yum Container description

Although Yum is you can use directly after the network, however, because your system's site image is not selected, will cause the connection is very slow! So, this time we need to manually modify the Yum Setup document.

If you are connected to a CentOS mirror site (Http://ftp.twaren.net/Linux/C ... ), you will find a bunch of links in it, which are the containers provided by this Yum server, including Centosplus, Extras, FastTrack, OS, updates, etc., preferably OS (system default software) and updates ( Software upgrade version).

In the Yum server container, one of the most important directories is the "Repodata", which is the software dependent data placement that is generated after analyzing the RPM software. Therefore, when you find the URL of the container, the most important thing is that the URL below must have a directory called "Repodata" exists, that is the container URL.

2, container query

First, you can find out what containers are used by the directory Yum server first.

Using the command: Yum repolist all, the query results are as follows:

For example, only if the right-most status is enabled and the container is active, there will be multiple profiles in/etc/yum.repos.d/(the file name ends in. Repo), and Yum will look for it from inside, so the container name cannot be duplicated.

3. Configuration file Modification

1) Yum container configuration file path: Files ending with. Repo in the/etc/yum.repos.d/directory are yum sources

2) Open the configuration file: Vi/etc/yum.repos.d/cenos-base.repo, the content is as follows:

As above is only part of the container, the description of the configuration file is as follows:

[Base]: Represents the name of the container. The brackets must be present, the names inside can be arbitrary, but not two of the same container name, otherwise Yum will not know where to find the container-related software list file.

Name: Just to illustrate the meaning of this container, the importance is not high.

Mirrorlist: Lists the mirror sites that this container can use, and if you don't want to use it, you can annotate the line.

BaseURL: This is the most important, because the actual URL of the container is followed. Mirrorlist is the Yum program to find the mirror site itself,
BASEURL specifies a fixed container URL.

Enable=1: Start this container, the default value is also 1. Close this container to set enable=0.

Gpgcheck=1: Specifies whether a digital certificate within the RPM file needs to be consulted.

Gpgkey: The public key file for the digital certificate is in the same location, using the default value.

Note:

1) Yum automatically recognizes files with the/etc/yum.repos.d/directory ending with. Repo.

2) When we modify the URL of the configuration file without modifying the container name, it can cause the list of this machine to be out of sync with the Yum server list, then we need to clear the container's data manually:

Syntax: Yum clean [Packages|headers|all]

Parameters:

Packages: Remove downloaded software files

Headers: Delete the downloaded software file header

All: Delete all container data

Example: Delete all container-related data (including the software itself and the list) that has been downloaded

Yum Clean All

Five, yum source configuration

If the CentOS server is in the intranet environment, if the lack of reliance on manual installation then it will be very cumbersome, it takes a lot of time to find the RPM package, now if the local Yum source, it is very convenient, if you set up the HTTP, then the LAN other servers can be used, Using the Yum source first requires a CentOS installation image, here: Centos-6-x86_64-dvd-1511.iso

1) Configure local Yum source for local iOS image

Most of the software needed to download DVDs from CentOS7 official website, so you can configure Yum source as local DVD without network, download fast, software is stable.
1. If you are using a virtual machine, mount the DVD's ISO file in the virtual machine.
2. Create a new mount point with the following command and mount the modify Yum source configuration

[[email protected] ~]# mkdir/media/cdrom //Create a mount point directory
[[email protected] ~]# mount/dev/cdrom/media/cdrom/ //mount the attached image to the CDROM directory as a yum source

3. Modify the Yum source configuration to create the Centos-cdrom.repo file as the local iOS image Mount source

[Email protected] ~]# cd/etc/yum.repos.d/
[[email protected] yum.repos.d]# ls
Centos-base.repo Centos-debuginfo.repo Centos-media.repo Centos-vault.repo
[[email protected] yum.repos.d]# CP Centos-base.repo centos-cdrom.repo-p //Create local mirror repo file
[[email protected] yum.repos.d]# ls
Centos-base.repo Centos-debuginfo.repo Centos-vault.repo
Centos-cdrom.repo Centos-media.repo

4. Modify the contents of the Centos-cdrom.repo, annotate all the Mirrorlist properties in the document, open the BaseURL property annotation, and set the BaseURL property value to the mount point, baseurl=file:///media/cdrom/,:

5. Empty all source information that Yum already exists

Yum Clean All

6. View all software from local source

Yum List
Yum Repolist

2) local network image configuration local Yum source

First need a Web server, such as Apache httpd or nginx can, if it is nginx to open access directory list permissions, general installation of CentOS will install HTTPD server, so here directly using Apache httpd If not installed can be downloaded through the RPM or download source package compiled installation, before specifically written an article to install Apache, the specific process is no longer described, if you can connect, you can directly use the yum-y install httpd installed, I have installed here, So use systemctl start Httpd.service to start the httpd service, execute the command systemctl status Httpd.service to view the running status, as shown in the boot success:

Configuring the Yum file is similar to the above

1, edit the configuration file:/etc/yum.repos.d/centos-base.rep; '

2, then note mirrorlist, release BaseURL configuration into the Yum source location, there are gpgkey also configured to correspond to the location;

3, after the configuration of these, and then in [Updates] and [extras] Both add a enabled=0 configuration item, indicating that it does not take effect, generally only in [base] configuration can be configured to save the exit;

4. Then execute yum repolist to view Yum source information;

Note: in some special cases, if the configuration of Centos-base.repo will still appear to connect some URLs and failure, this time manually check the/etc/yum.repos.d/below some other configuration files to see if there is a connection to the external network configuration, If there is a direct enabled=0 disable it, you need to note that/etc/yum.repos.d/all of the following configuration files can be used, Including self-built such as Centos.repo is also possible, as long as it is enabled, Yum will be loaded, generally is enabled Centos-base.repo, the rest of the disabled will be

Vi. use of Yum manuals

1. Enquiry

Query-related commands:

Search: Searches for a software name or a description of important keywords;

List: Lists all the software names and versions currently managed by Yum, somewhat similar to RPM-QA

Info: ditto, but somewhat similar to Rpm-qai

Provides: Search software from File! Similar to RPM-QF

1)查询与ftp相关的软件有哪些yum search ftp2)查询gcc这个软件的功能yum info gcc可以查询到该软件的版本号、描述信息、是否已安装等信息。3)列出yum服务器上所提供的所有软件名称yum list4)列出目前服务器上可供本机进行升级的软件有哪些yum list updates5)列出提供passwd这个文件的软件有哪些yum provides passwd6)查找以pam开头的软件名称有哪些yum list pam*

2. Installation and upgrade

Related commands:

Install: Follow the software to be installed.

Update: Follow the software that you want to upgrade. To upgrade the entire system, you can update it directly.

install emacs

Tips:
Using the parameter-y, this option provides a yes response when it encounters the need to wait for user input, as the above example can be written as: Yum-y install emacs

3. Uninstall

Related commands:
Remove

remove emacs

4. Software Group Management

Remember the new CentOS installation, you can not choose the required software? And does that software use names such as gnome/kde/x window to exist? Actually this is the software group. Software-level presence is a very useful feature for a large number of software installations.

Related Command Description:

Grouplist: List all available groups

GroupInfo: followed by group name, you can see all the group names included in the group

Groupstall: Install an entire level of software

Groupremove: Deleting a group

1)查询目前容器与本机上面的可用与安装过的软件组有哪些yum grouplist2)查看一个软件组的信息yum groupinfo GNOME3)安装桌面环境GNOMEyum groupstall GNOME

Linux Package Management: RPM and Yum

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.