1.备份原来的源文件
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2.换源(我这边试下来,华为的比阿里的更快)
阿里源:
[root@linux ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
--2019-07-10 01:22:45-- http://mirrors.aliyun.com/repo/Centos-6.repo
正在解析主机 mirrors.aliyun.com... 115.223.14.213, 122.225.67.224, 115.223.14.214, ...
正在连接 mirrors.aliyun.com|115.223.14.213|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:2523 (2.5K) [application/octet-stream]
正在保存至: “/etc/yum.repos.d/CentOS-Base.repo”
100%[=============================================================>] 2,523 --.-K/s in 0s
2019-07-10 01:22:50 (312 MB/s) - 已保存 “/etc/yum.repos.d/CentOS-Base.repo” [2523/2523]
华为源:
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.huaweicloud.com/repository/conf/CentOS-6-anon.repo
详见华为云官网说明:https://mirrors.huaweicloud.com
3.清理
[root@linux ~]# yum clean all
已加载插件:fastestmirror, refresh-packagekit, security
Cleaning repos: base extras updates
清理一切
Cleaning up list of fastest mirrors
4.生成缓存
[root@linux ~]# yum makecache
已加载插件:fastestmirror, refresh-packagekit, security
Determining fastest mirrors
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.7 kB 00:00
base/group_gz | 242 kB 00:00
base/filelists_db | 6.4 MB 00:00
base/primary_db | 4.7 MB 00:00
base/other_db | 2.8 MB 00:00
extras | 3.4 kB 00:00
extras/filelists_db | 24 kB 00:00
extras/prestodelta | 2.2 kB 00:00
extras/primary_db | 29 kB 00:00
extras/other_db | 14 kB 00:00
updates | 3.4 kB 00:00
updates/filelists_db | 3.6 MB 00:00
updates/prestodelta | 175 kB 00:00
updates/primary_db | 5.1 MB 00:00
updates/other_db | 249 kB 00:00
元数据缓存已建立