CentOs切换yum源

1、备份现有源

1
mv /etc/yum.repos.d /etc/yum.repos.d.backup

2、设置新的yum目录

1
mkdir /etc/yum.repos.d

3、配置阿里云源

centos7

1
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

centos8

1
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo

4、清理缓存

1
yum clean all

5、重新生成新的缓存

1
yum makecache 

6、更新软件

1
yum update -y