0%

Redhat6不能使用yum安装软件的解决

RHEL的YUM源需要注册用户才能更新使用,由于CentOS和RHEL基本没有区别,并且CentOS已经被REHL收购。所以将RHEL的YUM源替换为CentOS即可。

新安装的redhat使用yum时会出现如下如下:

1
2
3
[root@localhost~]# 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.

解决方法:

执行此脚本即可:(只对于Redhat6测试,具体方法后面)

1
curl -s https://www.hyman.shop/sh/redhat6-yum.sh |bash

清除原有RHEL的YUM及相关软件包。

1
2
[root@localhost~]# rpm -qa | grep yum | xargs rpm -e --nodeps
[root@localhost~]# rpm -qa |grep python-urlgrabber|xargs rpm -e --nodeps

下载centos6的相关软件包。

1
2
3
4
5
[root@localhost~]# wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-81.el6.centos.noarch.rpm
[root@localhost~]# wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
[root@localhost~]# wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm
[root@localhost~]# wget http://mirrors.163.com/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
[root@localhost~]# wget http://mirrors.163.com/centos/6/os/x86_64/Packages/python-urlgrabber-3.9.1-11.el6.noarch.rpm

安装软件包。

1
2
3
4
5
[root@localhost~]# rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm
[root@localhost~]# rpm -ivh python-urlgrabber-3.9.1-11.el6.noarch.rpm
[root@localhost~]# rpm -ivh yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
[root@localhost~]# rpm -ivh yum-plugin-fastestmirror-1.1.30-40.el6.noarch.rpm yum-3.2.29-81.el6.centos.noarch.rpm
*注释yum-plugin-fastestmirror和yum-3.2.29要一起安装。

编辑文件

1
2
3
4
5
6
7
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
[root@localhost~]# vim /etc/yum.repos.d/CentOS-Base.repo

把$releasever替换成现有系统的版cd本号(6)
vim替换命令
:%s/$releasever/6/g
退出保存

清理yum缓存

1
[root@localhost~]# yum clean all

将服务器软件包信息缓存至本地,提高搜索安装效率

1
[root@localhost~]# yum makecache