安裝完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