RedHat Linux7.3 使用yum安裝時報錯,改用CentOS yum源

在使用redhat linux的yum來安裝或者更新軟件的時候會有以下提示:node

[root@node1 home]# yum install package_name Loaded plugins: product-id, 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

通過翻譯是沒有通過註冊的,查閱資料發現redhat的yum在線更新是收費的,若是沒有註冊的話不能使用,若是要使用,需將redhat的yum卸載後,重啓安裝,再配置其餘源python

解決辦法:linux

  • 首先到http://mirrors.163.com/centos下載軟件包,本次爲最新版本 x86_64 地址:http://mirrors.163.com/centos/7.3.1611/os/x86_64/Packages/ 必要下載的軟件包有(以64位系統爲例):
  • 1.1.python-iniparse-0.4-9.el7.noarch.rpm
  • 1.2.python-urlgrabber-3.10-8.el7.noarch.rpm
  • 1.3.yum-3.4.3-150.el7.centos.noarch.rpm
  • 1.4.yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
  • 1.5.yum-plugin-fastestmirror-1.1.31-40.el7.noarch.rpm

下載命令:centos

wget http://mirrors.163.com/centos/7.3.1611/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
wget http://mirrors.163.com/centos/7.3.1611/os/x86_64/Packages/python-urlgrabber-3.10-8.el7.noarch.rpm
wget http://mirrors.163.com/centos/7.3.1611/os/x86_64/Packages/yum-3.4.3-150.el7.centos.noarch.rpm
wget http://mirrors.163.com/centos/7.3.1611/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7.3.1611/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-40.el7.noarch.rpm緩存

 卸載RedHat自帶的yum less

1>   xargs是一條Unix和類Unix操做系統的經常使用命令。它的做用是將參數列表轉換成小塊分段傳遞給其餘命令,以免參數列表過長的問題 測試

2>   –nodeps  強制卸載,無論依賴性this

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

 卸載RedHat自帶的兩個python:url

rpm -qa | grep python-iniparse| xargs rpm -e --nodepsspa

 rpm -qa | grep python-urlgrabber| xargs rpm -e --nodeps

安裝下載的centos的yum包:

最後2個須要一塊兒安裝,不然會出現依賴性錯誤

rpm -ivh python-iniparse-0.4-9.el7.noarch.rpm
rpm -ivh python-urlgrabber-3.10-8.el7.noarch.rpm rpm -ivh yum-3.4.3-150.el7.centos.noarch.rpm rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm rpm -ivh yum-plugin-fastestmirror-1.1.31-34.el7.noarch.rpm

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

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

編輯CentOS7-Base-163.repo文件,將其中的$releasever更改成centos的版本號 下面是修改好的,centos的版本號爲7,可根據http://mirrors.163.com/centos/$releasever
/os/x86_64/repodata/repomd.xml來測試版本號應該是什麼,經測試http://mirrors.163.com/centos/7
/os/x86_64/repodata/repomd.xml
是能夠的,而換成7.二、7.3都是不成功的

CentOS7-Base-163.repo  源文件:

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

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

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

gpgcheck=1

gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

 

#released updates

[updates]

name=CentOS-$releasever - Updates - 163.com

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

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

gpgcheck=1

gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

 

#additional packages that may be useful

[extras]

name=CentOS-$releasever - Extras - 163.com

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

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

gpgcheck=1

gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

 

#additional packages that extend functionality of existing packages

[centosplus]

name=CentOS-$releasever - Plus - 163.com

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

gpgcheck=1

CentOS7-Base-163.repo  修改後的文件:

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

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

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

gpgcheck=1

gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

 

#released updates

[updates]

name=CentOS-7 - Updates - 163.com

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

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

gpgcheck=1

gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

 

#additional packages that may be useful

[extras]

name=CentOS-7 - Extras - 163.com

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

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

gpgcheck=1

gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

 

#additional packages that extend functionality of existing packages

[centosplus]

name=CentOS-7 - Plus - 163.com

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

gpgcheck=1

最後,使用yum命令清除緩存、更新所有安裝包: 

yum clean all 清除原有緩存

yum makecache  獲取yum列表 出現下面提示,表示yum更改完成: Metadata Cache Created/元數據緩存已創建

yum update 更新所有安裝包,看需求,無關緊要。

參考文檔:http://blog.csdn.net/zhngjan/article/details/20843465 對該博客中的一些目前丟失包報404等問題進行了更改,本博客親測有效。 若有問題,請在評論中指出,共同進步,謝謝!!!

相關文章
相關標籤/搜索