微信号复制成功
微信号:ganshangwoniu
请返回微信添加朋友,粘贴微信号
如何更换centos系统为阿里云的yum源
centos更新云服务器的系统或者软件时,可以连接Internet,通过外部CentOS镜像源提供相关服务。如果云服务器无法访问Internet,或者外部CentOS镜像源提供的服务不稳定时,可以使用阿里云提供的CentOS镜像源进行更新。
操作步骤
1、执行以下命令,备份CentOS-Base.repo文件
mv/etc/yum.repos.d/CentOS-Base.repo/etc/yum.repos.d/CentOS-Base.repo.backup
2、使用wget命令下载对应版本的CentOS-Base.repo文件,并将其放入/etc/yum.repos.d/目录。
centos7:
wget-O/etc/yum.repos.d/CentOS-Base.repohttp://mirrors.aliyun.com/repo/Centos-7.repo
centos8:
wget-O/etc/yum.repos.d/CentOS-Base.repohttp://mirrors.aliyun.com/repo/Centos-8.repo
3、更换后执行:
yumcleanall
4、清除原来的yum源缓存
yummakecache
说明:
如果执行命令yum makecache后,回显信息为“Another app is currently holding the yum lock”,则需执行命令rm -rf /var/run/yum.pid删除yum.pid文件,然后再执行命令yum makecache生成缓存。
如果执行命令yum makecache后,回显信息为“Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again”,则需执行命令yum –disablerepo=epel -y update ca-certificates更新证书,临时禁用epel源。
如果使用过程中发现某些包不可用,可能是数据正在同步,请过几个小时后再重试。
QQ在线沟通,点击马上咨询在线咨询
电话咨询:
177-2050-9380
微信咨询:
ganshangwoniu