新安裝了redhat7.4安裝后,登錄系統,使用yum update 更新系統。提示:
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
無法更新。
redhat 默認自帶的 yum 源需要注冊,才能更新。我們想不花錢也可以更新,需要替換掉redhat的yum源。
1.檢查是否安裝yum包
查看RHEL是否安裝了yum,若是安裝了,那么又有哪些yum包:
[root@bogon ~]# rpm -qa |grep yum yum-3.4.3-154.el7.noarch yum-rhn-plugin-2.0.1-9.el7.noarch yum-metadata-parser-1.1.4-10.el7.x86_64
2 刪除redhat自帶的yum包
卸載上面顯示的所有yum包:
[root@bogon ~]# rpm -qa |grep yum | xargs rpm -e --nodeps
再檢查
[root@bogon ~]# rpm -qa |grep yum
查看,無信息顯示表示已經卸載完成。
3.下載新的yum包。使用Centos7的yum包
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-3.4.3-158.el7.centos.noarch.rpm wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-45.el7.noarch.rpm wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-8.el7.noarch.rpm wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/wget-1.14-15.el7_4.1.x86_64.rpm
安裝yum軟件包
注意:單個的安裝包可能會依賴其它包(例如yum和yum-fastestmirror會相互依賴),所以我們可以把所有這些包放在一起,用一行命令將它們同時安裝即可:
rpm -ivh python-urlgrabber-3.10-8.el7.noarch.rpm --replacefiles rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm yum-3.4.3-158.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm
4.更換yum源。使用本地源
[root@bogon ~]# cat /etc/yum.repos.d/client.repo [bash] name=centos7 baseurl=http://192.168.238.128:81 enabled=1 gpgcheck=0 gpgkey=http://192.168.238.128:81/RPM-GPG-KEY-CentOS-7
第四步:運行yum makecache生成緩存
yum clean all
yum makecache
yum安裝軟件,報錯
** Found 1 pre-existing rpmdb problem(s), 'yum check' output follows: rhn-check-2.0.2-17.el7.noarch has missing requires of yum-rhn-plugin >= ('0', '1.6.4', '1')
解決辦法
首先安裝 yum-utils 套件
yum install yum-utils
執行 clean duplicate package