Site icon 时鹏亮的Blog

Redhat 7使用CentOS 7的Yum源

请知悉:本文最近一次更新为 6年 前,文中内容可能已经过时。

我的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.从http://mirrors.163.com/ 找到你版本对应的CentOS的yum相关rpm,并下回来:

wget http://mirrors.163.com/centos/7.5.1804/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm
wget http://mirrors.163.com/centos/7.5.1804/os/x86_64/Packages/yum-updateonboot-1.1.31-45.el7.noarch.rpm
wget http://mirrors.163.com/centos/7.5.1804/os/x86_64/Packages/yum-utils-1.1.31-45.el7.noarch.rpm
wget http://mirrors.163.com/centos/7.5.1804/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://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=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 - 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 - 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 - 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

其实就是把CentOS配置里的$releasever替换为了$7

6.清除yum缓存,之后即可正常使用。

yum clean all
yum makecache

方法整理自:https://www.linuxprobe.com/redhat-7-use-centos-yum-network-sources.html


如您从本文得到了有价值的信息或帮助,请考虑扫描文末二维码捐赠和鼓励。

尊重他人劳动成果。转载请务必附上原文链接,我将感激不尽。


与《Redhat 7使用CentOS 7的Yum源》相关的博文:

Exit mobile version