1.檢查是否安裝yum軟件包.
[root@localhost ~]# rpm -qa |grep yum
yum-utils-1.1.31-24.el7.noarch
yum-langpacks-0.4.2-3.el7.noarch
yum-metadata-parser-1.1.4-10.el7.x86_64
yum-rhn-plugin-2.0.1-4.el7.noarch
PackageKit-yum-0.8.9-11.el7.x86_64
yum-3.4.3-118.el7.noarch
2.刪除RedHat自帶yum軟件包.
[root@localhost ~]# rpm -qa | grep yum | xargs rpm -e --nodeps
[root@localhost ~]# rpm -qa | grep yum
3.下載yum軟件包,使用CentOS 7的yum軟件包.
使用阿里雲地址下載
[root@localhost ~]# wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-metada ta-parser-1.1.4-10.el7.x86_64.rpm
[root@localhost ~]# wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-3.4.3- 150.el7.centos.noarch.rpm
[root@localhost ~]# wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-plugin -fastestmirror-1.1.31-40.el7.noarch.rpm
[root@localhost ~]# wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-utils- 1.1.31-40.el7.noarch.rpm
[root@localhost ~]# wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-url grabber-3.10-8.el7.noarch.rpm
(rpm -qa|grep python-urlgrabber|xargs rpm -e --nodeps )
或使用163地址下載
[root@localhost ~]# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
[root@localhost ~]# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-125.el7.centos.noarch.rpm
[root@localhost ~]# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
[root@localhost ~]# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-29.el7.noarch.rpm
4.安裝Yum軟件包.
注意:單獨安裝包可能會產生依賴包(如yum和yum-fastestmirror會相互依賴)
[root@localhost ~]# rpm -ivh python-urlgrabber-3.10-8.el7.noarch.rpm
[root@localhost ~]# rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm yum-3.4.3-150.el7 .centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-40.el7.noarch.rpm
5.更換Yum源,使用阿里雲或163的Yum源.
5.1 備份原鏡像文件
5.2 下載CentOS7-Base.repo到/etc/yum.repos.d/
[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS7-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.re po
5.3 修改CentOS-Base.repo文件中的$releasever全部替換爲版本號7. 或下載下面文件上傳至/etc/yum.repos.d 目錄.
5.4 運行 yum makecache 生成緩存.
[root@localhost ~]# yum clean all
[root@localhost ~]# yum makecache
[root@localhost ~]# yum update
[root@localhost ~]# yum repolist