573 views
linux-报错信息

解决Redhat自带yum源注册问题

Redhat默认自带的yum源需要注册,才能更新,报错信息如下:

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

注:需要提前看一下自己linu系统版本,本文中系统版本为Redhat 7 通过这个命令可以查看版本cat /etc/redhat-release

具体步骤如下:

1、检查目前本机安装了哪些yum包

[code]

rpm -qa |grep yum

[/code]

2、删除对应自带的yum包

[code]

#(–nodeps不检查依赖,直接删除rpm包)

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

[/code]

这里还需要卸载一个依赖包

[code]

rpm -qa |grep python-urlgrabb|xargs rpm -e –nodeps

[/code]

3、下载对应的rpm包,推荐地址http://mirrors.kernel.org/centos/7/os/x86_64/Packages/

4、需要下载的包

[code]

wget http://mirrors.kernel.org/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm

wget http://mirrors.kernel.org/centos/7/os/x86_64/Packages/yum-3.4.3-154.el7.centos.noarch.rpm

wget http://mirrors.kernel.org/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-8.el7.noarch.rpm

wget http://mirrors.kernel.org/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-42.el7.noarch.rpm

wget http://mirrors.kernel.org/centos/7/os/x86_64/Packages/yum-rhn-plugin-2.0.1-9.el7.noarch.rpm

[/code]

5、安装(注意安装顺序不能错)

[code]

rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm

rpm -ivh –force –nodeps yum-3.4.3-154.el7.centos.noarch.rpm python-urlgrabber-3.10-8.el7.noarch.rpm yum-plugin-fastestmirror-1.1.31-42.el7.noarch.rpm

[/code]

6、删除原来的repo源

[code]

rm -rf /etc/yum.repos.d/*

[/code]

7、建立新的源

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

[code]

#内容如下

[base]

name=CentOS-7 – Base – 163.com

#mirrorlist=http://mirrorlist.centos.org/?release=7&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=7&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=7&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 extendfunctionality of existing packages

[centosplus]

name=CentOS-7 – Plus – 163.com

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

gpgcheck=1

enabled=0

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

[/code]

8、最后清一下缓存

[code]

yum clean all

yum makecache fast

[/code]

9、在第5步的时候,需要依赖rpm对应版本的安装包,考虑到如果卸载了rpm就没法安装了,所以用了–force –nodeps来强制安装,所以最后最好把rpm更新一下

[code]yum update -y rpm*[/code]

Leave a Reply