一、准备环境
准备一台干净的CentOS7的环境,且可以ping通外网,之后清理官方yum源
cd /etc/yum.repos.d/ #官方yum源存放地
mkdir back
mv *.repo back #制作备份
二、配置yum源
在浏览器输入:https://mirrors.aliyun.com
在终端输入
[root@localhost yum.repos.d]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- 0 0 0 0 0 0 0 0 --:--:-- --:--:-- 100 2523 100 2523 0 0 3734 0 --:--:-- --:--:-- --:--:-- 3732
[root@localhost yum.repos.d]# curl -o /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- 100 664 100 664 0 0 2451 0 --:--:-- --:--:-- --:--:-- 2459
三、清除yum库
[root@localhost yum.repos.d]# yum clean all
已加载插件:fastestmirror
正在清理软件源: base epel extras updates
Cleaning up list of fastest mirrors
四、生成自己的缓存
[root@localhost yum.repos.d]# yum makecache #加载时间较长
五、列出yum源名称
[root@localhost yum.repos.d]# yum repolist
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
源标识 源名称 状态
base/7/x86_64 CentOS-7 - Base - mirrors.aliyun.com 10,072
epel/x86_64 Extra Packages for Enterprise Linux 7 - 13,786
extras/7/x86_64 CentOS-7 - Extras - mirrors.aliyun.com 518
updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com 5,434
repolist: 29,810