我的Redhat版本为:Red Hat Enterprise Linux Server release 7.5 (Maipo)
1.列出原装rpm包。
rpm -qa | grep yum
2.卸载列出的rpm包:
rpm -e yum-utils-1.1.31-45.el7.noarch --nodeps
rpm -e yum-metadata-parser-1.1.4-10.el7.x86_64 --nodeps
rpm -e yum-langpacks-0.4.2-7.el7.noarch --nodeps
rpm -e yum-3.4.3-158.el7.noarch --nodeps
rpm -e yum-rhn-plugin-2.0.1-10.el7.noarch --nodeps
3.从https://mirrors.163.com/ 找到你版本对应的CentOS的yum相关rpm,并下回来:
wget https://mirrors.163.com/centos/7.5.1804/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm
wget https://mirrors.163.com/centos/7.5.1804/os/x86_64/Packages/yum-updateonboot-1.1.31-45.el7.noarch.rpm
wget https://mirrors.163.com/centos/7.5.1804/os/x86_64/Packages/yum-utils-1.1.31-45.el7.noarch.rpm
wget https://mirrors.163.com/centos/7.5.1804/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget https://mirrors.163.com/centos/7.5.1804/os/x86_64/Packages/yum-3.4.3-158.el7.centos.noarch.rpm
4.安装刚才下好的rpm:
rpm -ivh yum-*
5.调整yum源配置文件:
vim /etc/yum.repos.d/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 - 163.com
#mirrorlist=https://mirrorlist.centos.org/ release=$7&arch=$basearch&repo=os
baseurl=https://mirrors.163.com/centos/7/os/$basearch/
gpgcheck=1
gpgkey=https://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$7 - Updates - 163.com
#mirrorlist=https://mirrorlist.centos.org/ release=$7&arch=$basearch&repo=updates
baseurl=https://mirrors.163.com/centos/7/updates/$basearch/
gpgcheck=1
gpgkey=https://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$7 - Extras - 163.com
#mirrorlist=https://mirrorlist.centos.org/ release=$7&arch=$basearch&repo=extras
baseurl=https://mirrors.163.com/centos/7/extras/$basearch/
gpgcheck=1
gpgkey=https://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$7 - Plus - 163.com
baseurl=https://mirrors.163.com/centos/7/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
其实就是把CentOS配置里的$releasever替换为了$7
6.清除yum缓存,之后即可正常使用。
yum clean all
yum makecache
方法整理自:https://www.linuxprobe.com/redhat-7-use-centos-yum-network-sources.html
如您从本文得到了有价值的信息或帮助,请考虑扫描文末二维码捐赠和鼓励。
如本文对您有用,捐赠和留言 将是对我最好的支持~(捐赠可转为站内积分)
如愿意,请向朋友推荐本站,谢谢。
尊重他人劳动成果。转载请务必附上原文链接,我将感激不尽。
留言