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

CentOS configure local yum source / Ali Cloud yum source / 163yuan source and configure priority of yum source

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

First, use Centos image to build local yum source.

Since the default yum source after installing centos is the official address of centos, it is slow to use or even inaccessible in China, so the general practice is to replace the default yum source with aliyun's yum source or 163domestic yum source (described below).

However, the above methods all require a network, and cannot be used when there is no network, so another common method is to use the iso image of Centos to build a local yum source, so that the speed of installing the software will be very fast, but the disadvantage is that some packages may not be available.

1. The default Yum source after installing Centos is as follows

[root@kangvcar] # ll / etc/yum.repos.d/total 32 RW Murray. 1 root root 1664 Dec 9 2015 CentOS-Base.repo-rw-r--r--. 1 root root 1309 Dec 9 2015 CentOS-CR.repo-rw-r--r--. 1 root root 649 Dec 9 2015 CentOS-Debuginfo.repo-rw-r--r--. 1 root root 290 Dec 9 2015 CentOS-fasttrack.repo-rw-r--r--. 1 root root 630 Dec 9 2015 CentOS-Media.repo-rw-r--r--. 1 root root 1331 Dec 9 2015 CentOS-Sources.repo-rw-r--r--. 1 root root 1952 Dec 9 2015 CentOS-Vault.repo

two。 Back up the default yum source (optional)

[root@kangvcar ~] # mkdir / opt/centos-yum.bak [root@kangvcar ~] # mv / etc/yum.repos.d/* / opt/centos-yum.bak/

3. Mount the CentOS image file on the virtual machine

[root@kangvcar ~] # mount-t iso9660 / dev/sr0 / opt/centosmount: / dev/sr0 is write-protected, mounting read-only

4. Write a repo file and point to the mount directory of the image

[root@kangvcar ~] # vi / etc/yum.repos.d/local.repo [local] name=localbaseurl= file:///opt/centosenabled=1gpgcheck=0

5. Clear cach

[root@kangvcar ~] # yum clean allLoaded plugins: fastestmirrorCleaning repos: localCleaning up everythingCleaning up list of fastest mirrors [root@kangvcar ~] # yum makecache / / caches yum sources locally to speed up software search and installation [root@kangvcar ~] # yum list / / lists 3780 packages

Second, modify the default CentOS yum source to the domestic aliyun yum source

Ali Yun's official tutorial: http://mirrors.aliyun.com/help/centos

1. The default Yum source after installing Centos is as follows

[root@kangvcar] # ll / etc/yum.repos.d/total 32 RW Murray. 1 root root 1664 Dec 9 2015 CentOS-Base.repo-rw-r--r--. 1 root root 1309 Dec 9 2015 CentOS-CR.repo-rw-r--r--. 1 root root 649 Dec 9 2015 CentOS-Debuginfo.repo-rw-r--r--. 1 root root 290 Dec 9 2015 CentOS-fasttrack.repo-rw-r--r--. 1 root root 630 Dec 9 2015 CentOS-Media.repo-rw-r--r--. 1 root root 1331 Dec 9 2015 CentOS-Sources.repo-rw-r--r--. 1 root root 1952 Dec 9 2015 CentOS-Vault.repo

two。 Back up the default yum source (optional)

[root@kangvcar ~] # mkdir / opt/centos-yum.bak [root@kangvcar ~] # mv / etc/yum.repos.d/* / opt/centos-yum.bak/

3. Download the aliyun yum source repo file (corresponding to your own system version)

# download operation CentOS 5wget-O / etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repoCentOS 6wget-O / etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repoCentOS 7wget-O / etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo[ corresponding to each system version repo file Root@kangvcar ~] # cat / etc/redhat-release / / View the version of the system, CentOS Linux release 7.2.1511 (Core) [root@kangvcar ~] # wget-O / etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo--2017-06-20 06purl 438muri-http://mirrors.aliyun.com/repo/Centos-7.repoResolving mirrors.aliyun.com (mirrors.aliyun.com). 112.124.140.210, 115.28.122.210Connecting to mirrors.aliyun.com (mirrors.aliyun.com) | 112.124.140.210 |: 80. Connected.HTTP request sent, awaiting response... 200 OKLength: 2573 (2.5K) [application/octet-stream] Saving to:'/ etc/yum.repos.d/CentOS-Base.repo'100% [= >] 2573 -.-K in 0s 2017-06-20 06:43:08 (118MB/s) -'/ etc/yum.repos.d/CentOS-Base.repo' saved [2573 Universe 2573]

4. Clear cach

[root@kangvcar ~] # yum clean allLoaded plugins: fastestmirrorCleaning repos: base extras updatesCleaning up everythingCleaning up list of fastest mirrors [root@kangvcar ~] # yum makecache / / cache yum sources locally to speed up software search and installation [root@kangvcar ~] # yum list / / A total of 9954 packages are listed

Modify the default CentOS yum source to the domestic 163source

Official tutorial: http://mirrors.163.com/.help/centos.html

1. The default Yum source after installing Centos is as follows

[root@kangvcar] # ll / etc/yum.repos.d/total 32 RW Murray. 1 root root 1664 Dec 9 2015 CentOS-Base.repo-rw-r--r--. 1 root root 1309 Dec 9 2015 CentOS-CR.repo-rw-r--r--. 1 root root 649 Dec 9 2015 CentOS-Debuginfo.repo-rw-r--r--. 1 root root 290 Dec 9 2015 CentOS-fasttrack.repo-rw-r--r--. 1 root root 630 Dec 9 2015 CentOS-Media.repo-rw-r--r--. 1 root root 1331 Dec 9 2015 CentOS-Sources.repo-rw-r--r--. 1 root root 1952 Dec 9 2015 CentOS-Vault.repo

two。 Back up the default yum source (optional)

[root@kangvcar ~] # mkdir / opt/centos-yum.bak [root@kangvcar ~] # mv / etc/yum.repos.d/* / opt/centos-yum.bak/

3. Download the 163yum source repo file

# download operation CentOS 5wget-O / etc/yum.repos.d/CentOS5-Base-163.repo http://mirrors.163.com/.help/CentOS5-Base-163.repoCentOS 6wget-O / etc/yum.repos.d/CentOS6-Base-163.repo http://mirrors.163.com/.help/CentOS6-Base-163.repoCentOS 7wget-O / etc/yum.repos.d/CentOS7-Base-163.repo http://mirrors. corresponding to each system version repo file 163.com/.help/CentOS7-Base-163.repo [root@kangvcar ~] # cat / etc/redhat-release / / View the version of the system CentOS Linux release 7.2.1511 (Core) [root@kangvcar ~] # wget-O / etc/yum.repos.d/CentOS7-Base-163.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo--2017-06-20 06purl 29MU 47ft-http://mirrors.163.com/ .help / CentOS7-Base-163.repoResolving mirrors.163.com (mirrors.163.com). 123.58.173.185, 123.58.173.186Connecting to mirrors.163.com (mirrors.163.com) | 123.58.173.185 |: 80. Connected.HTTP request sent, awaiting response... 200 OKLength: 1572 (1.5K) [application/octet-stream] Saving to:'/ etc/yum.repos.d/CentOS7-Base-163.repo'100% [= >] 1572 -.-K in 0s 2017-06-20 06:29:47 (293 MB/s)'/ etc/yum.repos.d/CentOS7-Base-163.repo' saved [1572 etc/yum.repos.d/CentOS7-Base-163.repo' saved 1572]

4. Clear cach

[root@kangvcar ~] # yum clean allLoaded plugins: fastestmirrorCleaning repos: base extras updatesCleaning up everythingCleaning up list of fastest mirrors [root@kangvcar ~] # yum makecache / / cache yum sources locally to speed up software search and installation [root@kangvcar ~] # yum list / / A total of 9951 packages are listed

Modify the priority of the yum source

Ps: when we have both local yum source and 163source, we certainly want to install the software using the local yum source when installing the software package, and then use the 163source to install the software when the local package is not available. This involves the issue of priority. The plug-in yum-plugin-priorities.noarch provided by yum can solve this problem.

1. Check to see if the system has priority plug-ins installed

[root@kangvcar ~] # rpm-qa | grep yum-plugin-yum-plugin-fastestmirror-1.1.31-34.el7.noarch / / the plug-in yum-plugin-priorities.noarch is not installed here [root@kangvcar ~] # yum search yum-plugin-priorities / / use search to see if this plug-in is available Loaded plugins: fastestmirrorLoading mirror speeds from cached hostfile* base: mirrors.aliyun.com* extras: mirrors.aliyun.com* updates: mirrors.aliyun.com=== N / S matched: yum-plugin-priorities = yum-plugin-priorities.noarch: plugin to give priorities to packages from different repos

two。 Install the yum-plugin-priorities.noarch plug-in

[root@kangvcar ~] # yum- y install yum-plugin-priorities.noarch

3. Check whether the plug-in is enabled

[root@kangvcar ~] # cat / etc/yum/pluginconf.d/ priorities.confession [main] enabled = 1Unigram 1 is enabled; 0 is disabled

4. Modify local yum source priority

[root@kangvcar] # ll / etc/yum.repos.d/total 8 RW Murray / RW Murray. 1 root root 2573 May 15 2015 CentOS-Base.repo-rw-r--r--. 1 root root 67 Jun 20 06:04 local.repo// has two repo files [root@kangvcar ~] # vi / etc/yum.repos.d/local.repo [local] name=localbaseurl= file:///opt/centosenabled=1gpgcheck=0priority=1// adds priority=1 on the original basis; the smaller the number, the higher the priority / / you can continue to modify the priority value of other sources. After testing, only configuring the priority of the local source to priority=1 will give priority to the use of the local source.

5. test

Before configuring priority: (using Aliyun yum source) [root@kangvcar ~] # yum-y install vimDependencies Resolved=Package Arch Version Repository Size=Installing:vim-enhanced x86'64 2yum 7.4.160-1.el7_3.1 updates 1.0 MUpdating for dependencies:vim-common x86 _ 64 2root@kangvcar 7.4.160-1.el7_3.1 updates 5.9m after omitting the configuration priority: (using local yum source) [root@kangvcar ~] # yum-y install vimDependencies Resolved=Package Arch Version Repository Size=Installing:vim-enhanced x86 requests 64 2 : 7.4.160-1.el7 local 1.0 MInstalling for dependencies:gpm-libs x86 degrees 64 1.20.7-5.el7 local 32 kperl x86 bands 64 4 5.el7 local 5.16.3-286.el7 local 8.0 Mperl-Carp Noarch 1.26-244.el7 local 19 kperl-Encode x86'64 2.51-7.el7 local 1.5 Mperl-Exporter noarch 5.68-3.el7 local 28 kperl-File-Path Noarch 2.09-2.el7 local 26 kperl-File-Temp noarch 0.23.01-3.el7 local 56k omitted

The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.

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