Redhat7 yum源换成centos的YUM 源

一、卸载原有的yum的rpm包

查看原有的yum:rpm -qa | grep yum
Redhat7 yum源换成centos的YUM 源_第1张图片

卸载以上安装包

[root@wxd src]# rpm -qa | grep yum | xargs rpm -e --nodeps

查看是否删除完成

[root@wxd src]# rpm -qa | grep yum

二、去阿里镜像站下载centos必要的yum包

测试主机可以上网

[root@wxd src]# ping mirrors.aliyun.com
PING mirrors.aliyun.com.w.alikunlun.com (219.238.20.88) 56(84) bytes of data.
64 bytes from 219.238.20.88: icmp_seq=1 ttl=50 time=2.16 ms
64 bytes from 219.238.20.88: icmp_seq=2 ttl=50 time=3.72 ms
64 bytes from 219.238.20.88: icmp_seq=3 ttl=50 time=2.95 ms
64 bytes from 219.238.20.88: icmp_seq=4 ttl=50 time=3.53 ms

--- mirrors.aliyun.com.w.alikunlun.com ping statistics ---
8 packets transmitted, 8 received, 0% packet loss, time 125997ms
rtt min/avg/max/mdev = 2.167/3.349/4.421/0.736 ms

去阿里镜像站里下载对应的rpm包https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/Redhat7 yum源换成centos的YUM 源_第2张图片
下载软件包

[root@wxd src]# wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm
[root@wxd src]# wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
[root@wxd src]# wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-3.4.3-161.el7.centos.noarch.rpm
[root@wxd src]# wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-50.el7.noarch.rpm
[root@wxd src]# wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-updateonboot-1.1.31-50.el7.noarch.rpm
[root@wxd src]# wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
[root@wxd src]# wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-9.el7.noarch.rpm
[root@wxd src]# wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/rpm-4.11.3-35.el7.x86_64.rpm

下载完成
Redhat7 yum源换成centos的YUM 源_第3张图片

三、rpm -ivh yum- 安装相对应的rpm

执行安装命令 :rpm -ivh yum-*
问题
出现问题,发现是python-urlgrabber和rpm版本过低,python-urlgrabber的版本不能低于3.10-8,rpm的版本不能低于4.11.3-22

之前下载的版本分别是 python-urlgrabber-3.10-9.el7.noarch.rpmrpm-4.11.3-35.el7.x86_64.rpm 大于需要版本

直接更新后再安装即可

[root@wxd src]# rpm -Uvh rpm-4.11.3-35.el7.x86_64.rpm --nodeps

Redhat7 yum源换成centos的YUM 源_第4张图片

[root@wxd src]# rpm -Uvh python-urlgrabber-3.10-9.el7.noarch.rpm --nodeps

在这里插入图片描述
执行重新安装 [root@wxd src]# rpm -ivh yum-*
Redhat7 yum源换成centos的YUM 源_第5张图片

查看原有的yum:rpm -qa | grep yumRedhat7 yum源换成centos的YUM 源_第6张图片

四、去阿里镜像站下载 centos-base.repo,并修改

去阿里镜像站下载centos-7.repo

[root@wxd src]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

Redhat7 yum源换成centos的YUM 源_第7张图片
把/etc/yum.repos.d/CentOS-Base.repo内容中的releasever替换成现有系统的版本号’7’

[root@wxd src]# vim /etc/yum.repos.d/CentOS-Base.repo

vim中执行 :%s/$releasever/7/g
Redhat7 yum源换成centos的YUM 源_第8张图片

五、清楚yum缓存,再重新生成缓存

清除缓存 yum clean all
清除缓存
再生成缓存 yum makecache
Redhat7 yum源换成centos的YUM 源_第9张图片

六、测试 使用 yum -y install gcc gcc-c++

测试是否安装完成
Redhat7 yum源换成centos的YUM 源_第10张图片
完成!

你可能感兴趣的:(yum,linux)