A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service
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 ), this name is also available after being improved by the [email protected] development team of Duke University. 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.
# 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
The basic installation package of Yum includes:
Install other installation packages as needed.
Iii. Yum Configuration
The configuration file of yum is divided into two parts: Main and repository
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 0 is not retained (the default value is 0), the value 1 is retained debuglevel = 2.
// Debug information output level, ranging from 0 to 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, or any installed RPM package 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, if you want 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
// The number of retries after a network connection error occurs. If it is set to 0, the Retry is unlimited. The default value is 6.
Obsoletes = 1
// This is an update parameter. For details, refer to Yum (8). In short, it is equivalent to upgrade and allows updating of old RPM packages. Plugins = 1
// Whether to enable the plug-in. The default value is 1, and 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-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
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
2. Configure the local Yum Source
# Cd/etc/yum. Repos. d/
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
# Cat CentOS-Media.repo
# 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
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=Some name for this serverbaseurl=url://path/to/repository/
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:
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=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
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## 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
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/
Http://mirrors.tuna.tsinghua.edu.cn/(IPv4 + IPv6)
Tianjin University: http://mirror.tju.edu.cn/
China University of Science and Technology:
Http://mirrors.ustc.edu.cn/(IPv4 + IPv6)
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
# Wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
4. Install the PGP key of the Dag
# Rpm -- import http://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.
[[Email protected] yum. Repos. d] # Cat rpmforge. Repo
### Name: RPMforge RPM Repository for RHEL 5 - 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
Install and use other third-party software libraries, such as epel (extra packages for Enterprise Linux) and rpmfusion, similar to rpmforge.
Configuration and use of centos Yum Source
Start building with 50+ products and up to 12 months usage for Elastic Compute Service