CentOS configures local yum source/Alibaba Cloud yum source/163yuan source and configures the priority of yum source

CentOS configures local yum source/Alibaba Cloud yum source/163yuan source and configures the priority of yum source

1. Use Centos image to build local yum source

Since the default yum source after installing centos is the official address of centos, it is very slow to use or even inaccessible in China. Therefore, the general practice is to replace the default yum source with aliyun's yum source or 163 and other domestic yum sources (the following describes how to configure it).

However, the above methods all require the Internet, and they cannot be used when there is no Internet. Therefore, another commonly used method is to use the Centos iso image to build a local yum source, which will greatly speed up the installation of the software. 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-r--r--. 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

2. 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/centos
mount: /dev/sr0 is write-protected, mounting read-only

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

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

5. Clear cache

[root@kangvcar ~]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: local
Cleaning up everything
Cleaning up list of fastest mirrors
[root@kangvcar ~]# yum makecache //Cache the yum source locally to speed up software search and installation [root@kangvcar ~]# yum list //Lists 3780 packages

2. Change the default CentOS yum source to the domestic aliyun yum source

Alibaba Cloud 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-r--r--. 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

2. 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 (download the corresponding system version)

#Download operations corresponding to the repo files of each system version CentOS 5
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
CentOS 6
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
[root@kangvcar ~]# cat /etc/redhat-release //View the system version 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 06:43:08-- http://mirrors.aliyun.com/repo/Centos-7.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 112.124.140.210, 115.28.122.210
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|112.124.140.210|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2573 (2.5K) [application/octet-stream]
Saving to: '/etc/yum.repos.d/CentOS-Base.repo'
100%[===================================================================================================================>] 2,573 --.-K/s in 0s   
2017-06-20 06:43:08 (118 MB/s) - '/etc/yum.repos.d/CentOS-Base.repo' saved [2573/2573]

4. Clear the cache

[root@kangvcar ~]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: base extras updates
Cleaning up everything
Cleaning up list of fastest mirrors
[root@kangvcar ~]# yum makecache //Cache the yum source locally to speed up software search and installation [root@kangvcar ~]# yum list //A total of 9954 packages are listed

3. Change the default CentOS yum source to the domestic 163 source

163 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-r--r--. 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

2. 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 163 yum source repo file

#Download operations corresponding to the repo files of each system version CentOS 5
wget -O /etc/yum.repos.d/CentOS5-Base-163.repo http://mirrors.163.com/.help/CentOS5-Base-163.repo
CentOS 6
wget -O /etc/yum.repos.d/CentOS6-Base-163.repo http://mirrors.163.com/.help/CentOS6-Base-163.repo
CentOS 7
wget -O /etc/yum.repos.d/CentOS7-Base-163.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo
[root@kangvcar ~]# cat /etc/redhat-release //View the system version 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 06:29:47-- http://mirrors.163.com/.help/CentOS7-Base-163.repo
Resolving mirrors.163.com (mirrors.163.com)... 123.58.173.185, 123.58.173.186
Connecting to mirrors.163.com (mirrors.163.com)|123.58.173.185|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1572 (1.5K) [application/octet-stream]
Saving to: '/etc/yum.repos.d/CentOS7-Base-163.repo'
100%[==================================================================================================================>] 1,572 --.-K/s in 0s   
2017-06-20 06:29:47 (293 MB/s) - '/etc/yum.repos.d/CentOS7-Base-163.repo' saved [1572/1572]

4. Clear the cache

[root@kangvcar ~]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: base extras updates
Cleaning up everything
Cleaning up list of fastest mirrors
[root@kangvcar ~]# yum makecache //Cache the yum source locally to speed up software search and installation [root@kangvcar ~]# yum list //A total of 9951 packages are listed

4. Modify the priority of the yum source

ps: When there are both local yum sources and 163 sources, we certainly hope to use the local yum source to install the software package first, and then use the 163 source to install the software when no available package is found locally. This involves the issue of priority. The yum plug-in yum-plugin-priorities.noarch can solve this problem.

1. Check whether the system has installed the priority plug-in

[root@kangvcar ~]# rpm -qa | grep yum-plugin-
yum-plugin-fastestmirror-1.1.31-34.el7.noarch    
//Here we can see that the yum-plugin-priorities.noarch plugin is not installed [root@kangvcar ~]# yum search yum-plugin-priorities    
//Use search to see if this plugin is available Loaded plugins: fastestmirror
Loading 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

2. Install the yum-plugin-priorities.noarch plugin

[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.conf
[main]
enabled = 1
//1 is enabled; 0 is disabled

4. Modify the local yum source to use first

[root@kangvcar ~]# ll /etc/yum.repos.d/
total 8
-rw-r--r--. 1 root root 2573 May 15 2015 CentOS-Base.repo
-rw-r--r--. 1 root root 67 Jun 20 06:04 local.repo
//There are two repo files [root@kangvcar ~]# vi /etc/yum.repos.d/local.repo
[local]
name=local
baseurl=file:///opt/centos
enabled=1
gpgcheck=0
priority=1
//Add priority=1 to the original value; the smaller the number, the higher the priority. //You can continue to modify the priority values ​​of other sources. After testing, only configuring the priority of the local source as priority=1 will give priority to the local source.

5. Testing

Before configuring the priority: (Using Alibaba Cloud yum source)
[root@kangvcar ~]# yum -y install vim
Dependencies Resolved
=================================================================================================================================================
Package Arch Version Repository Size
=================================================================================================================================================
Installing:
vim-enhanced x86_64 2:7.4.160-1.el7_3.1 updates 1.0 M
Updating for dependencies:
vim-common x86_64 2:7.4.160-1.el7_3.1 updates 5.9 M
Omit...
After configuring the priority: (using local yum source)
[root@kangvcar ~]# yum -y install vim
Dependencies Resolved
=================================================================================================================================================
Package Arch Version Repository Size
=================================================================================================================================================
Installing:
vim-enhanced x86_64 2:7.4.160-1.el7 local 1.0 M
Installing for dependencies:
gpm-libs x86_64 1.20.7-5.el7 local 32k
perl x86_64 4:5.16.3-286.el7 local 8.0 M
perl-Carp noarch 1.26-244.el7 local 19k
perl-Encode x86_64 2.51-7.el7 local 1.5 M
perl-Exporter noarch 5.68-3.el7 local 28k
perl-File-Path noarch 2.09-2.el7 local 26 k
perl-File-Temp noarch 0.23.01-3.el7 local 56 k
Omit...

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Detailed explanation of CentOS7 online installation of Docker 17.03.2 using Alibaba Cloud Docker Yum source
  • Detailed explanation of CentOS configuration of Nginx official Yum source
  • CentOS7 configuration Alibaba Cloud yum source method code
  • Install mysql 5.6 from yum source in centos7.4 system
  • How to change the yum source in CentOS
  • CentOS 6.5 local Yum source configuration tutorial
  • Detailed explanation of how to configure local yum source in centos7
  • Detailed configuration and use of yum source in CentOS
  • Detailed explanation of using yum source in CentOS7 Alibaba Cloud
  • Configure MySQL source and install MySQL using yum under CentOS 7
  • How to change the yum update source in CentOS
  • Tutorial on compiling and installing MySQL and setting up related yum sources under CentOS system

<<:  Detailed explanation of the use of the built-in function locate instr position find_in_set in MySQL efficient fuzzy search

>>:  How to build a Vue3 desktop application

Recommend

Solve the problem of mysql data loss when docker restarts redis

Official documentation: So mysql should be starte...

Detailed explanation of scp and sftp commands under Linux

Table of contents Preface 1. scp usage 2. Use sft...

Why can't the MP4 format video embedded in HTML be played?

The following code is in my test.html. The video c...

In-depth analysis of MySQL deadlock issues

Preface If our business is at a very early stage ...

WeChat applet implements form verification

WeChat applet form validation, for your reference...

JavaScript Interview: How to implement array flattening method

Table of contents 1 What is array flattening? 2 A...

How does MySQL connect to the corresponding client process?

question For a given MySQL connection, how can we...

MySQL master-slave configuration study notes

● I was planning to buy some cloud data to provid...

A brief talk about Rx responsive programming

Table of contents 1. Observable 2. Higher-order f...

Practical explanation of editing files, saving and exiting in linux

How to save and exit after editing a file in Linu...

Simple understanding and examples of MySQL index pushdown (ICP)

Preface Index Condition Pushdown (ICP) is a new f...

Vue3+script setup+ts+Vite+Volar project

Table of contents Create a vue + ts project using...