![98b30d4e942f8cdf2170a22f007d8cb3.png](https://img-blog.csdnimg.cn/img_convert/98b30d4e942f8cdf2170a22f007d8cb3.png)
第一步、先卸载原有YUM
- 保证虚拟机的RHEL可以连接网络
- 卸载原有YUM的命令:rpm -qa|grep yum|xargs rpm -e --nodeps
- 确认是否卸载完成:rpm -qa |grep yum (回车后无信息显示代表OK!)
第二步、安装YUM
下载YUM包以及相关依赖文件(6个)
直接复制到终端中即可
wget http://mirrors.163.com/centos/7.7.1908/os/x86_64/Packages/rpm-4.11.3-40.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7.7.1908/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
wget http://mirrors.163.com/centos/7.7.1908/os/x86_64/Packages/python-urlgrabber-3.10-9.el7.noarch.rpm
wget http://mirrors.163.com/centos/7.7.1908/os/x86_64/Packages/yum-3.4.3-163.el7.centos.noarch.rpm
wget http://mirrors.163.com/centos/7.7.1908/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7.7.1908/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-52.el7.noarch.rpm
注:此处安装可能会有版本不同出现错误,可以去 http://mirrors.163.com/centos 找到高一些的版本
![bc12fb3c3760f8093cd7b8515242a72e.png](https://img-blog.csdnimg.cn/img_convert/bc12fb3c3760f8093cd7b8515242a72e.png)
http://mirrors.163.com/centos/你们找到的版本/os/x86_64/Packages/
找到新版本点击进入后,依次进入 os 、X86_64、Packages
在页面中Ctrl + F来查找上边不能安装的文件名【下边进行举例】
如果此文件没有:
wget http://mirrors.163.com/centos/7.7.1908/os/x86_64/Packages/rpm-4.11.3-40.el7.x86_64.rpm
Ctrl + F 查找文件的开头即可【rpm-4.11.3】
根据最新版本进行安装
*安装顺序* 必须按照我给的顺序安装
直接复制到终端中即可
rpm -Uvh rpm-4.11.3-40.el7.x86_64.rpm --nodeps 这个必须最先安装
rpm -Uvh python-urlgrabber-3.10-9.el7.noarch.rpm --nodeps
rpm -Uvh python-iniparse-0.4-9.el7.noarch.rpm --nodeps
rpm -ivh 此命令直接会把剩下的所有自动安装
安装后终端输入YUM,看看有没有反应。有反应的咱们接着弄。GO
最终、新建配置.repo文件
输入:vim /etc/yum.repos.d/CentOS-Base.repo 把下边的命令全部复制进去,wq!保存.
#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 - http://163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=os
baseurl=http://mirrors.163.com/centos/7/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$7 - Updates - http://163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/7/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$7 - Extras - http://163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/7/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$7 - Plus - http://163.com
baseurl=http://mirrors.163.com/centos/7/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7