The configuration and usage of Yum source in CentOS _linux

Source: Internet
Author: User
Tags ftp site gpg reserved centos in python

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

# 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

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.

//yum cached directory, yum stores the downloaded rpm package and database here, the default setting is /var/cache/yum
//Whether the package is retained after the installation is complete, 0 is not reserved (default is 0), 1 is reserved
/ / Debug information output level, the range is 0-10, the default is 2
//yum log file location. Users can go to the /var/log/yum.log file to check for updates made in the past.
/ / 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.
/ / 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.
// 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.
// 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.
//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.
//This is an update parameter. See yum(8) for details. Simply put, it is equivalent to upgrade, allowing you to update stale RPM packages.
/ / Whether to enable the plugin, the default 1 is allowed, 0 means not allowed. We generally use the yum-fastestmirror plugin.
# Note: yum-RHN-plugin doesn't honor this.
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

# 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 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]

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

# yum Install PostgreSQL

About the format of the repo file

All repository server settings should follow the following format:

Name=some name for this server

    • 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:
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:// 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:

Name=fedora Core $releasever-$basearch-released Updates
baseurl= /updates/$releasever/$basearch$releasever/$basearch$releasever/$basearch

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.
name=CentOS-$releasever - Base
#released updates 
name=CentOS-$releasever - Updates
#additional packages that may be useful
name=CentOS-$releasever - Extras
#additional packages that extend functionality of existing packages
name=CentOS-$releasever - Plus
#contrib - packages by Centos Users
name=CentOS-$releasever - Contrib

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:

NetEase Open Source Mirror station:

2. University Teaching:

Beijing Institute (IPV4 only) (IPV6 only)

Bjtu (IPV4 only) (IPV6 only) (Ipv4+ipv6)

Lanzhou University:

Xiamen University:

Tsinghua university: only) only)

Tianjin University:

University of Science and Technology of China:

Northeastern only) only)

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:

#mirrorlist = $releasever &arch=$ Basearch&repo=os

3, download and install the corresponding rpmforge RPM packages

# wget

4, the installation of Dag PGP Key

# RPM--import Http://

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:
Name = RHEL $relea
baseurl =$basearch/rpmforge
mirrorlist = http://
#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

# yum Install Htop

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]
name=CentOS-$releasever - Media
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.