Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Configuration and use of YumSource in CentOS

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "the configuration and use of YumSource in CentOS". The content of the explanation in this article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "the configuration and use of YumSource in CentOS".

A brief introduction to yum

Yum, the abbreviation of Yellow dog Updater and Modified, is a software package manager developed by Duke University to improve the installation of RPM software packages. Originally developed by Terra Soft, the developer of the yellow dog distribution, and written in python, it was then called yup (yellow dog updater), and later improved by the Linux@Duke development team at Duke University. The purpose of yum is to automatically upgrade, install / remove rpm packages, collect information about rpm packages, check dependencies, and automatically prompt users for resolution. The key to yum is to have a reliable repository, as the name implies, this is a software repository, it can be a http or ftp site, it can also be a local software pool, but it must include the header,header of rpm, including a variety of information about the rpm package, including descriptions, functions, provided files, dependencies, etc. It is the collection and analysis of these header that automates the remaining tasks.

The idea of yum is to use a central warehouse (repository) to manage the relationship between some or even one distribution application, and to upgrade, install, delete and so on according to the calculated software dependency, so as to reduce the dependencies problem that Linux users have been having a headache. At this point, yum is the same as apt. Apt was originally used by debian's deb type software management, but now it can also use rpm under the RedHat door.

The main function of yum is to add / delete / update RPM packages more conveniently, automatically solve the problem of package dependence, and facilitate the management of a large number of system updates.

Yum can configure multiple resource libraries (Repository) and concise configuration files (/ etc/yum.conf) at the same time, automatically solve the dependency problems encountered when adding or deleting rpm packages, and maintain consistency with the RPM database.

II. Yum installation

CentOS has installed yum by default, so no additional installation is required. Here, for experimental purposes, uninstall yum and then reinstall it.

1. View the yum installed by default on the system

# 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 and install it from the Internet through wget, or you can mount the system installation CD for installation. Here, you can choose to mount the system installation CD 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 packages for yum include:

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 your own needs.

III. Yum configuration

The configuration file for yum is divided into two parts: main and repository

The global configuration options are defined in the main section, 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, which can have one or more. It is often located in the files in the / etc/yum.repo.d directory.

The yum.conf file is generally located in the / etc directory and generally contains only the configuration options for the main section.

# cat / etc/yum.conf

[main] cachedir=/var/cache/yum / / yum cache directory where yum stores downloaded rpm packages and databases. The default setting is whether to keep the software package after installation, 0 is not retained (default is 0), 1 is reserved debuglevel=2 / / Debug information output level, range is 0-10, default is 2logfile=/var/log/yum.log / / yum log file location. Users can check the / var/log/yum.log file for past updates. The policy of pkgpolicy=newest / / package. There are two options, newest and last, this function is that if you set up multiple repository and the same software exists in different repository at the same time, which yum should install, and if it is newest, yum will install the latest version. In the case of last, yum alphabetically sorts the server id and selects the software installation on the last server. Newest is usually chosen. Distroverpkg=redhat-release / / specify a package based on which yum will determine your distribution. The default is redhat-release, or it can be any rpm package installed for your own distribution. Tolerant=1 / / has two options 1 and 0, indicating whether yum tolerates errors related to software packages on the command line. For example, if you want to install three packages, 3 of which have already been installed, if you set it to 1, yum will not have an error message. The default is 0. Exactarch=1 / / has options 1 and 0, and if set to 1, yum will only install packages that match the system architecture. For example, yum will not install packages for i686 on systems that are suitable for i386. The default is 1. The number of retries after a retries=6 / / network connection error. If set to 0, it will be retried indefinitely. The default value is 6.obsoletes=1 / / this is a parameter for update, see yum (8), which is simply equivalent to upgrade and allows you to update stale RPM packages. Plugins=1 / / whether to enable the plug-in. Default 1 is allowed, and 0 means disallowed. We usually use the plug-in yum-fastestmirror. 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 = 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 as:

Exclude=selinux* / / excluding some software from the upgrade list, you can use wildcards, and the items in the list should be separated by spaces, which is especially useful for friends who have installed patches such as beautification packages and Chinese patches.

Gpgcheck=1 / / has two choices of 1 and 0, which represent whether or not to perform a gpg (GNU Private Guard) check to determine that the source of the rpm packet is valid and secure. This option, if set in the [main] section, is valid for each repository. The default value is 0.

4. Configure local yum source

1. Mount the installation CD of the system

# mount / dev/cdrom / mnt/cdrom/

2. Configure the local yum source

# cd / etc/yum.repos.d/

# ls

You will see four repo files

CentOS-Base.repo is the configuration file for the yum network source

CentOS-Media.repo is the configuration file for the local source of yum

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-Mediabaseurl= file:///media/CentOS/ file:///mnt/cdrom/ file:///media/cdrecorder/gpgcheck=1enabled=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

Modify the second path in baseurl to / mnt/cdrom (that is, the CD mount point)

Change enabled=0 to 1

3. Disable the default yum network source

Rename the yum network source configuration file to CentOS-Base.repo.bak, otherwise it will look for the appropriate package in the network source first, and then read it directly from the local source.

4. Execute the yum command

# yum install postgresql

About the format of repo files

All repository server settings should follow the following format:

[serverid] name=Some name for this serverbaseurl=url://path/to/repository/

Serverid is used to distinguish between different repository and must have a unique name.

Name is a description of repository and supports variables like $releasever $basearch

Baseurl is the most important part of the server setup, and the software can only be obtained from it if it is set correctly. Its format is:

Baseurl=url://server1/path/to/repository/ url://server2/path/to/repository/ url://server3/path/to/repository/

Among them, there are three protocols supported by url: http:// ftp:// file://. After baseurl, you can follow multiple url, and you can change it to a faster mirror station, but baseurl can only have one, 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 that url points to must be one level above the repository header directory, and it also supports variables such as $releasever $basearch.

After url, you can add several options, such as gpgcheck, exclude, failovermethod, etc., such as:

[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,exclude is the same as that of [main], but it only works on this server. Failovermethode has two options: roundrobin and priority, which means that when there are multiple url to choose, the order in which yum is selected, roundrobin is randomly selected, and if the connection fails, the next one is used, cycling in turn, and priority starts from the first one according to the order of url. If not specified, the default is roundrobin.

5. Configure domestic yum sources

The default yum source speed of the system is often not satisfactory. In order to achieve the purpose of rapid installation, the yum source is modified here as a domestic source.

Yum source of Shanghai Jiaotong University

a. Modify / 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=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 usefull [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 packa GE [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

About variables

$releasever: represents the version of the distribution, obtained from the distroverpkg in the [main] section, and if not, it is judged based on the redhat-release package.

$arch:cpu system, such as i686 Magi athlon, etc.

The basic system group of $basearch:cpu, such as i686 and athlon belong to i386 and alphaev6 belong to 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 put in a prominent place on the home page, some plain text files such as RPM-GPG-KEY-CentOS-5, download them, and then use the rpm-- import RPM-GPG-KEY-CentOS-5 command to import key.

c. Execute the yum command

Other domestic yum sources are listed as follows:

1. Corporate contribution:

Sohu open source mirror station: http://mirrors.sohu.com/

NetEase open source mirror station: http://mirrors.163.com/

two。 University teaching:

Beijing Institute of Technology:

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/

University of Science and Technology of China:

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/

Use third-party software libraries

Centos/RHEL 's default yum software repository is very limited, limited to regular packages and some software package updates in the distribution. With RpmForge, you can add a lot of third-party rpm packages. The RpmForge library now has more than 10000 CentOS software packages, which is considered by the CentOS community to be the most secure and stable third-party software library.

1. Install the yum-priorities plug-in

This plug-in is used to set the order in which yum invokes the software source. Because the official software sources are relatively stable and recommended. Therefore, the order of official sources is higher than that of third-party sources. How to ensure this order, you need to install the plug-in yum-priorities.

# 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 instruction in these files: priority=N (N is a positive integer from 1 to 99, the smaller the value, the better)

Generally configure [base], [addons], [updates], [extras] priority=1, [CentOSplus], [contrib] priority=2, and other third software sources are: 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 rpm package of the corresponding rpmforge

# wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm

4. Install PGP Key of DAG

# rpm-- import http://apt.sw.be/RPM-GPG-KEY.dag.txt

5. Verify the rpm package of rpmforge

# rpm-K rpmforge-release-0.5.2-2.el5.rf.*.rpm

6. Install the rpm package of rpmforge

# rpm-I rpmforge-release-0.5.2-2.el5.rf.i386.rpm

7. Set the level of the source in / 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: 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 the installation

# yum install htop

Thank you for your reading, the above is the content of "configuration and use of YumSource in CentOS". After the study of this article, I believe you have a deeper understanding of the configuration and use of YumSource in CentOS, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report