Yum, the abbreviation for Yellow Dog Updater, Modified, is a package manager developed by Duke University to improve the installation of RPM packages. It was originally developed by Yellow Dog, the developer of the release, Terra Soft, written in Python, then called yup (Yellow Dog updater), and then improved by the [email protected] 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 repository of software, it can be an HTTP or FTP site, it can also be a local software pool, but must contain RPM Header,header includes various information of RPM package, including description, function, Provide documents, dependencies, etc. It is the collection of these headers that can be analyzed to automate the completion of the remaining tasks.
Yum's philosophy is to use a central repository (repository) to manage a subset of even a distribution of application interactions, and to perform related upgrades, installations, deletions, etc. based on the calculated software dependencies, reducing the Linux The user has always had a headache dependencies problem. At this point, yum and apt are the same. Apt was originally used by Debian's deb-type software management, but it can now use the RPM of Redhat.
Yum main function is more convenient to add/remove/update RPM package, automatically solve the dependency problem of the package, easy to manage a large number of system update problems.
Yum can simultaneously configure multiple repositories (Repository), Concise configuration files (/etc/yum.conf), and automatically resolve dependency issues encountered when adding or removing RPM packages, maintaining consistency with the RPM database.
Second, yum installation
CentOS is already installed by default and does not need to be installed separately, and for experimental purposes, Yum is uninstalled and reinstalled.
1. Check the system default installed Yum
# Rpm-qa|grep 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. Re-install Yum
Here you can download the relevant package installation from the Internet via wget, or mount the system installation CD-ROM for installation.
# 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
Yum's base installation package 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
The Yum configuration file is divided into two parts: Main and repository
- The main section defines the global configuration options, and the entire Yum configuration file should have only one main. Often located in the/etc/yum.conf.
- The repository section defines the specific configuration for each source/server and can have one or more. are often located in the files under the/ETC/YUM.REPO.D directory.
yum.conf files are typically located in the/etc directory, and typically contain only the configuration options in the main section.
# cat/etc/yum.conf
[Main]cachedir=/var/cache/yum//yum cache directory, yum stores downloaded RPM packages and databases, default setting is/var/cache/yumkeepcache=0//whether the package is retained after 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 2logfile=/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. A total of two options, newest and last, this role is if you set up multiple repository, and the same software in different repository exist simultaneously, Yum should install which, if it is newest, yum will install the latest version. If it is last, Yum will sort the server ID alphabetically and select the software installation on the final server. Newest is generally chosen. Distroverpkg=redhat-release//Specify a package, Yum will determine your distribution based on this package, default is Redhat-release, or it can be any installed RPM package for your own release version. Tolerant=1//There are 1 and 2 options that indicate whether Yum tolerates a package-related error on the command line, such as installing a three-by-five package, where 3 has already been installed, and if you set it to 1, Yum will not have an error message. The default is 0. Exactarch=1//with 1 and 2 options set to 1, Yum installs only packages that match the system architecture, for example, Yum does not install i686 packages on systems that are suitable for i386. The default is 1. Retries=6//The number of retries after a network connection error occurs, and if set to 0, it will be retried indefinitely. The default value is 6. Obsoletes=1//This is an update parameter, see Yum (8), simply the equivalent of upgrade, allowing the updating of stale RPM packages. Plugins=1//Whether the plug-in is enabled, default 1 is allowed, and 0 means disallowed. We usually use yum-fastestmirror this 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= 1hinstallonly_limit = AA 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 that you can add, such as:
exclude=selinux*//Exclude some software in the upgrade list, you can use wildcards, the list of items to be separated by a space, which is installed such as beautify the package, Chinese patches of friends especially useful. Gpgcheck=1//There are 1 and 2 options, each representing whether the GPG (GNU Private Guard) checksum is performed to determine the source of the RPM package is valid and secure. 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
# 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 configuration file for the Yum network source
Centos-media.repo is a configuration file for Yum Local source
Modify Centos-media.repo
# Cat 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 the this repo and the Yum to install items directly off the# DVD ISO then we release.## to use this repo, put in Y Our DVDs and use it with the other repos too:# yum--enablerepo=c5-media [command]# # or for only the media repo, D o this:## yum--disablerepo=\*--enablerepo=c5-media [command] [c5-media]name=centos-$releasever-mediabaseurl= file:///media/CentOS/ file:///mnt/cdrom/ file:///media/cdrecorder/gpgcheck=1enabled=1gpgkey=file:/// Etc/pki/rpm-gpg/rpm-gpg-key-centos-5
Modify the 2nd path to/mnt/cdrom (that is, the CD mount point) in BaseURL
Change Enabled=0 to 1
3. Disable the default Yum network source
Rename the Yum network source profile to Centos-base.repo.bak, otherwise the appropriate package is first found in the network source and read directly from the local source after renaming.
4. Execute the Yum command
# yum Install PostgreSQL
About the format of the repo file
All repository server settings should follow the following format:
[Serverid]name=some name for this serverbaseurl=url://path/to/repository/
- ServerID is used to differentiate between different repository and must have a unique name;
- Name is a description of the repository, supporting variables like the $releasever $basearch;
- BaseURL is the most important part of the server Setup and is only set correctly to get the software from above. Its format is:
baseurl=url://server1/path/to/repository/url://server2/path/to/repository/url://server3/path/to/repository/
Where the URL supports the protocol has http:/ftp://file://three kinds. After BaseURL can be followed by multiple URLs, you can change 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 where the URL points to must be the upper level of the Repository header directory, and it also supports variables such as $releasever $basearch. You can add multiple options after the URL, such as Gpgcheck, Exclude, Failovermethod, and so on, such as:
[Updates-released]name=fedora Core $releasever-$basearch-released updatesbaseurl=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/$basearchgpgcheck =1exclude= Gaimfailovermethod=priority
Where the meaning of gpgcheck,exclude is the same as the [main] section, but only for this server, Failovermethode has two options roundrobin and priority, which means that when there are multiple URLs to choose from, Yum chooses the order, The Roundrobin is randomly selected, and if the connection fails, the next is used, looping sequentially, and priority starts with the first order of the URL. If not specified, the default is Roundrobin.
V. Configuration of domestic Yum sources
The system default Yum source speed is often unsatisfactory, in order to achieve the purpose of rapid installation, here to modify the Yum source for domestic sources.
Shanghai Jiaotong University Yum Source
A. Modify the/etc/yum.repos.d/centos-base.repo to:
# 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 is updated to and# geographically close to the client. You should use this for CentOS updates# unless is manually picking other mirrors.## If the mirrorlist= does For your, as a fall back you can try the # remarked out Baseurl= line instead.##[base]name=centos-$releasever-base#mirror list=http://mirrorlist.centos.org/?release= $releasever &arch= $basearch &repo=osbaseurl=http:// ftp.sjtu.edu.cn/centos/$releasever/os/$basearch/gpgcheck=1gpgkey=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=updatesbaseurl=http://ftp.sjtu.edu.cn/centos/$releasever/updates/$ Basearch/gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-centos-5#additional packages that could be useful[ extras]name=centos-$releasever-extras#mirrorlist=http://mirrorlist.centos.org/?release= $releasever &arch= $basearch &repo= extrasbaseurl=http://ftp.sjtu.edu.cn/centos/$releasever/extras/$basearch/gpgcheck=1gpgkey=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=centosplusbaseurl=http://ftp.sjtu.edu.cn/centos/$releasever/centosplus/$basearch/gpgcheck=1enabled= 0gpgkey=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= contribbaseurl=http://ftp.sjtu.edu.cn/centos/$releasever/contrib/$basearch/gpgcheck=1enabled=0gpgkey=file:/// Etc/pki/rpm-gpg/rpm-gpg-key-centos-5
About variables
- $releasever: The version that represents the release, obtained from DISTROVERPKG in the [main] section, if not, is judged based on the Redhat-release package.
- $arch: CPU system, such as I686,athlon, etc.
- $basearch: The basic system groups of CPUs, such as i686 and Athlon, belong to the same genus I386,alpha and Alphaev6 Alpha.
B. Import GPG KEY
Yum can use GPG to verify the package to ensure the integrity of the download package, so we have to go to each repository site to find GPG key, usually placed on the homepage of the eye-catching position, some names such as rpm-gpg-key-centos-5 such as plain text files, Download them and use the RPM--import rpm-gpg-key-centos-5 command to import the keys.
C. Executing 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 Polytechnic University: http://mirror.bit.edu.cn (IPV4 only) http://mirror.bit6.edu.cn (IPV6 only) Peking University: 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: 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/China University of Science and Technology: http://mirrors.ustc.edu.cn/(Ipv4+ipv6) http://mirrors4.ustc.edu.cn/http:// mirrors6.ustc.edu.cn/Tohoku University: 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 repositories are very limited and are limited to regular packages and updates to some packages in the release version, and with Rpmforge, you can add very many third-party RPM 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 of a third-party software library.
1. Install yum-priorities plug-in
This plugin is used to set the order in which Yum calls the software source. Because the official source of the software, are relatively stable and recommended to 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 yum-priorities this plugin.
# yum-y Install Yum-priorities
2. After installing the Yum-priorities plug-in, you need to set the. Repo related files (such as Centos-base.repo) in the/etc/yum.repos.d/directory, and insert the order directives in these files: priority=n (positive integers N 1 to 99) , the smaller the number, the higher the priority)
General configuration [Base], [addons], [updates], [extras] priority=1,[centosplus], priority=2 of [contrib], other third source of software: 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=osbaseurl=http://ftp.sjtu.edu.cn/centos/$releasever/os/$basearch/gpgcheck=1gpgkey=file:/// Etc/pki/rpm-gpg/rpm-gpg-key-centos-5priority=1
3, download and install the corresponding rpmforge RPM file package
# wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
4. Install the DAG's PGP Key
# RPM--import Http://apt.sw.be/RPM-GPG-KEY.dag.txt
5. Verify Rpmforge RPM file Package
# rpm-k rpmforge-release-0.5.2-2.el5.rf.*.rpm
6. Install 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
[email protected] yum.repos.d]# cat Rpmforge.repo
# # Name:rpmforge RPM Repository for RHEL 5-dag### url:http://rpmforge.net/[rpmforge]name = Rhel $releasever-rpmforg E.net-dagbaseurl = http://apt.sw.be/redhat/el5/en/$basearch/rpmforgemirrorlist = http://apt.sw.be/redhat/el5/en/ Mirrors-rpmforge#mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforgeenabled = 1protect = 0gpgkey = file:///etc/pki/ Rpm-gpg/rpm-gpg-key-rpmforge-daggpgcheck = 1priority=12
8. Test Installation
# yum Install Htop
Reference http://wiki.centos.org/AdditionalResources/Repositories/RPMForge#head-5aabf02717d5b6b12d47edbc5811404998926a1b
Other third-party repositories such as EPEL (Extra Packages for Enterprise Linux) and rpmfusion are similar to the installation and use of Rpmforge, and can be installed on their own.
Yum configuration details (forwarding)