Red Hat的yum替换为CentOS7的yum(解决:This system is not registered to Red Hat Subscription Management)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/ztx114/article/details/85149629

导读:在使用redhat7的yum命令安装软件时,发现总是提示This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. 或如下错误信息:This system is not registered with RHN. RHN support will be disabled.原来RHEL7的yum服务是付费的,因为没有付费,所以无法使用yum安装软件,只能替换为CentOs的yum工具,下面是具体操作步骤。

今天按照某博客安装Red Hat虚拟机,结果发现yum根本不能用,于是想用CentOS7的yum替换,结果踩了无数坑,填完坑之后最终做个总结。废话不多说直接上教程。

一、卸载原来的yum

– 查看yum

rpm -qa |grep yum 

–卸载yum

rpm -qa | grep yum | xargs rpm -e --nodeps 

二、下载并安装CentOS7的yum以及依赖

因为我新安装的虚拟机没有wget所以相关安装都是在以下网站下载
这个地址很重要 http://mirrors.163.com/centos/7/os/x86_64/Packages/ 在这里面下载相关的依赖
在这里插入图片描述
我用到了以下这些这些:每个人的环境不一样因此需要的依赖可能会有差别但是上图红箭头指向的是必需的
在这里插入图片描述

安装

声明:我的安装包放在home文件夹下面
首先我先安装的 yum-3.4.3-161.el7.centos.noarch.rpm 如下:

1、安装yum-metadata-parser

[root@localhost home]# rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm

2、安装yum

[root@localhost ~]# cd /home

[root@localhost home]# ls

yum-3.4.3-161.el7.centos.noarch.rpm  yum-metadata-parser-1.1.4-10.el7.x86_64.rpm  yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm  yum-updateonboot-1.1.31-50.el7.noarch.rpm  yum-utils-1.1.31-50.el7.noarch.rpm

[root@localhost home]# rpm -ivh yum-3.4.3-161.el7.centos.noarch.rpm 

警告:yum-3.4.3-161.el7.centos.noarch.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
错误:依赖检测失败:
        python-urlgrabber >= 3.10-8 被 yum-3.4.3-161.el7.centos.noarch 需要
        rpm >= 0:4.11.3-22 被 yum-3.4.3-161.el7.centos.noarch 需要
        yum-plugin-fastestmirror 被 yum-3.4.3-161.el7.centos.noarch 需要

如上面所打印的错误信息,安装 yum-3.4.3-161.el7.centos.noarch.rpm 必须先安装 python-urlgrabber (版本>=3.10-8) | rpm(版本>=4.11.3-22) | yum-plugin-fastestmirror(对版本无要求) 这三个。

3、安装python-urlgrabber

那么我们就按照提示来做吧,现在安装 python-urlgrabber-3.10-9.el7.noarch.rpm (别忘了先去下载安装包)

[root@localhost home]# rpm -ivh python-urlgrabber-3.10-9.el7.noarch.rpm 

警告:python-urlgrabber-3.10-9.el7.noarch.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:python-urlgrabber-3.10-9.el7     ################################# [100%]

现在我们再安装 yum-3.4.3-161.el7.centos.noarch.rpm

[root@localhost home]# rpm -ivh yum-3.4.3-161.el7.centos.noarch.rpm    
 
警告:yum-3.4.3-161.el7.centos.noarch.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
错误:依赖检测失败:
        rpm >= 0:4.11.3-22 被 yum-3.4.3-161.el7.centos.noarch 需要
        yum-plugin-fastestmirror 被 yum-3.4.3-161.el7.centos.noarch 需要

发现 python-urlgrabber 已经安装成功,不再报需要 python-urlgrabber

4、安装rpm(版本>=4.11.3-22)

首先我们现有的 rpm

[root@localhost home]# rpm -qa | grep rpm

rpm-libs-4.11.1-16.el7.x86_64
rpm-python-4.11.1-16.el7.x86_64
rpm-4.11.1-16.el7.x86_64
rpm-build-libs-4.11.1-16.el7.x86_64

发现 rpm 已经有了 rpm-4.11.1-16.el7.x86_64 版本,但是不满足 rpm(版本>=4.11.3-22) 的要求。

[root@localhost home]# rpm -ivh rpm-4.11.3-35.el7.x86_64.rpm 

警告:rpm-4.11.3-35.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
准备中...                          ################################# [100%]
        file /bin/rpm from install of rpm-4.11.3-35.el7.x86_64 conflicts with file from package rpm-4.11.1-16.el7.x86_64
        file /usr/bin/rpm2cpio from install of rpm-4.11.3-35.el7.x86_64 conflicts with file from package rpm-4.11.1-16.el7.x86_64
        file /usr/bin/rpmdb from install of rpm-4.11.3-35.el7.x86_64 conflicts with file from package rpm-4.11.1-16.el7.x86_64
        file /usr/bin/rpmkeys from install of rpm-4.11.3-35.el7.x86_64 conflicts with file from package rpm-4.11.1-16.el7.x86_64
        file /usr/lib/rpm/macros from install of rpm-4.11.3-35.el7.x86_64 conflicts with file from package rpm-4.11.1-16.el7.x86_64
        file /usr/lib/rpm/platform/aarch64-linux/macros from install of rpm-4.11.3-35.el7.x86_64 conflicts with file from package rpm-4.11.1-16.el7.x86_64
                 ......   自处省略
[root@localhost home]# rpm -ivh yum-3.4.3-161.el7.centos.noarch.rpm 

警告:yum-3.4.3-161.el7.centos.noarch.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
错误:依赖检测失败:
        rpm >= 0:4.11.3-22 被 yum-3.4.3-161.el7.centos.noarch 需要
        yum-plugin-fastestmirror 被 yum-3.4.3-161.el7.centos.noarch 需要

现在我们再安装 yum-3.4.3-161.el7.centos.noarch.rpm

[root@localhost home]# rpm -ivh yum-3.4.3-161.el7.centos.noarch.rpm    
 
警告:yum-3.4.3-161.el7.centos.noarch.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
错误:依赖检测失败:
        rpm >= 0:4.11.3-22 被 yum-3.4.3-161.el7.centos.noarch 需要
        yum-plugin-fastestmirror 被 yum-3.4.3-161.el7.centos.noarch 需要

第一个坑:发现还是报 rpm >= 0:4.11.3-22 被 yum-3.4.3-161.el7.centos.noarch 需要
搜了一些资料发现是我们的命令写错了:
之前我们已经有了 rpm-4.11.1-16.el7.x86_64 版本,所以我们要升级 rpm 即可,命令这样写:

[root@localhost home]# rpm -Uvh rpm-4.11.3-35.el7.x86_64.rpm --nodeps 

警告:rpm-4.11.3-35.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:rpm-4.11.3-35.el7                ################################# [ 50%]
正在清理/删除...
   2:rpm-4.11.1-16.el7                ################################# [100%]

就是把

[root@localhost home]# rpm -ivh yum-3.4.3-161.el7.centos.noarch.rpm 

改为

[root@localhost home]# rpm -Uvh rpm-4.11.3-35.el7.x86_64.rpm --nodeps

现在我们再安装 yum-3.4.3-161.el7.centos.noarch.rpm 发现只需要安装 yum-plugin-fastestmirror 就可以了

[root@localhost home]# rpm -ivh yum-3.4.3-161.el7.centos.noarch.rpm   
      
警告:yum-3.4.3-161.el7.centos.noarch.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
错误:依赖检测失败:
        yum-plugin-fastestmirror 被 yum-3.4.3-161.el7.centos.noarch 需要

5、安装yum-plugin-fastestmirror

[root@localhost home]# rpm -ivh yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm 

警告:yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
错误:依赖检测失败:
        yum >= 3.0 被 yum-plugin-fastestmirror-1.1.31-50.el7.noarch 需要

第二个坑:蛋疼的事情出现了安装 yum-plugin-fastestmirror 依赖 yum(版本>=3.0),安装yum-3.4.3-161又依赖yum-plugin-fastestmirror。互相依赖了怎么搞?

这段蛋疼的互相需要
[root@localhost home]# rpm -ivh yum-3.4.3-161.el7.centos.noarch.rpm
警告:yum-3.4.3-161.el7.centos.noarch.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
错误:依赖检测失败:
yum-plugin-fastestmirror 被 yum-3.4.3-161.el7.centos.noarch 需要

[root@localhost home]# rpm -ivh yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm
警告:yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm: 头V3 RSA/SHA256
Signature, 密钥 ID f4a80eb5: NOKEY 错误:依赖检测失败:
yum >= 3.0 被 yum-plugin-fastestmirror-1.1.31-50.el7.noarch 需要

解决办法:
不怎么搞,那就一起安装呗。

[root@localhost home]# rpm -ivh yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm  yum-3.4.3-161.el7.centos.noarch.rpm 

警告:yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:yum-3.4.3-161.el7.centos         ################################# [ 50%]
   2:yum-plugin-fastestmirror-1.1.31-5################################# [100%]

搞定了。

6、安装yum-updateonboot和yum-utils

[root@localhost home]# rpm -ivh yum-updateonboot-1.1.31-50.el7.noarch.rpm 

警告:yum-updateonboot-1.1.31-50.el7.noarch.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:yum-updateonboot-1.1.31-50.el7   ################################# [100%]
   
[root@localhost home]# rpm -ivh yum-utils-1.1.31-50.el7.noarch.rpm 

警告:yum-utils-1.1.31-50.el7.noarch.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
准备中...                          ################################# [100%]

三、配置yum源

在阿里云开源软件镜像站点下载资源文件 http://mirrors.aliyun.com/repo/Centos-7.repo添加链接描述
把下载的文件放在 /etc/yum.repos.d/ 文件夹下面并重命名为 CentOS-Base.repo
编辑 CentOS-Base.repo
在这里插入图片描述
把文件中所有的 $releasever替换为 7。注意,是所有的 $releasever 替换为7

运行以下命令生成缓存

yum clean all
yum makecache

若出现:

/var/run/yum.pid 已被锁定,PID 为 2703 的另一个程序正在运行。
Another app is currently holding the yum lock; waiting for it to exit...
  另一个应用程序是:yum
    内存: 28 M RSS (980 MB VSZ)
    已启动: Fri Dec 21 06:11:05 2018 - 07:18之前
    状态  :跟踪/停止,进程ID:2703
Another app is currently holding the yum lock; waiting for it to exit...

则执行一次:

rm -f /var/run/yum.pid

测试

[root@localhost home]# yum install net-tools 
已加载插件:fastestmirror, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 net-tools.x86_64.0.2.0-0.24.20131004git.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

=========================================================================================================================================================================================================================================
 Package                                               架构                                               版本                                                                    源                                                大小
=========================================================================================================================================================================================================================================
正在安装:
 net-tools                                             x86_64                                             2.0-0.24.20131004git.el7                                                base                                             306 k

事务概要
=========================================================================================================================================================================================================================================
安装  1 软件包

总下载量:306 k
安装大小:918 k

成功。

写这么多主要是想记录这次踩得坑,也希望你看到这些坑能举一反三解决问题。

四、参考:

1、redhat7 yum安装软件时提示This system is not registered with RHN. 解决方案

2、解决:This system is not registered to Red Hat Subscription Management

3、解决Yum安装依赖问题

4、安装yum: rpm >= 0:4.11.3-22 被 yum-3.4.3-154.el7.centos.noarch

5、centos7安装yum python-urlgrabber-3.10-8.el7.noarch依赖问题

6、运行yum时出现/var/run/yum.pid已被锁定,PID为xxxx的另一个程序正在运行的问题解决

猜你喜欢

转载自blog.csdn.net/ztx114/article/details/85149629