1. 首先刪除redhat原有的yum rpm -aq | grep yum | xargs rpm -e --nodeps rpm -aq | grep yum | xargs rpm -e --nodeps rpm -aq | grep python-iniparse | xargs rpm - ...
1. 首先刪除redhat原有的yum
- rpm -aq | grep yum | xargs rpm -e --nodeps
- rpm -aq | grep python-iniparse | xargs rpm -e --nodeps
查看是否已經卸載完成:
- rpm -aq | grep yum
- rpm -aq | grep python-iniparse
2. 下載yum安裝包
- wget http://mirrors.163.com/centos/7.4.1708/os/x86_64/Packages/yum-3.4.3-154.el7.centos.noarch.rpm
- wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
- wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
- wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-42.el7.noarch.rpm
- wget http://mirrors.163.com/centos/7/os/x86_64/RPM-GPG-KEY-CentOS-7
先安裝python,在安裝yum-metadata 最後兩個yum一起安裝。
3. 安裝下載的rpm包
rpm -ivh python-iniparse-0.4-9.el7.noarch.rpm yum-metadata-parser-1.1.4-10.el7.x86_64.rpm yum-3.4.3-154.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-42.el7.noarch.rpm
4. 創建文件/etc/yum.repos.d/CentOS-Base.repo
可以使用網易雲或阿裡雲鏡像站點:
網易雲鏡像:
[base] name=CentOS-$releasever - Base baseurl=http://mirrors.163.com/centos/7.4.1708/os/$basearch/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/7.4.1708/os/x86_64/RPM-GPG-KEY-CentOS-7 #released updates [updates] name=CentOS-$releasever - Updates baseurl=http://mirrors.163.com/centos/7.4.1708/updates/$basearch/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/7.4.1708/os/x86_64/RPM-GPG-KEY-CentOS-7 [extras] name=CentOS-$releasever - Extras baseurl=http://mirrors.163.com/centos/7.4.1708/extras//$basearch/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/7.4.1708/os/x86_64/RPM-GPG-KEY-CentOS-7 [centosplus] name=CentOS-$releasever - Plus baseurl=http://mirrors.163.com/centos/7.4.1708/centosplus//$basearch/ gpgcheck=1 enabled=0
阿裡雲鏡像:
[base] name=CentOS-$releasever - Base baseurl=https://mirrors.aliyun.com/centos/7.4.1708/os/$basearch/ gpgcheck=1 gpgkey=https://mirrors.aliyun.com/centos/7.4.1708/os/x86_64/RPM-GPG-KEY-CentOS-7 #released updates [updates] name=CentOS-$releasever - Updates baseurl=https://mirrors.aliyun.com/centos/7.4.1708/updates/$basearch/ gpgcheck=1 gpgkey=https://mirrors.aliyun.com/centos/7.4.1708/os/x86_64/RPM-GPG-KEY-CentOS-7 [extras] name=CentOS-$releasever - Extras baseurl=https://mirrors.aliyun.com/centos/7.4.1708/extras//$basearch/ gpgcheck=1 gpgkey=https://mirrors.aliyun.com/centos/7.4.1708/os/x86_64/RPM-GPG-KEY-CentOS-7 [centosplus] name=CentOS-$releasever - Plus baseurl=https://mirrors.aliyun.com/centos/7.4.1708/centosplus//$basearch/ gpgcheck=1 enabled=0
5. yum clean all
6. yum makecache(生成本地緩存)
附:yum源變更說明
經查從2018年05月24日起阿裡雲和網易雲鏡像站點中對於CentOS 7.4.1708版本的yum源已經不做支持,在鏡像站點中附帶了一個readme文件說明如下:
解決該站點鏡像無法使用的方式有如下兩種:
方式一:將上述第4點中所有的7.4.1708替換為7
方式二:將上述第4點中所有的mirrors.163.com或mirrors.aliyun.com替換為vault.centos.org
yum update出現: