1. 程式人生 > >RHEL7刪除註冊提示並使用YUM源的解決方法

RHEL7刪除註冊提示並使用YUM源的解決方法

RHEL的YUM源需要註冊使用者才能更新使用,由於CentOS和RHEL基本沒有區別,並且CentOS已經被REHL收購。所以將RHEL的YUM源替換為CentOS即可。

問題如下:
[[email protected] ~]# yum repolist
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
repolist: 0
或者# yum install ntp
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Setting up Install Process
Nothing to do
解決方法:
1.清除原有RHEL的YUM及相關軟體包。
rpm -qa | grep yum | xargs rpm -e --nodeps
rpm -qa |grep python-urlgrabber|xargs rpm -e --nodeps
2.下載centos7的相關軟體包。
http://mirrors.173.com/centos/7.3.1711/os/x87_74/Packages/yum-3.4.3-150.el7.centos.noarch.rpm
http://mirrors.173.com/centos/7.3.1711/os/x87_74/Packages/yum-metadata-parser-1.1.4-10.el7.x87_74.rpm
http://mirrors.173.com/centos/7.3.1711/os/x87_74/Packages/yum-plugin-fastestmirror-1.1.31-40.el7.noarch.rpm
http://mirrors.173.com/centos/7.3.1711/os/x87_74/Packages/python-iniparse-0.4-9.el7.noarch.rpm
http://mirrors.173.com/centos/7.3.1711/os/x87_74/Packages/python-urlgrabber-3.10-8.el7.noarch.rpm

*註釋:這些軟體包的具體的版本,請到http://mirrors.173.com/centos/7/os/x87_74/Packages/ 目錄下,選擇下載上述軟體包。網上很多文章沒法直接使用就是因為軟體包的版本問題。

3.安裝軟體包。
rpm -ivh python-iniparse-0.3.1-2.1.el7.noarch.rpm
rpm -ivh python-urlgrabber-3.9.1-11.el7.noarch.rpm
rpm -ivh yum-metadata-parser-1.1.2-17.el7.x87_74.rpm
rpm -ivh yum-plugin-fastestmirror-1.1.30-37.el7.noarch.rpm yum-3.2.29-73.el7.centos.noarch.rpm
*註釋yum-plugin-fastestmirror和yum-3.2.29要一起安裝。

如果按照遇到問題:發現錯誤,python-urlgrabber版本必須大於等於3.9.1-10
 # rpm -ivh  yum-3.2.29-73.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-37.el7.noarch.rpm
warning: yum-3.2.29-73.el7.centos.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
error: Failed dependencies:
    python-urlgrabber >= 3.9.1-10 is needed by yum-3.2.29-73.el7.centos.noarch
檢視系統的python資訊
# rpm -qa|grep python

發現python-urlgrabber-3.9.1-9.el7.noarch 版本低於3.9.1-10 
解除安裝:python-urlgrabber-3.9.1-9.el7.noarch
 rpm -e python-urlgrabber-3.9.1-9.el7.noarch
安裝:rpm -ivh python-urlgrabber-3.9.1-11.el7.noarch.rpm

安裝yum
# rpm -ivh yum-*
更改yum源
cd /etc/yum.repos.d/
下載配置檔案
wget http://mirrors.173.com/.help/CentOS7-Base-173.repo
將此配置檔案替換/etc/yum.repos.d同名檔案
sed -i "s;\releasever;7;g" CentOS7-Base-173.repo mv rhel-source.repo rhel-source.repo.bak  或者編輯配置檔案   #vim CentOS-Base.repo  把releasever;7;g" CentOS7-Base-173.repo mv rhel-source.repo rhel-source.repo.bak  或者編輯配置檔案   #vim CentOS-Base.repo  把releasever替換成現有系統的版本號(7)
vim替換命令
:%s/$releasever/7/g
退出儲存

清理yum快取
#yum clean all
將伺服器軟體包資訊快取至本地,提高搜尋安裝效率
#yum makecache

測試
#yum seach vim

執行yum repolist檢視,如果顯示出repo倉庫列表,並顯示軟體包數量則OK。(或者使用yum makecache)


7.使用yum安裝軟體包測試。
yum -y install lrzsz

至此,如果不出現意外,lrzsz軟體包安裝成功。yum也就可以正常使用了。

解決辦法一(未驗證刪除RHEL 6.7 的RHN註冊和訂閱提示

------------------------------------------------------------------------------------

     系統: RHEL 6.7 x64

    桌面: Gnome 

1. 查詢RHN註冊和訂閱的程式元件。          

    (1) 查詢subscription-manager相關元件:                 

      執行命令: rpm -qa|grep subscription-manager                 

       subscription-manager-gui-1.14.10-1.el6.x86_64
                  subscription-manager-1.14.10-1.el6.x86_64
                  subscription-manager-migration-1.14.10-1.el6.x86_64
                  subscription-manager-migration-data-2.0.22-1.el6.noarch
                  subscription-manager-firstboot-1.14.10-1.el6.x86_64       

    (2) 查詢rhn相關元件:                 

      執行命令: rpm -qa|grep rhn                 

       rhnsd-4.9.3-2.el6.x86_64
                  rhn-check-1.0.0.1-32.el6.noarch
                  rhn-setup-gnome-1.0.0.1-32.el6.noarch
                  rhn-setup-1.0.0.1-32.el6.noarch
                  rhn-client-tools-1.0.0.1-32.el6.noarch
                  rhnlib-2.5.22-15.el6.noarch
                  yum-rhn-plugin-0.9.1-58.el6.noarch

2. 刪除subscription-manager和rhn的相關程式元件。    

         (1) 執行命令: yum remove subscription-manager                   

        正在刪除   : subscription-manager-firstboot-1.14.10-1.el6.x86_64              1/4 
                   正在刪除   : subscription-manager-migration-1.14.10-1.el6.x86_64           2/4 
                   正在刪除   : subscription-manager-gui-1.14.10-1.el6.x86_64                      3/4 
                   正在刪除   : subscription-manager-1.14.10-1.el6.x86_64                             4/4              

   (2) 執行命令: yum remove rhn-check                   

       正在刪除   : rhn-setup-gnome-1.0.0.1-32.el6.noarch                        1/5 
                   正在刪除   : rhn-check-1.0.0.1-32.el6.noarch                                     2/5 
                   正在刪除   : yum-rhn-plugin-0.9.1-58.el6.noarch                               3/5 
                   正在刪除   : rhn-setup-1.0.0.1-32.el6.noarch                                      4/5 
                   正在刪除   : rhnsd-4.9.3-2.el6.x86_64                                                  5/5 

這裡不用rpm -e來刪除程式是因為在執行刪除任務的過程中會出現由於程式的相互依賴關係而無法刪除的錯誤。

因此,用yum remove來執行刪除任務,它會自動分析程式的相互依賴關係並刪除。

      刪除完後,直接用yum源安裝!!!(未驗證!)      有時間試一下看起作用不,,,,這幾天太忙,等週六週日再看!

-----------------------------------------------------------------------------------------------------------------------------

方法二:解除安裝yum ,安裝CentOS的rpm包,安裝yum.  重新整理yum快取,yum makecache ,具體如下,

------------------------------------------------------------------------------------------------------------------

第一步下載相關安裝包

第二步解除安裝Redhat自帶的yum

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

第三步安裝下載的安裝包

#rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm

#rpm -ivh yum-metadata-parser-1.1.2-16.el6.x86_64.rpm

#rpm -ivh yum-3.2.29-40.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm

第四步到http://mirrors.163.com的 centos幫助文件 
中下載CentOS6-Base-163.repo檔案,存放到/etc/yum.repos.d中

#wget http://mirrors.163.com/.help/CentOS6-Base-163.repo

第五步將Centos6-Base-163.repo中的$releasever改為Centos的版本號即可

檔案修改成如下即可:

# 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-6 - Base - 163.com

baseurl=http://mirrors.163.com/centos/6/os/$basearch/

#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=os

gpgcheck=1

gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#released updates

[updates]

name=CentOS-6 - Updates - 163.com

baseurl=http://mirrors.163.com/centos/6/updates/$basearch/

#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=updates

gpgcheck=1

gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#additional packages that may be useful

[extras]

name=CentOS-6 - Extras - 163.com

baseurl=http://mirrors.163.com/centos/6/extras/$basearch/

#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=extras

gpgcheck=1

gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality of existing packages

[centosplus]

name=CentOS-6 - Plus - 163.com

baseurl=http://mirrors.163.com/centos/6/centosplus/$basearch/

#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=centosplus

gpgcheck=1

enabled=0

gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#contrib - packages by Centos Users

[contrib]

name=CentOS-6 - Contrib - 163.com

baseurl=http://mirrors.163.com/centos/6/contrib/$basearch/

#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=contrib

gpgcheck=1

enabled=0

gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

第六步 yum clean all 清除原有快取

第七步 yum makecache  獲取yum列表

等待,大約三分鐘後出現下面提示,表示yum更改完成:

Metadata Cache Created

 ----------------------------------------------------------------------------------------

其實也不用這麼麻煩,

1.解除安裝redhat自帶的yum元件      rpm -qa|grep yum|xargs rpm -e --nodeps

2.安裝centos的yum包, 先瀏覽網頁看版本號,再wget 對應的版本,(因為RHEL和CentOS 的關係,包都是一樣的 ),  網頁:http://centos.ustc.edu.cn/centos/ 下  對應版本  下,根據機器32位還是64位 裝包

http://centos.ustc.edu.cn/centos/6/os/x86_64/Packages/

# wget http://centos.ustc.edu.cn/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm

# wget  http://centos.ustc.edu.cn/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-37.el6.noarch.rpm

# wget  http://centos.ustc.edu.cn/centos/6/os/x86_64/Packages/yum-3.2.29-73.el6.centos.noarch.rpm

3. 下載更新源,並存放在系統目錄中 

wget http://docs.linuxtone.org/soft/lemp/CentOS-Base.repo     http://docs.linuxtone.org這個網站裡邊存放了許多有用的資料,有機會可以看看

mv CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo

4. 更新yum 資源庫

yum clean all

*****************************************************************************************

設定本地yum倉庫

1、安裝createrepo,yum install createrepo

    若無法使用網路,請到百度雲下載rpm包

連結:http://pan.baidu.com/s/1jHUBWRO 密碼:8il2

2、在包路徑下執行 createrepo . 以生成repodata資料夾

3、/etc/yum.repos.d/ 建立 name.repo

[update]
NAME=update
baseurl=file:///root/package/update
enabled=1
gpgcheck=0

註釋其他repo檔案,或拷貝到tmp目錄

yum clean all

yum list