1. 程式人生 > >Red Hat的yum替換為CentOS7的yum(解決:This system is not registered to Red Hat Subscription Management)

Red Hat的yum替換為CentOS7的yum(解決:This system is not registered to Red Hat Subscription Management)

導讀:在使用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

[[email protected] home]# rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm

2、安裝yum

[[email protected] ~]# cd /home

[[email protected] 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

[[email protected] 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 (別忘了先去下載安裝包)

[[email protected] 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

[[email protected] 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

[[email protected] 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) 的要求。

[[email protected] 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
                 ......   自處省略
[[email protected] 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

[[email protected] 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 即可,命令這樣寫:

[[email protected] 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%]

就是把

[[email protected] home]# rpm -ivh yum-3.4.3-161.el7.centos.noarch.rpm 

改為

[[email protected] 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 就可以了

[[email protected] 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

[[email protected] 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。互相依賴了怎麼搞?

這段蛋疼的互相需要
[[email protected] 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 需要

[[email protected] 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 需要

解決辦法:
不怎麼搞,那就一起安裝唄。

[[email protected] 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

[[email protected] 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%]
   
[[email protected] 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

測試

[[email protected] 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的另一個程式正在執行的問題解決