CentOS7设置阿里镜像源

该文指导如何验证网络连接阿里云镜像,删除并备份yum源,特别是CentOS的Base和EPELrepo。接着,通过wget或curl下载阿里云的CentOS-Base.repo文件,并清除yum缓存。此外,还提到了网易163和中科大的Docker镜像加速配置方法。

1.验证网络可不可以连接阿里云镜像

ping mirrors.aliyun.com

2.删除原yum源

rm -rf /etc/yum.repos.d/*

2.1备份系统原来的epel文件

mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.bak

(epel的全称叫 Extra Packages for Enterprise Linux 。epel是由 Fedora 社区打造,为 RHEL 及衍生发行版如 CentOS、Scientific Linux 等提供高质量软件包的项目;

epel相当于一个第三方源。为什么需要 epel?因为 CentOS 官方源包含的大多数的库都是比较旧的。并且很多流行的库也不存在。当然这样做也是无可厚非的,毕竟服务器版本安全稳定是重点)

2.2备份系统原有的repo文件

mv /etc/yum.repos.d/Centos-Base.repo /etc/yum.repos.d/Centos-Base.repo.bak

3.下载阿里云文件

(前提要有wget

#wget命令下载:wget[options][url]

# wget命令下载: wget [options] [url]

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

# curl命令下载: curl [options] [url]

curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

4清除及缓存

# 清除yum缓存

yum clean all

# 缓存阿里云镜像

yum makecache

其他国内镜像源

网易163镜像加速

--registry-mirror=http://hub-mirror.c.163.com

中科大镜像加速

--registry-mirror=https://docker.mirrors.ustc.edu.cn

 创建文件夹

sudo mkdir -p /etc/docker

编辑/etc/docker/daemon.json文件,并输入国内镜像源地址

sudo vi /etc/docker/daemon.json

网易163镜像加速

{"registry-mirrors": ["http://hub-mirror.c.163.com"]

}

中科大镜像加速

{

    "registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"]     

}

阿里云和daocloud镜像加速需要注册账号

评论 3
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值