Installation and detailed explanation of centos yum Source
1. Introduction to yum
Yum, short for Yellow dog Updater and Modified, is a software package manager developed by Duke University to improve the installation of RPM software packages. It was initially developed by Terra Soft, a developer of the yellow dog release and written in python. It was also called yup (yellow dog updater ), after being improved by Duke's Linux @ Duke Development Team, this name is available. Yum is designed to automatically upgrade, install/remove rpm packages, collect rpm package information, check dependencies, and automatically prompt users to solve the problem. The key to yum is to have a reliable repository. As the name suggests, this is the software repository. It can be an http or ftp site, or a local software pool, but it must contain the rpm header, the header contains various rpm package information, including descriptions, functions, provided files, dependencies, and so on. Only by collecting and analyzing these headers can we automate the remaining tasks.
Yum uses a repository to manage the relationship between some or even a distribution application, and upgrades, installs, deletes, and so on based on the calculated software dependency, this reduces the dependencies problem that Linux users have always suffered. At this point, yum and apt are the same. Apt is originally used by deb software management of debian, but now it can also use rpm under RedHat.
Yum is mainly used to conveniently add, delete, and update RPM packages. It automatically solves the dependency problem of packages and facilitates management of a large number of system updates.
Yum can be used to configure multiple resource libraries (Repository) and a simple configuration file (/etc/yum. conf) automatically solves the dependency problem when the rpm package is added or deleted, and maintains consistency with the RPM database.
Ii. Install yum
By default, CentOS has installed yum without additional installation. For the purpose of this experiment, uninstall yum and reinstall it.
1. view the yum installed by default.
# 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. reinstall yum
You can use wget to download and install related packages from the Internet, or mount the system installation disc. Here, you can choose to mount the system installation disc 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
The basic installation package of yum includes:
Yum/RPM installer/updater
Yum-fastestmirror // Yum plugin which chooses fastest repository from a previous list
Yum-metadata-parser // A fast metadata parser for yum
Install other installation packages as needed.
Iii. yum Configuration
The configuration file of yum is divided into two parts: main and repository
The main section defines global configuration options. The entire yum configuration file should have only one main. It is usually located in/etc/yum. conf.
The repository section defines the specific configurations of each source/server. There can be one or more configurations. It is usually located in the files in the/etc/yum. repo. d directory.
The yum. conf file is generally located in the/etc directory, which generally only contains the configuration options of the main part.
# Cat/etc/yum. conf
[Main] cachedir =/var/cache/yum // yum cache directory, where yum stores the downloaded rpm package and database, the default value is/var/cache/yumkeepcache = 0. // whether the software package is retained after the installation is complete. If the value is 0, the software package is not retained (the default value is 0 ), 1 indicates the output level of the retained debuglevel = 2 // Debug information. The value range is 0-10. The default value is 2 logfile =/var/log/yum. log // yum log file location. You can query previous updates in the/var/log/yum. log file. Pkgpolicy = newest // package policy. There are two options: newest and last. If you set multiple repository and the same software exists in different repository, which one should yum install, if it is newest, yum will install the latest version. If it is last, yum will sort the server IDs in alphabetical order and select the software installation on the last server. Generally, select newest. Distroverpkg = redhat-release // specify a software package. yum determines your release version based on this package. The default value is redhat-release, you can also install any rpm packages for your own release. Tolerant = 1 // there are two options: 1 and 0, indicating whether yum can tolerate errors related to software packages in command lines. For example, you need to install packages 1, 2, and 3, 3 of them have been installed before. If you set it to 1, yum will not have an error message. The default value is 0. Exactarch = 1 // there are two options: 1 and 0. If this parameter is set to 1, yum only installs software packages that match the system architecture. For example, yum will not install the i686 software package in a system suitable for i386. The default value is 1. Retries = 6 // Number of retries after a network connection error occurs. If it is set to 0, the retries are unlimited. The default value is 6. obsoletes = 1 // This is an update parameter. For more information, see yum (8). In short, this parameter is equivalent to upgrade, which allows you to update outdated RPM packages. Plugins = 1 // whether to enable the plug-in. The default value is 1. 0 indicates no. We usually use the yum-fastestmirror plug-in. 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-plugindoesn 'thonorthis. metadata_expire = 1hinstallonly_limit = 5 # response. repo # in/etc/yum. repos. d
In addition to the above, there are some options that can be added, such:
Exclude = selinux * // exclude some software from the upgrade list. You can use wildcards to separate each item in the list with spaces. This installation includes beautification packages, chinese patching is particularly useful.
Gpgcheck = 1 // there are two options: 1 and 0, which respectively indicate whether or not gpg (GNU Private Guard) verification is performed to determine whether the rpm package source is valid and safe. This option is valid for each repository if it is set in [main. The default value is 0.
4. Configure the local yum Source
1. Mount the system installation disc
# Mount/dev/cdrom/mnt/cdrom/
2. Configure the local yum Source
# Cd/etc/yum. repos. d/
# Ls
Four repo files are displayed.
The CentOS-Base.repo is the configuration file for the yum network source
The CentOS-Media.repo is the configuration file of the yum local source
Modify CentOS-Media.repo
# Cat CentOS-Media.repo
#CentOS-Media.repo##ThisrepoisusedtomountthedefaultlocationsforaCDROM/DVDon#CentOS-5.Youcanusethisrepoandyumtoinstallitemsdirectlyoffthe#DVDISOthatwerelease.##Tousethisrepo,putinyourDVDanduseitwiththeotherrepostoo:#yum--enablerepo=c5-media[command]##orforONLYthemediarepo,dothis:##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
In baseurl, change the 2nd paths to/mnt/cdrom (that is, the disk mount point)
Change enabled = 0 to 1
3. Disable the default yum network source.
Rename the yum network source configuration file to the CentOS-Base.repo.bak, otherwise it will first find the appropriate package in the network source, renamed and directly read from the local source.
4. Run the yum command
# Yum install postgresql
Repo File Format
All repository server settings should follow the following format:
[serverid]name=Somenameforthisserverbaseurl=url://path/to/repository/
Serverid is used to distinguish different repository and must have a unique name;
Name is the description of repository and supports variables such as $ releasever $ basearch;
Baseurl is the most important part in server settings. You can obtain software from it only when the settings are correct. The format is:
baseurl=url://server1/path/to/repository/ url://server2/path/to/repository/ url://server3/path/to/repository/
The url supports three protocols: http: // ftp: // file. After baseurl, it can be followed by multiple URLs. You can change it to an image site with a high speed, but there can only be one baseurl, that is, it cannot be in 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 the repository header directory. It also supports variables such as $ releasever $ basearch.
You can add multiple options after the url, such as gpgcheck, exclude, and failovermethod. For example:
[updates-released]name=FedoraCore$releasever-$basearch-ReleasedUpdatesbaseurl=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
The meaning of gpgcheck and exclude is the same as that of [main], but it only works for this server. failovermethode has two options: roundrobin and priority, meaning that multiple URLs are available, the order of yum selection. roundrobin is a random selection. If the connection fails, use the next one, which loops in sequence. priority starts from the first one according to the url order. If not specified, the default value is roundrobin.
5. Configure domestic yum sources
The system's default yum source speed is often unsatisfactory. To achieve Fast Installation, modify the yum source here as the domestic source.
Shanghai Jiao Tong University yum Source
A. Modify/etc/yum. repos. d/CentOS-Base.repo:
#CentOS-Base.repo##ThemirrorsystemusestheconnectingIPaddressoftheclientandthe#updatestatusofeachmirrortopickmirrorsthatareupdatedtoand#geographicallyclosetotheclient.YoushouldusethisforCentOSupdates#unlessyouaremanuallypickingothermirrors.##Ifthemirrorlist=doesnotworkforyou,asafallbackyoucantrythe#remarkedoutbaseurl=lineinstead.##[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#releasedupdates[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#additionalpackagesthatmaybeuseful[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#additionalpackagesthatextendfunctionalityofexistingpackages[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-packagesbyCentosUsers[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: indicates the release version. It is obtained from distroverpkg in [main]. If not, it is determined based on the redhat-release package.
$ Arch: cpu system, such as i686 and athlon
$ Basearch: Basic cpu system group. For example, i686 and athlon belong to the same i386, and alpha and alphaev6 belong to the same alpha.
B. Import the GPG KEY
Yum can use gpg to verify the package to ensure the integrity of the downloaded package. Therefore, we need to find the gpg key at each repository site, which is usually placed in a prominent position on the home page, some plain text files named like RPM-GPG-KEY-CentOS-5, download them, and use the rpm -- import RPM-GPG-KEY-CentOS-5 command to import the key.
C. Execute the yum command
Other domestic yum sources are listed as follows:
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 University of Technology:
Http://mirror.bit.edu.cn (IPv4 only)
Http://mirror.bit6.edu.cn (IPv6 only)
Beijing Jiao Tong 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)
University of electronic science and technology: http://ubuntu.uestc.edu.cn/
6. Use third-party software libraries
The default yum software repository for Centos/RHEL is very limited. It is only limited to the regular packages and updates of some software packages in the released versions. Using RpmForge, many third-party rpm software packages can be added. The RpmForge library now has more than 10000 CentOS software packages, which is considered by the CentOS community as the safest and most stable third-party software library.
1. Install the yum-priorities plug-in.
This plug-in is used to set the order in which yum calls the software source. Because the official software sources are relatively stable and recommended. Therefore, the order of the official source is higher than that of the third source. To ensure this order, you need to install the yum-priorities plug-in.
# Yum-y install yum-priorities
2. After installing the yum-priorities plug-in, you need to set/etc/yum. repos. d/directory. repo-related files, such as CentOS-Base.repo, insert sequence instructions in these files: priority = N (N is a positive integer from 1 to 99, the smaller the value, the higher priority)
Generally, set the priority of [base], [addons], [updates], [extras] to 1, [CentOSplus], and [contrib] to 2. The 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=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 rpmforge rpm package
# Wgethttp: // pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
4. Install the PGP Key of the DAG
# Rpm -- importhttp: // apt. sw. be/RPM-GPG-KEY.dag.txt
5. Verify rpmforge's rpm file package
# Rpm-K rpmforge-release-0.5.2-2.el5.rf. *. rpm
6. Install rpmforge's rpm package
# Rpm-I rpmforge-release-0.5.2-2.el5.rf.i386.rpm
7. Set the source level in the/etc/yum. repos. d/rpmforge. repo file.
[Root @ TS-DEV yum. repos. d] # cat rpmforge. repo
###Name:RPMforgeRPMRepositoryforRHEL5-dag###URL:http://rpmforge.net/[rpmforge]name=RHEL$releasever-RPMforge.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 and install
# Yum install htop
Reference http://wiki.centos.org/AdditionalResources/Repositories/RPMForge#head-5aabf02717d5b6b12d47edbc5811404998926a1b
Install and use other third-party software libraries, such as EPEL (Extra Packages forEnterpriseLinux) and RPMFusion, similar to RPMForge.