CentOS更换yum源
centos系统更换源
1.备份原始yum源
cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
2.下载yum文件,替代原始yum源(这里替换aliyun源)
CentOS 6系统命令
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-6.10.repo
如果wget命令不生效,说明还没有安装wget工具,或者使用
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-6.10.repo
CentOS 7系统命令
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
或者
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/CentOS-7.repo
CentOS 8系统命令
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
或者
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
3.yum clean all && yum makecache 清除并生成缓存,会把新下载CentOS-Base.repo源生效。
4.其它
非阿里云ECS用户会出现 Couldn't resolve host 'mirrors.cloud.aliyuncs.com' 信息,不影响使用。用户也可自行修改相关配置: eg:
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
其它yum源下载地址:
腾讯源
Centos5: http://mirrors.cloud.tencent.com/repo/centos5_base.repo
Centos6: http://mirrors.cloud.tencent.com/repo/centos6_base.repo
Centos7: http://mirrors.cloud.tencent.com/repo/centos7_base.repo
网易源
Centos5: http://mirrors.163.com/.help/CentOS5-Base-163.repo
Centos6: http://mirrors.163.com/.help/CentOS6-Base-163.repo
Centos7: http://mirrors.163.com/.help/CentOS7-Base-163.repo
华为源
Centos5:https://repo.huaweicloud.com/repository/conf/CentOS-5-reg.repo
Centos6:https://repo.huaweicloud.com/repository/conf/CentOS-6-reg.repo
Centos7:https://repo.huaweicloud.com/repository/conf/CentOS-7-reg.repo
注意:安装时可能出现的错误
-bash: wget: command not found
解决办法:
# 执行如下命令
yum install -y wget