1.首先确保自己虚拟能够连网测试一下:
ping www.baidu.com
2.备份原始镜像:
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
3.安装wget:
yum -y install wget
4.下载新的 CentOS-Base.repo 到 /etc/yum.repos.d/:
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
如出现报错信息用使用curl命令,取代wget命令进行镜像的下载:
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
5.更新镜像
yum clean all #清理源缓存
yum makecache #创建新缓存
6.进入yum源的配置路径,打开CentOS-Base.repo文件并改写配置文件,将 所有的http改为https
vi /etc/yum.repos.d/`CentOS-Base.repo`
7.更新yum
yum update