Configuration and use of the CentOS yum source
I. Introduction of YUM
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
650) this.width=650; "src=" http://image.mamicode.com/info/201603/20181021072246288895.jpg "/>
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
650) this.width=650; "src=" http://image.mamicode.com/info/201603/20181021072246351391.jpg "width=" "/>"
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.
650) this.width=650; "src=" http://image.mamicode.com/info/201603/20181021072246425605.jpg "width=" "/>"
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
650) this.width=650; "src="/img/fz.gif "alt=" copy Code "/>
[Main]cachedir=/var/cache/yum//yum Cache directory,yum This store downloaded rpm package and database, the default setting is/var/cache/yumkeepcache=0// If 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 function is if you set up multiple repository, and the same software in different repository in the same time,yum should install which, if it is newest, The yum will install the latest version. If it is last, yum will sort the server id in alphabetical order and select the software installation on the final server. Newest is generally chosen. Distroverpkg=redhat-release//Specifies a package,yum will determine your distribution based on this package, by default, Redhat-release, or any installation of the rpm package for its own release version. Tolerant=1//There are 1 and 2 options that indicate whether yum is tolerant of package-related errors on the command line, such as if you are installing a three-pack, 3 have 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 only installs packages that match the system schema, for example,yum does not install i686 packages on systems that are appropriate 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 a 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 = 5# put your repos here or in separate Files named file.repo# in /etc/yum.repos.d
650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "/>
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
650) this.width=650; "src=" http://image.mamicode.com/info/201603/20181021072246573056.jpg "/>
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
650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "/>
# centos-media.repo## 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 - Mediabaseurl=file:///media/CentOS/ file:///mnt/cdrom/ File:///media/cdrecorder/gpgchecK=1enabled=1gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-centos-5
650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "/>
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
650) this.width=650; "src=" http://image.mamicode.com/info/201603/20181021072246662894.jpg "/>
650) this.width=650; "src=" http://image.mamicode.com/info/201603/20181021072246738085.jpg "width=" "/>"
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:
650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "/>
[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
650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "/>
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:
650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "/>
# 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=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 may 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
650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "/>
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
650) this.width=650; "src=" http://image.mamicode.com/info/201603/20181021072246862100.jpg "width=" "/>"
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)
Beijing Jiaotong 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 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/
China University of Science and Technology:
http://mirrors.ustc.edu.cn/(Ipv4+ipv6)
http://mirrors4.ustc.edu.cn/
http://mirrors6.ustc.edu.cn/
Northeastern 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
650) this.width=650; "src=" http://image.mamicode.com/info/201603/20181021072246947056.jpg "width=" "/>"
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:
650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "/>
[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
650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "/>
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
650) this.width=650; "src=" http://image.mamicode.com/info/201603/20181021072247053494.jpg "width=" "/>"
7. Set the level of the source in the/etc/yum.repos.d/rpmforge.repo file
[email protected] yum.repos.d]# cat Rpmforge.repo
650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "/>
# # 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
650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "/>
8. Test Installation
# yum Install Htop
650) this.width=650; "src=" http://image.mamicode.com/info/201603/20181021072247157003.jpg "width=" "/>"
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.
Installation and production of Yum