How to change the default yum source of CentOS to the domestic yum mirror source

Sometimes the default yum source of CentOS is not necessarily a domestic mirror, resulting in an unsatisfactory yum online installation and update speed. At this time, you need to set the yum source to a domestic mirror site. The main open source open source mirror sites in China should be NetEase and Alibaba Cloud.


Modify the default yum source of CentOS to mirrors.163.com

1. First, backup the system's own yum source configuration file /etc/yum.repos.d/CentOS-Base.repo

1
[root@localhost ~] # mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup


2. Enter the folder where the yum source configuration file is located

1
[root@localhost ~] # cd /etc/yum.repos.d/


3. Download the yum source configuration file of 163 to the above folder

CentOS7

1
[root@localhost yum.repos.d] # wget http://mirrors.163.com/.help/CentOS7-Base-163.repo

 
CentOS6

1
[root@localhost yum.repos.d] # wget http://mirrors.163.com/.help/CentOS6-Base-163.repo

 
CentOS5

1
[root@localhost yum.repos.d] # wget http://mirrors.163.com/.help/CentOS5-Base-163.repo


4. Run yum makecache to generate the cache

1
[root@localhost yum.repos.d] # yum makecache


5. At this time, update the system and you will see the following mirrors.163.com information

1
2
3
4
5
6
[root@localhost yum.repos.d] # yum -y update
已加载插件:fastestmirror, refresh-packagekit, security
设置更新进程Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com


Modify the default yum source of CentOS to mirrors.aliyun.com
1. First, back up the yum source configuration file that comes with the system /etc/yum.repos.d/CentOS-Base.repo

1
[root@localhost ~] # mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup


2. Download ailiyun's yum source configuration file to /etc/yum.repos.d/
CentOS7

1
[root@localhost ~] # wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo


CentOS6

1
[root@localhost ~] # wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo


CentOS5

1
[root@localhost ~] # wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo

 
3. Run yum makecache to generate the cache

1
[root@localhost ~] # yum makecache


4. At this time, update the system and you will see the following mirrors.aliyun.com information

1
2
3
4
5
6
[root@localhost ~] # yum -y update
已加载插件:fastestmirror, refresh-packagekit, security
设置更新进程Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325688412&siteId=291194637