新装了虚拟机,替换yum源的过程中出现了问题,在这里总结一下:
按照网上的做法,依次执行以下命令替换yum源:
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all
yum makecache
但执行yum makecache建立缓存的时候,出现了下面的问题:
[root@localhost yum.repos.d]# yum makecache
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
base/7/x86_64/primary_db FAILED
http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/04efe80d41ea3d94d36294f7107709d1c8f70db11e152d6ef562da344748581a-primary.sqlite.bz2: [Errno 14] curl#6 - "Could not resolve host: mirrors.cloud.aliyuncs.com; Unknown error"
Trying other mirror.
(1/10): base/7/x86_64/group_gz | 165 kB 00:00:00
(2/10): base/7/x86_64/other_db | 2.6 MB 00:00:00
(3/10): extras/7/x86_64/filelists_db | 210 kB 00:00:00
(4/10): extras/7/x86_64/other_db | 103 kB 00:00:00
(5/10): updates/7/x86_64/primary_db | 6.7 MB 00:00:01
(6/10): updates/7/x86_64/filelists_db | 4.0 MB 00:00:02
(7/10): updates/7/x86_64/other_db | 487 kB 00:00:00
(8/10): base/7/x86_64/primary_db | 6.0 MB 00:00:01
base/7/x86_64/filelists_db FAILED
http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/41232548001a78473ae0f2d4b92e1ec28f7a0593e0495056515887fe2a39b416-filelists.sqlite.bz2: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/41232548001a78473ae0f2d4b92e1ec28f7a0593e0495056515887fe2a39b416-filelists.sqlite.bz2: (28, 'Connection timed out after 30004 milliseconds')
Trying other mirror.
extras/7/x86_64/primary_db FAILED
http://mirrors.aliyuncs.com/centos/7/extras/x86_64/repodata/8c048743b0740639c36ce95b6464f0d6c186db3981672c058c133d9f6cbf2485-primary.sqlite.bz2: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/7/extras/x86_64/repodata/8c048743b0740639c36ce95b6464f0d6c186db3981672c058c133d9f6cbf2485-primary.sqlite.bz2: (28, 'Connection timed out after 30001 milliseconds')
Trying other mirror.
最后是参考了下面的博客:
https://blog.51cto.com/aixer95/2325505
将CentOS-Base.repo文件里面使用的是https://mirrors.aliyuncs.com都注释掉,这个地址是用在阿里云服务器内网的,我们自己的电脑不可能链接得到
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
# http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
# http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
替换掉后,在执行:
yum clean all
yum makecache
[root@localhost yum.repos.d]# yum clean all
Loaded plugins: fastestmirror, langpacks
Cleaning repos: base extras updates
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors
[root@localhost yum.repos.d]# yum makecache
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
* base: mirrors.aliyun.com
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/10): base/7/x86_64/group_gz | 165 kB 00:00:00
(2/10): base/7/x86_64/primary_db | 6.0 MB 00:00:02
(3/10): base/7/x86_64/filelists_db | 7.3 MB 00:00:03
(4/10): extras/7/x86_64/primary_db | 159 kB 00:00:00
(5/10): extras/7/x86_64/other_db | 103 kB 00:00:00
(6/10): extras/7/x86_64/filelists_db | 210 kB 00:00:00
(7/10): base/7/x86_64/other_db | 2.6 MB 00:00:00
(8/10): updates/7/x86_64/filelists_db | 4.0 MB 00:00:01
(9/10): updates/7/x86_64/other_db | 487 kB 00:00:00
(10/10): updates/7/x86_64/primary_db | 6.7 MB 00:00:02
Metadata Cache Created
缓存建立成功
版权声明:本文为weixin_44125034原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。