05 linux中yum源報錯
清華大學開源映象站:https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.9/os/x86_64/
首先確保我的虛擬機器網路是通的。
網絡卡域名伺服器配置:
cat /etc/sysconfig/network-scripts/ifcfg-eth0
然後cat /etc/resolv.conf,這裡的nameserver與網絡卡配置中的DNS配置對應就可。
測試網路是否通:ping www.baidu.com
網路是通的,排除DNS域名,防火牆沒關,網路介面卡必須修改為橋接這種可能性。
網上還有些人說是/etc/yum.repos.d/CentOS-Base.repo這個檔案的配置問題,註釋掉mirrorlist這個配置項就能成功,試下看看。
mirrorlist都註釋掉了,執行sudo yum update試試
還是沒能成功
把源站點配置改為國內清華大學站點https://mirrors.tuna.tsinghua.edu.cn/centos-vault找到對應的Centos版本,最終成功。
這裡參考了這位老兄的文章,https://blog.csdn.net/fangeqin/article/details/106170479?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-3.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-3.control
確認清華大學站點能訪問:
修改yum源站點配置:vi /etc/yum.repos.d/CentOS-Base.repo
對照清華大學映象站中的目錄修改後如下:
[base] name=CentOS-$releasever - Base #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.8/os/x86_64/gpgcheck=1 #gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.8/os/x86_64/RPM-GPG-KEY-CentOS-6 #released updates [updates] name=CentOS-$releasever - Updates #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/ baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.8/updates/x86_64/ gpgcheck=1 #gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.8/os/x86_64/RPM-GPG-KEY-CentOS-6 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/ baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.8/extras/x86_64/ gpgcheck=1 #gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.8/os/x86_64/RPM-GPG-KEY-CentOS-6 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/ baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.8/centosplus/x86_64/ gpgcheck=1 enabled=0 #gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.8/os/x86_64/RPM-GPG-KEY-CentOS-6 #contrib - packages by Centos Users [contrib] name=CentOS-$releasever - Contrib #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/ baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.8/contrib/x86_64/ gpgcheck=1 enabled=0 #gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.8/os/x86_64/RPM-GPG-KEY-CentOS-6
配置YUM源出現Errno 14 Could not open/read repomd.xml
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* c6-media:
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.7 kB 00:00
base/group_gz | 226 kB 00:00
base/filelists_db | 6.4 MB 00:06
base/other_db | 2.8 MB 00:02
file:///media/CentOS/repodata/repomd.xml: [Errno 14] Could not open/read file:///media/CentOS/repodata/repomd.xml
Trying other mirror.
file:///media/cdrecorder/repodata/repomd.xml: [Errno 14] Could not open/read file:///media/cdrecorder/repodata/repomd.xml
Trying other mirror.
file:///mnt/cdrom/repodata/repomd.xml: [Errno 14] Could not open/read file:///mnt/cdrom/repodata/repomd.xml
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: c6-media. Please verify its path and try again
解決辦法就是把本地源關閉:將/etc/yum.repos.d/CentOS-Media.repo裡面的enabled=1改成enabled=0即可,因為yum尋包的順序應該先是本地源,再尋網路源。