1、首先备份一下系统原本的镜像配置文件
[root@localhost ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2、进入yum源配置文件所在文件夹
[root@localhost ~]# cd /etc/yum.repos.d/
需要切换到配置文件所在文件夹,否则会出错
3、确认centos的版本
4、下载yum源配置文件到上面的文件夹中
163镜像:
CentOS7
[root@localhost yum.repos.d]# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
CentOS6
[root@localhost yum.repos.d]# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
CentOS5
[root@localhost yum.repos.d]# wget http://mirrors.163.com/.help/CentOS5-Base-163.repo
阿里云镜像(阿里云不太好用,你们可以自己尝试一下,我也不知道什么问题):
CentOS7
[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
CentOS6
[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
CentOS5
[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
5、运行yum makecache生成缓存
[root@localhost ~]# yum makecache
6、更新系统,则会显示源信息
[root@localhost ~]# yum -y update