RHEL7解決沒法使用YUM源問題node
RHEL的YUM源須要註冊用戶才能更新使用,因爲CentOS和RHEL基本沒有區別,而且CentOS已經被REHL收購。因此將RHEL的YUM源替換爲CentOS便可。
問題以下:
[root@bogon ~]# 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.rpmpython
*註釋:這些軟件包的具體的版本,請到http://mirrors.173.com/centos/7/os/x87_74/Packages/ 目錄下,選擇下載上述軟件包。網上不少文章無法直接使用就是由於軟件包的版本問題。linux
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要一塊兒安裝。vim
若是按照遇到問題:發現錯誤,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 pythoncentos
發現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 vimless
執行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 ,具體以下,
------------------------------------------------------------------------------------------------------------------
第一步下載相關安裝包
能夠經過http://mirrors.163.com/centos下載,
第二步卸載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的版本號便可
爲了防止錯誤,也可以使用我已修改好的文件http://pan.baidu.com/s/1o6AZ23o
文件修改爲以下便可:
# 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
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 makecache 安裝完成,下來就能夠裝調試包了, http://debuginfo.centos.org/6/x86_64/
*****************************************************************************************
設置本地yum倉庫
一、安裝createrepo,yum install createrepo
若沒法使用網絡,請到百度雲下載rpm包
連接:http://pan.baidu.com/s/1jHUBWRO 密碼:8il2
二、在包路徑下執行 createrepo . 以生成repodata文件夾
三、/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