一键

cd /etc/yum.repos.d/
mkdir bak
mv * bak/
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum clean all
yum makecache

一.yum源理解

yum源仓库的地址 在/etc/yum.repos.d/,并且只能读出第一层的repo文件
yum仓库的文件都是以.repo结尾的

二.下载阿里云的.repo仓库文件 ,放到/etc/yum.repos.d/

备份原本的仓库文件
cd /etc/yum.repos.d/
mkdir allbak
mv CentOS-* allbak
此时 /etc/yum.repos.d/底下就没有repo文件,此时无法使用yum工具,必须配置yum源,生成新的.repo文件

1、下载第一个阿里云仓库文件

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

-O 参数 ,指定一个下载地址,且改名

2、配置第二个仓库文件 epel 额外仓库(redis,nginx,mongo,ipython)

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

3、清空原本yum缓存

yum clean all

4、生成新的阿里云的yum缓存,加速下载预热数据

yum makecache
Logo

更多推荐