centos开源镜像及更换

centos7开源镜像

1. 阿里云开源镜像站资源目录

https://mirrors.aliyun.com/centos/7/os/x86_64/

1、备份源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup 

2、下载新的 CentOS-Base.repo 到 /etc/yum.repos.d/
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo 

3、非阿里云ECS用户会出现 Couldn't resolve host 'mirrors.cloud.aliyuncs.com' 信息,不影响使用,可以修改配置
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo 

4、生成缓存
yum makecache 

5、查看当前源
yum repolist 

2. 网易开源镜像站

http://mirrors.163.com/

wget http://mirrors.163.com/ .help/CentOS6-Base-163.repo
wget -O CentOS-Base.repo http://mirrors.163.com/.help/CentOS6-Base-163.repo

1.进入/etc/yum.repos.d/目录
[root@localhost ~]# cd /etc/yum.repos.d/

2.备份本地源
[root@localhost yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.backup

3.下载网易源
[root@localhost yum.repos.d]# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo

4.更新缓存
[root@localhost yum.repos.d]# yum makecache(下一步也可以加上 yum clean all && yum update -y)

3. 华为云

CentOS的镜像地址为:https://repo.huaweicloud.com/centos/

1、备份配置文件:
cp -a /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak

2、两种方案,请大家自行选取。
方案一:
下载新的CentOS-Base.repo文件到/etc/yum.repos.d/目录下,选择CentOS版本:
CentOS 7
执行如下命令:
wget -O /etc/yum.repos.d/CentOS-Base.repo https://repo.huaweicloud.com/repository/conf/CentOS-7-reg.repo

方案二:
修改CentOS-Base.repo文件,取消baseurl开头的行的注释,并增加mirrorlist开头的行的注释。将文件中的http://mirror.centos.org替换成https://repo.huaweicloud.com,可以参考如下命令:
sed -i "s/#baseurl/baseurl/g" /etc/yum.repos.d/CentOS-Base.repo
sed -i "s/mirrorlist=http/#mirrorlist=http/g" /etc/yum.repos.d/CentOS-Base.repo
sed -i "s@http://mirror.centos.org@https://repo.huaweicloud.com@g" /etc/yum.repos.d/CentOS-Base.repo

3、执行yum clean all清除原有yum缓存。

4、执行yum makecache(刷新缓存)或者yum repolist all(查看所有配置可以使用的文件,会自动刷新缓存)。
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值