Configuration and use of the CentOS yum source

Source: Internet
Author: User
Tags ftp site



Reprint Address: http://www.cnblogs.com/mchina/archive/2013/01/04/2842275.html



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






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 here, the default setting is / var / cache / yum
keepcache = 0
// Whether to keep the software package after installation, 0 is not reserved (default is 0), 1 is reserved
debuglevel = 2
// Debug information output level, the range is 0-10, the default is 2
logfile = / var / log / yum.log
// yum log file location. Users can go to the /var/log/yum.log file to query the updates made in the past.
pkgpolicy = newest
// 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 should yum be installed? If it is newest, yum will install the latest version . If it is last, yum sorts the server ids alphabetically and selects the software installation on the last server. Generally choose newest.
distroverpkg = redhat-release
// Specify a package, yum will determine your release version based on this package, the default is redhat-release, or any rpm package installed for your own release.
tolerant = 1
// There are two options, 1 and 0, indicating whether yum will tolerate package-related errors on the command line. For example, you want to install three packages 1, 2, and 3, and 3 of them have been previously installed. If you set 1 , Then yum will not show an error message. The default is 0.
exactarch = 1
// 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 i686 packages on systems that are suitable for i386. The default is 1.
retries = 6
// The number of retries after an network connection error occurs. If set to 0, the number of retries will be unlimited. The default value is 6.
obsoletes = 1
// This is an update parameter. For details, please refer to yum (8). In short, it is equivalent to upgrade, which allows to update stale RPM packages.
plugins = 1
// Whether to enable the plug-in, the default 1 is allowed, 0 means not allowed. We generally use the yum-fastestmirror 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 does n’t honor this.
metadata_expire = 1h

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 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 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 - Media
baseurl=file:///media/CentOS/
        file:///mnt/cdrom/
        file:///media/cdrecorder/
gpgcheck=1
enabled=1
gpgkey=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 server
baseurl=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 Updates
baseurl=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/$basearch
gpgcheck=1
exclude=gaim
failovermethod=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 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=os
baseurl=http://ftp.sjtu.edu.cn/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=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=updates
baseurl=http://ftp.sjtu.edu.cn/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=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=extras
baseurl=http://ftp.sjtu.edu.cn/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=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=centosplus
baseurl=http://ftp.sjtu.edu.cn/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=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=contrib
baseurl=http://ftp.sjtu.edu.cn/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=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 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






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=os
baseurl=http://ftp.sjtu.edu.cn/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
priority=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 - RPMforge.net - dag
baseurl = http://apt.sw.be/redhat/el5/en/$basearch/rpmforge
mirrorlist = http://apt.sw.be/redhat/el5/en/mirrors-rpmforge
#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






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.



Configuration and use of the CentOS yum source


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: info-contact@alibabacloud.com 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.