CentOS 7がyumソースを置き換えてyum makecacheが失敗した問題を解決

11022 ワード

仮想マシンが新しくインストールされ、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


キャッシュの作成に成功しました