RHEL7删除注册提示并使用YUM源的解决方法

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.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 ,具体如下,

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

第一步下载相关安装包

可以通过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

 

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 makecache   安装完成,下来就可以装调试包了, http://debuginfo.centos.org/6/x86_64/

 

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

设置本地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

你可能感兴趣的:(linux,RHEL)