Introduction of Yum
Yum, Yellow Dog Updater, is the abbreviation for Modified, a package manager developed by Duke University to improve the installation of RPM software packages. It was originally developed by Yellow Dog, the developer of the release, Terra Soft, written in Python, then called yup (Yellow Dog updater), after being improved by the Linux@duke development team at Duke University. Yum's mission is to automate upgrades, install/remove RPM packages, collect information about RPM packages, check dependencies, and automatically prompt users to resolve them. Yum's key is to have a reliable repository, as the name implies, this is the software warehouse, it can be HTTP or FTP site, can also be a local software pool, but must include RPM Header,header including the various information of the RPM package, including description, function, Provide documents, dependencies, etc. It is by collecting these headers and analyzing them that the remaining tasks can be done automatically.
Yum's idea is to use a central warehouse (repository) to manage some or even a distribution application, and to perform related upgrades, installations, deletions, etc. based on the calculated software dependencies, reducing Linux The user has been having headaches for dependencies problems. On this point, Yum and apt are the same. Apt was originally used for Debian's Deb type software management, but it can now be used to redhat rpm.
Yum main function is more convenient to add/remove/update RPM package, automatically solve the problem of the dependency of the package, easy to manage a large number of system update problems.
Yum can also configure multiple resource libraries (Repository), Concise configuration files (/etc/yum.conf), automatically resolve the dependency problems when adding or removing RPM packages, and maintain consistency with the RPM database.
Second, yum installation
CentOS The default has been installed Yum, do not need additional installation, here for experimental purposes, first uninstall and then reinstall the Yum.
1, view the system default installation of the Yum
2. Uninstall Yum
# rpm-e Yum-fastestmirror-1.1.16-14.el5.centos.1 Yum-metadata-parser-1.1.2-3.el5.centos Yum-3.2.22-33.el5.centos
3, reinstall Yum
Here you can download the relevant package installation from the Internet via wget, or mount the system installation CD-ROM to install it, choose Mount System installation CD-ROM to install it.
# mount/dev/cdrom/mnt/cdrom/
# RPM-IVH yum-3.2.22-33.el5.centos.noarch.rpm yum-fastestmirror-1.1.16-14.el5.centos.1.noarch.rpm yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm
# yum-v
The base installation package for Yum includes:
- Yum//rpm Installer/updater
- Yum-fastestmirror//yum plugin which chooses fastest repository from a mirrorlist
- Yum-metadata-parser//a Fast metadata parser for Yum
Other installation packages are installed according to their needs.
Third, yum configuration
Yum's configuration file is divided into two parts: Main and repository
- The main section defines the global configuration option, and the entire Yum configuration file should have only one main. Often located in/etc/yum.conf.
- The repository section defines the specific configuration of each source/server and can have one or more. Often located in the files in the/ETC/YUM.REPO.D directory.
yum.conf files are generally located in the/etc directory, which typically contains only the configuration options for the main section.
[main]
Cachedir=/var/cache/yum
//yum cached directory, yum stores the downloaded rpm package and database here, the default setting is /var/cache/yum
Keepcache=0
//Whether the package is retained after the installation is complete, 0 is not reserved (default is 0), 1 is reserved
Debuglevel=2
/ / Debug information output level, the range is 0-10, the default is 2
Logfile=/var/log/yum.log
//yum log file location. Users can go to the /var/log/yum.log file to check for updates made in the past.
Pkgpolicy=newest
/ / Package strategy. There are two options, newest and last. The effect is that if you set multiple repositories and the same software exists in different repositories, which one yum should be installed, if it is newest, yum will install the latest version. . If it is last, yum sorts the server ids in alphabets and selects the software installation on the last server. Usually choose newest.
Distroverpkg=redhat-release
/ / Specify a package, yum will judge your distribution according to this package, the default is redhat-release, or any rpm package installed for your own release.
Tolerant=1
// There are two options, 1 and 0, to indicate whether yum tolerates error related to the package on the command line. For example, you need to install 1, 2, 3, and 3 of them have been installed before, if you set it to 1 , yum will not display an error message. The default is 0.
Exactarch=1
// There are two options, 1 and 0. If set to 1, yum will only install packages that match the system architecture. For example, yum will not install the i686 package on a system suitable for i386. The default is 1.
Retries=6
//The number of retries after an error occurs on the network connection. If it is set to 0, it will be retried infinitely. The default is 6.
Obsoletes=1
//This is an update parameter. See yum(8) for details. Simply put, it is equivalent to upgrade, allowing you to update stale RPM packages.
Plugins=1
/ / Whether to enable the plugin, the default 1 is allowed, 0 means not allowed. We generally use the yum-fastestmirror plugin.
Bugtracker_url=http://bugs.centos.org/set_project.php?project_id=16&ref=http://bugs.centos.org/bug_report_page.php?category=yum
# Note: yum-RHN-plugin doesn't honor this.
Metadata_expire=1h
Installonly_limit = 5
# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d
In addition to the above, there are some options you can add, such as:
exclude=selinux*//Exclude some software from the upgrade list, you can use wildcard characters, the list of items to be separated by spaces, this for the installation of such as landscaping package, Chinese patches of friends particularly useful.
Gpgcheck=1//has 1 and 2 options, representing whether the GPG (GNU Private Guard) Check is performed to determine if the source of the RPM package is valid and safe. This option is valid for each repository if it is set in the [main] section. The default value is 0.
Iv. Configuring local Yum sources
1, mount the system installation CD-ROM
# mount/dev/cdrom/mnt/cdrom/
2. Configure local Yum Source
# cd/etc/yum.repos.d/
# ls
You'll see four repo files
Centos-base.repo is a yum network source configuration file
Centos-media.repo is a yum local source configuration file
Modify Centos-media.repo
# Centos-media.repo # This
repo are used to mount the default locations for a cdrom/dvd on
# CentOS-5. You can use this repo and yum to install items directly off the
# DVD ISO so we release.
#
To use this repo, put on your DVD and use it with the other repos too:
# yum--enablerepo=c5-media [command]#
# or for only the media repo, does this:
#
# yum--disablerepo=\*--enablerepo=c5-media [command]
[c 5-media]
name=centos-$releasever-media
baseurl=file:///media/centos/
file:///mnt/cdrom/
file:///media/cdrecorder/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-centos-5
Modify the 2nd path in BaseURL to/mnt/cdrom (that is, the disc mount point)
Change Enabled=0 to 1
3, disable the default Yum network source
Change the Yum network source profile to Centos-base.repo.bak, or you will first look for the appropriate package in the network source and read it directly from the local source after renaming it.
4. Execute Yum command
About the format of the repo file
All repository server settings should follow the following format:
[ServerID]
Name=some name for this server
baseurl=url://path/to/repository/
- ServerID is used to distinguish between different repository and must have a unique name;
- Name is a description of repository that supports variables such as $releasever $basearch;
- BaseURL is the most important part of the server Setup, and only the correct settings can get the software from above. Its format is:
baseurl=url://server1/path/to/repository/
url://server2/path/to/repository/
url://server3/path/to/ repository/
One of the protocols supported by the URL is http://ftp://file://three species. BaseURL can be followed by multiple URLs, you can change yourself to a faster mirror station, but BaseURL can only have one, that is, not like the following format:
baseurl=url://server1/path/to/repository/
baseurl=url://server2/path/to/repository/
baseurl=url:// server3/path/to/repository/
The directory to which the URL points must be the upper level of this repository header directory, and it also supports variables such as $releasever $basearch.
URLs can be followed by several options, such as Gpgcheck, exclude, failovermethod, etc., such as:
[Updates-released]
Name=fedora Core $releasever-$basearch-released Updates
baseurl=http://download.atrpms.net/mirrors/fedoracore /updates/$releasever/$basearch
http://redhat.linux.ee/pub/fedora/linux/core/updates/$releasever/$basearch
http://fr2.rpmfind.net/linux/fedora/core/updates/$releasever/$basearch
gpgcheck=1
Exclude=gaim
failovermethod=priority
Where the meaning of gpgcheck,exclude is the same as in the [main] section, but only for this server, Failovermethode has two options roundrobin and priority, meaning that there are multiple URLs to choose from, yum the order of selection, Roundrobin is a random selection, if the connection fails, the next one is used, followed by loops, and priority begins with the first order of the URL. If not indicated, the default is Roundrobin.
V. Configuration of domestic Yum source
system default Yum source speed is often unsatisfactory, in order to achieve the purpose of rapid installation, here to modify the Yum source for the domestic source.
Yum Source of Shanghai Jiaotong University
A. The modified/etc/yum.repos.d/centos-base.repo is:
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
baseurl=http://ftp.sjtu.edu.cn/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
#released updates
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
baseurl=http://ftp.sjtu.edu.cn/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
baseurl=http://ftp.sjtu.edu.cn/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
baseurl=http://ftp.sjtu.edu.cn/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
baseurl=http://ftp.sjtu.edu.cn/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
About variables
- $releasever: Represents the release version, obtained from the distroverpkg in the [main] section, if not, based on the Redhat-release package.
- $arch: CPU system, such as I686,athlon
- $basearch: The basic system groups of CPUs, such as i686 and Athlon, belong to I386,alpha and alphaev6 with Alpha.
B. Import GPG KEY
Yum can use the GPG to check the package, to ensure the integrity of the download package, so we first to find GPG key to each repository site, generally will be placed in the home page eye-catching position, some names such as rpm-gpg-key-centos-5, such as plain text files, Download them and then use the RPM--import rpm-gpg-key-centos-5 command to import the KEY.
C. Implementation of the Yum command
Other domestic yum sources are listed below:
1. Enterprise Contribution:
Sohu Open Source Mirror station: http://mirrors.sohu.com/
NetEase Open Source Mirror station: http://mirrors.163.com/
2. University Teaching:
Beijing Institute
http://mirror.bit.edu.cn (IPV4 only)
http://mirror.bit6.edu.cn (IPV6 only)
Bjtu
http://mirror.bjtu.edu.cn (IPV4 only)
http://mirror6.bjtu.edu.cn (IPV6 only)
http://debian.bjtu.edu.cn (Ipv4+ipv6)
Lanzhou University: http://mirror.lzu.edu.cn/
Xiamen University: http://mirrors.xmu.edu.cn/
Tsinghua university:
http://mirrors.tuna.tsinghua.edu.cn/(Ipv4+ipv6)
http://mirrors.6.tuna.tsinghua.edu.cn/(IPV6 only)
http://mirrors.4.tuna.tsinghua.edu.cn/(IPV4 only)
Tianjin University: http://mirror.tju.edu.cn/
University of Science and Technology of China:
http://mirrors.ustc.edu.cn/(Ipv4+ipv6)
http://mirrors4.ustc.edu.cn/
http://mirrors6.ustc.edu.cn/
Northeastern
http://mirror.neu.edu.cn/(IPV4 only)
http://mirror.neu6.edu.cn/(IPV6 only)
http://ubuntu.uestc.edu.cn/:
Vi. use of third party software libraries
Centos/rhel the default Yum software warehouse is very limited, only limited to the release version of the regular packages and some software package updates, using Rpmforge, can add a lot of third-party rpm software packages. The Rpmforge library now has more than 10000 CentOS packages and is considered by the CentOS community to be the safest and most stable third-party software library.
1. Install Yum-priorities Plugin
This plug-in is used to set the order of the Yum when invoking the software source. Because the official source of software, are relatively stable and recommended use. Therefore, the order of official sources is higher than the order of third-party sources. How to ensure this order, you need to install the yum-priorities this plugin.
# yum-y Install Yum-priorities
2, after the installation of Yum-priorities Plug-ins need to set the/etc/yum.repos.d/directory of the. Repo related files (such as Centos-base.repo), insert sequential instructions in these files: priority=n (n is a positive integer from 1 to 99, the smaller the number is preferred)
General configuration [Base], [addons], [updates], [extras] priority=1,[centosplus], [contrib] priority=2, the other third software source is: priority=n (recommended N >10)
Take Centos-base.repo as an example:
[Base]
name=centos-$releasever-base
#mirrorlist =http://mirrorlist.centos.org/?release= $releasever &arch=$ Basearch&repo=os
baseurl=http://ftp.sjtu.edu.cn/centos/$releasever/os/$basearch/
gpgcheck=1
Gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-centos-5
Priority=1
3, download and install the corresponding rpmforge RPM packages
# wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
4, the installation of Dag PGP Key
# RPM--import Http://apt.sw.be/RPM-GPG-KEY.dag.txt
5, verify the Rpmforge RPM packages
# rpm-k rpmforge-release-0.5.2-2.el5.rf.*.rpm
6, install the Rpmforge rpm file package
# rpm-i rpmforge-release-0.5.2-2.el5.rf.i386.rpm
7, set the level of the source in the/etc/yum.repos.d/rpmforge.repo file
[Root@ts-dev yum.repos.d]# Cat Rpmforge.repo
### name:rpmforge RPM Repository for RHEL 5-dag ### url:http://rpmforge.net/
[rpmforge]
Name = RHEL $relea Sever-rpmforge.net-dag
baseurl = http://apt.sw.be/redhat/el5/en/$basearch/rpmforge
mirrorlist = http:// Apt.sw.be/redhat/el5/en/mirrors-rpmforge
#mirrorlist = File:///etc/yum.repos.d/mirrors-rpmforge
Enabled = 1
protect = 0
Gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
gpgcheck = 1
priority= 12
8. Test Installation
Other Third-party software libraries such as Epel (Extra Packages for Enterprise Linux) and rpmfusion are similar to installation and use and Rpmforge to find data installations.
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.
#
# This repo is used to mount the default locations for a CDROM / DVD on
# CentOS-5. You can use this repo and yum to install items directly off the
# DVD ISO that we release.
#
# To use this repo, put in your DVD and use it with the other repos too:
# yum --enablerepo=c5-media [command]
#
# or for ONLY the media repo, do this:
#
# yum --disablerepo=\* --enablerepo=c5-media [command]
[c5-media]
name=CentOS-$releasever - Media
baseurl=file:///media/CentOS/
file:///mnt/cdrom/
file:///media/cdrecorder/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5