安装完Redhat7以后,使用yum安装软件,提示红帽操作系统未注册。解决方式是将yum源更改为国内yum的镜像库。
1.卸载原本的yum
# rpm -aq|grep yum|xargs rpm -e --nodeps
检查是否卸载完成
# rpm -qa |grep yum
2.下载安装新yum安装包
网易的镜像网站为:http://mirrors.163.com,选择下载Centos7的镜像源,
在以下网址http://mirrors.163.com/centos/7/os/x86_64/Packages/ 下载所需文件,所需的文件为:
rpm-4.11.3-25.el7.x86_64.rpm yum-metadata-parser-1.1.4-10.el7.x86_6 python-urlgrabber-3.10-8.el7.noarch.rpm yum-3.4.3-154.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-42.el7.noarch.rpm
##版本号会更新注意修改!
安装
rpm -ivh rpm-4.11.3-25.el7.x86_64.rpm yum-metadata-parser-1.1.4-10.el7.x86_6 python-urlgrabber-3.10-8.el7.noarch.rpm yum-3.4.3-154.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-42.el7.noarch.rpm
3.下载新的 CentOS-Base.repo 到 /etc/yum.repos.d/
CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
4.修改repo文件
将$releaseserve替换为7,例如
# sed -i 's/$releaseserve/7/g' /etc/yum.repos.d/CentOS-Base.repo
或者
# cd /etc/yum.repos.d/ # vim CentOS-Base.repo :%s/$releasever/7/g
5.生成yum缓存
yum clean all
yum makecache
更新yum
yum update
测试yum源的可用性
yum repolist all
如果发现某个yum源的状态是disabled,则在CentOS7-Base.repo文件中进行更改,将相应模块的enabled参数更改为1
遇到问题
使用yum install xxx 安装文件仍然有如下提示,
[This system is not registered with an entitlement server.You can use subscription-manager to register.]
并且在替换自带的repo源时发现无论是将redhat.repo重命名还是删除,在执行yum命令后总是自动又生成redhat.repo得问题,
导致替换的CentOS-Base.repo,一直无法使用。
原因在redhat自带的插件subscription-manager。
这个插件的作用就是Red Hat Subscription Manager订阅管理器,就是它导致你一直register
解决办法:
在/etc/yum/pluginconf.d/subscription-manager.conf文件下
设置:enabled=0
vim /etc/yum/pluginconf.d/subscription-manager.conf enabled=0 :wq
yum clean all
yum makecache
参考引用:
https://www.cnblogs.com/xinyuyang/p/10486733.html
https://www.cnblogs.com/archer-wen/p/9643927.html
https://developer.aliyun.com/mirror/centos?spm=a2c6h.13651102.0.0.3e221b11Uawrn3
https://www.cnblogs.com/lucky-ss/p/12977108.html