1.先备份CentOS-Base.repo文件
2.下载新的CentOS-Base.repo 到/etc/yum.repos.d/
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
方法2、修改CentOS-Base.repo文件。将文件中的baseurl地址修改为源地址即可!
[root@localhost ~]# vi /etc/yum.repos.d/CentOS-Base.repo
末行模式介入一下内容:
:1,$s#mirrors.aliyun.com#mirrors.163.com#g
3.清除yum原来的缓存:yum clean all
生成新的缓存缓存:yum makecache
更新系统时不升级内核:yum --exclude=kernel* update 或者修改vim /etc/yum.conf