RHEL7更换CentOS的yum源

邮差的信 提交于 2020-03-17 09:00:17

1.检查是否安装yum包

查看RHEL是否安装了yum,若是安装了,那么又有哪些yum包:
[root@localhost /]# rpm -qa |grep yum
PackageKit-yum-1.1.5-1.el7.x86_64
yum-3.4.3-154.el7.noarch
yum-rhn-plugin-2.0.1-9.el7.noarch
yum-utils-1.1.31-52.el7.noarch
yum-metadata-parser-1.1.4-10.el7.x86_64
yum-langpacks-0.4.2-7.el7.noarch

2. 删除redhat自带的yum包

卸载上面显示的所有yum包:
rpm -qa|grep yum|xargs rpm -e --nodeps

3.下载新的yum包

可以在以下网站查看软件包的版本是否升级或者找到系统所对应的文件包版本;
网易163网络源地址:http://mirrors.163.com/
CentOS网络源地址:http://centos.ustc.edu.cn/centos/

wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-163.el7.centos.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-52.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-52.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/rpm-4.11.3-40.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-9.el7.noarch.rpm

4.安装yum软件包

rpm -ivh python-urlgrabber-3.10-9.el7.noarch.rpm
rpm -Uvh rpm-4.11.3-40.el7.x86_64.rpm --nodeps
rpm -Uvh yum-plugin-fastestmirror-1.1.31-52.el7.noarch.rpm --nodeps
rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
rpm -ivh yum-3.4.3-163.el7.centos.noarch.rpm
rpm -ivh yum-utils-1.1.31-52.el7.noarch.rpm

5.更换yum源

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
替换命令 :%s/$releasever/7/g
enabled=0 #数字“0”改成"1"
yum clean all
yum repolist all

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!