以下操作均在root下进行:
[redhat@root ~]$ cat /etc/redhat-release 查看对应的版本号
Red Hat Enterprise Linux Server release 7.9 (Maipo)
[redhat@root ~]$ rpm -qa |grep yum 查看安装的yum源
yum-utils-1.1.31-54.el7_8.noarch
yum-metadata-parser-1.1.4-10.el7.x86_64
yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch
yum-3.4.3-168.el7.centos.noarch
[redhat@root ~]$ rpm -qa|grep yum|xargs rpm -e --nodeps #强行卸载所以yum源
[redhat@root ~]$ rpm -qa|grep yum #再次查看为空
下载以下依赖
[redhat@root ~]$
wget http://mirrors.aliyun.com/centos/7/os/x86_64/Packages/rpm-4.11.3-45.el7.x86_64.rpmwget http://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-10.el7.noarch.rpm
wget http://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm
wget http://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
[redhat@root ~]$ rpm -ivh --force rpm-4.11.3-45.el7.x86_64.rpm yum-metadata-parser-1.1.4-10.el7.x86_64.rpm python-urlgrabber-3.10-10.el7.noarch.rpm yum-3.4.3-168.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm --force
如果出现以下问题

解决方法
vim /etc/resolv.conf
加入以下内容
nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 223.5.5.5
nameserver 223.6.6.6
[redhat@root ~]$ wget http://mirrors.aliyun.com/repo/Centos-7.repo
[redhat@root ~]$ mv Centos-7.repo /etc/yum.repos.d/
[redhat@root ~]$ vi /etc/yum.repos.d/Centos-7.repo
%s/$releasever/7/g
#使用vi编辑器进行全局替换
[redhat@root ~]$ cd /etc/yum.repos.d/
mv redhat.repo redhat.repo.bak
关闭订阅插件提示
[redhat@root ~]$ vi /etc/yum.conf
plugins=0
[redhat@root ~]$ vim /etc/yum/pluginconf.d/subscription-manager.conf
[main]
enabled=0 #将它禁用掉
[redhat@root ~]$ yum clean all #清空 yum 缓存,使其设置生效
[redhat@root ~]$ yum makecache #加载服务器软件包缓存信息,提高搜索安装软件的速度
本文详细描述了如何在RedHat系统中更换yum源,卸载并重新安装必要的包,修复DNS问题,配置yum仓库,以及清理和刷新yum缓存的过程。

3239

被折叠的 条评论
为什么被折叠?



