redhat7.6 更换 centos7 YUM

使用yum 遇到如下错误.

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

因为RedHat yum源是收费的,没有注册的Red Hat是不能使用yum源的。

卸载Red Hat原有的yum,安装centos 7 yum.

# 查看本地yum
rpm -qa|grep yum   

# 清除原有RHEL的YUM及相关软件包。
rpm -qa | grep yum | xargs rpm -e --nodeps
rpm -qa |grep python-urlgrabber|xargs rpm -e --nodeps

 

下载Centos yum 并安装.

# 切换目录
cd /etc/yum.repos.d/

#下载以下四个安装包
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm

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

wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-161.el7.centos.noarch.rpm

wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm

# 先安装python**这个
rpm -ivh python-iniparse-0.4-9.el7.noarch.rpm

# 其它三个一起安装 因为有相互依赖关系
rpm -ivh yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm yum-metadata-parser-1.1.4-10.el7.x86_64.rpm yum-3.4.3-161.el7.centos.noarch.rpm

 

下载配置文件

cd /etc/yum.repos.d/

# 以下源二选一

#网易源
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo 

#中国科技大学源
wget https://lug.ustc.edu.cn/wiki/_export/code/mirrors/help/centos?codeblock=3

 

备份原配置文件:

cd /etc/yum.repos.d/

mv redhat.repo redhat.repo.bak

 更新yum缓存

yum clean all  # 清除yum缓存

yum makecache  #更新yum缓存

此时遇到了一个错误.

 

查了下因为没有设置配置文件. 根据上面下载的源 选择执行语句.

#163源 
sed -i "s;\$releasever;7;g" CentOS7-Base-163.repo

#中科大源 
sed -i "s;\$releasever;7;g" CentOS-Base.repo

设置完成后 重新执行

yum clean all    #清除yum缓存

yum makecache    #更新yum缓存

yum repolist 

看到repolist 显示软件包数量就可以了.

 

完成 Red Hat yum 更换为 Centos yum.

posted @ 2019-08-16 19:08  Aliwall  阅读(4154)  评论(0编辑  收藏  举报