CentOS系统更换yum源(repomd.xml not found解决方案)
生活随笔
收集整理的這篇文章主要介紹了
CentOS系统更换yum源(repomd.xml not found解决方案)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
CentOS系統更換yum源
問題
當初瞎鼓搗服務器,更換yum源為aliyun的,奈何阿里的源最近全部打不開,導致yum安裝不了,一直報錯:
http://mirrors.aliyun.com/centos/6/os/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - “The requested URL returned error: 404 Not Found” Trying other mirror. http://mirrors.aliyuncs.com/centos/6/os/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 7 - “couldn’t connect to host” Trying other mirror. http://mirrors.cloud.aliyuncs.com/centos/6/os/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 6 - “Couldn’t resolve host ‘mirrors.cloud.aliyuncs.com’” Trying other mirror. Error: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again在網上查了些資料,總算弄懂應該怎么處理了,但是找不到一個對應的源,所以還原默認了;
1. 查詢服務器的系統版本
[root@nys yum.repos.d]# rpm -qi centos-release Name : centos-release Relocations: (not relocatable) Version : 6 Vendor: CentOS Release : 10.el6.centos.12.3 Build Date: Tue 26 Jun 2018 10:52:41 PM CST Install Date: Mon 23 Jul 2018 11:48:26 AM CST Build Host: x86-01.bsys.centos.org Group : System Environment/Base Source RPM: centos-release-6-10.el6.centos.12.3.src.rpm Size : 38232 License: GPLv2 Signature : RSA/SHA1, Tue 26 Jun 2018 11:35:30 PM CST, Key ID 0946fca2c105b9de Packager : CentOS BuildSystem <http://bugs.centos.org> Summary : CentOS release file Description : CentOS release files如上:Version,Release兩項,當前服務器操作系統的版本就是:6.10
2. 更換yum源
- 進入yum配置文件目錄
- 確保yum源可訪問,此處用的163源
http://mirrors.163.com/centos/6.10/
- 可以查看網易的源說明:
http://mirrors.163.com/.help/
- 下載對應版本的163源:
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
- 替換源文件到Base:
sudo cp CentOS6-Base-163.repo CentOS-Base.repo
- 更換Base文件中的路徑為指定版本號:
* 需要將$releasever替換為當前系統版本號:6.10,對應可訪問的163源路徑
http://mirrors.163.com/centos/6.10/
- 使用vim替換:
:%s/$releasever/6.10/g
- 僅展示部分替換后的文件內容:
3. 更新yum
#重置緩存 yum makecache其它可參考執行的命令
#檢查可以更新的軟件包 yum check-update #更新所有的軟件包 yum update #更新特定的軟件包 yum update kernel #大規模的升級 yum upgrade#清楚緩存中rpm包文件 yum clean packages #清楚緩存中rpm的頭文件 yum clean headers #清除緩存中舊的頭文件 yum clean old headers #清除緩存中舊的rpm頭文件和包文件 yum clean all如果不成功,還原為默認源配置文件
- CentOS-Base.repo 源文件內容,需要將版本6改為7,因為6版本repomd.xml文件已經沒有了,只能從7版本開始
http://mirror.centos.org/centos/7/os/x86_64/repodata/
[root@nys yum.repos.d]# cat CentOS-Base.repo # CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead. # #[base] name=CentOS-7 - Base mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=os&infra=$infra #baseurl=http://mirror.centos.org/centos/7/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6#released updates [updates] name=CentOS-7 - Updates mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=updates&infra=$infra #baseurl=http://mirror.centos.org/centos/7/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6#additional packages that may be useful [extras] name=CentOS-7 - Extras mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=extras&infra=$infra #baseurl=http://mirror.centos.org/centos/7/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6#additional packages that extend functionality of existing packages [centosplus] name=CentOS-7 - Plus mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=centosplus&infra=$infra #baseurl=http://mirror.centos.org/centos/7/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6#contrib - packages by Centos Users [contrib] name=CentOS-7 - Contrib mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=contrib&infra=$infra #baseurl=http://mirror.centos.org/centos/7/contrib/$basearch/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6- 更新epel.repo文件內容,將6改為7:
- 清楚緩存并重置
總結
以上是生活随笔為你收集整理的CentOS系统更换yum源(repomd.xml not found解决方案)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 你这还不精通NIO(Netty_1)
- 下一篇: 计算机软件技术大作业报告,多媒体技术大作