1.备份现有的源
mv /etc/yum.repos.d /etc/yum.repos.d.backup
2.设置新的yun目录
mkdir /etc/yum.repos.d
3.安装wget
yum install -y wget
4.根据系统版本选择镜像源
##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
CentOS 8
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
5.清除文件并重建元数据缓存
yum clean all
yun makecache
6.更新软件包
yum update -y
完成!
网友评论