前言:
RHEL的YUM源需要注册用户才能更新使用,由于CentOS和RHEL基本没有区别,并且CentOS已经被REHL收购。所以将RHEL的YUM源替换为CentOS即可。
问题如下:
[root@localhost ~]# yum repolist
已加载插件:product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
repolist: 0
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# yum install ntp
已加载插件:product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
There are no enabled repos.
Run "yum repolist all" to see the repos you have.
To enable Red Hat Subscription Management repositories:
subscription-manager repos --enable <repo>
To enable custom repositories:
yum-config-manager --enable <repo>
解决方法:
1、清除原有RHEL的YUM及相关软件包:
rpm -qa|grep yum|xargs rpm -e --nodeps
rpm -qa|grep python-urlgrabber|xargs rpm -e --nodeps
2、下载centos7的相关软件包:
网盘地址:链接:https://pan.baidu.com/s/1Z3hm1LErfI6DYxYAUa3o0Q
提取码:ye4x
http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-158.el7.centos.noarch.rpm
http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm
http://mirrors.163.com/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
http://mirrors.163.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-8.el7.noarch.rpm
3、上传软件包到linux:
4、安装软件包:
*注:yum-plugin-fastestmirror和yum两个rpm要一起安装,不能拆开。
rpm -ivh python-iniparse-0.4-9.el7.noarch.rpm
rpm -ivh python-urlgrabber-3.10-8.el7.noarch.rpm
rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
rpm -ivh yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm yum-3.4.3-158.el7.centos.noarch.rpm
5、下载配置文件http://mirrors.163.com/.help/CentOS7-Base-163.repo:
把文件中所有$releasever改为当前redhat的版本,本机版本是7.6.1810,就改为7.6.1810,带“#”的是注释,可以不改
将此配置文件上传并复制到/etc/yum.repos.d/路径下:
使用cat /etc/issue 或cat /etc/redhat-release(Linux查看版本当前操作系统发行版信息)
6、删除/var/cache/yum/下的x86_64目录:
7、清理yum缓存:
yum clean all
8、将服务器软件包信息缓存至本地,提高搜索安装效率:
yum makecache
9、测试:
能搜索到软件包信息,说明配置完成:
yum search vim
10、执行yum repolist查看,如果显示出repo仓库列表,并显示软件包数量则OK。(或者使用yum makecache):
yum repolist
11、使用yum安装软件包测试:
yum -y install vim
到此大功告成。