Redhat7 yum 無法使用
錯誤信息
[root@micocube ~]# yum install gcc-c++ Loaded plugins: 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>
查看redhat 7.0系統本身所安裝的那些yum軟件包
[root@micocube ~]# rpm -qa | grep yum yum-rhn-plugin-2.0.1-10.el7.noarch yum-metadata-parser-1.1.4-10.el7.x86_64 yum-3.4.3-158.el7.noarch
卸載這些軟件包
[root@micocube ~]# rpm -e yum-rhn-plugin-2.0.1-10.el7.noarch --nodeps [root@micocube ~]# rpm -e yum-metadata-parser-1.1.4-10.el7.x86_64 --nodeps [root@micocube ~]# rpm -e yum-3.4.3-158.el7.noarch --nodeps
下載centos的yum 相關 rpm包,包下載地址,版本請從包下載地址獲取最新的,可以用wget下載
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-kitchen-1.1.1-5.el7.noarch.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-chardet-2.2.1-3.el7.noarch.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-167.el7.centos.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-utils-1.1.31-53.el7.noarch.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-updateonboot-1.1.31-53.el7.noarch.rpm wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-53.el7.noarch.rpm
安裝軟件包
rpm -ivh python-* rpm -ivh yum-*
切換到/etc/yum.repos.d/目錄
從這里下載repo文件到/etc/yum.repos.d/目錄。比如
wget http://mirrors.aliyun.com/repo/Centos-7.repo
清除緩存
yum clean all
可以用yum search vim測試
訂閱插件提示:This system is not registered with an entitlement server. You can use subscription-manager to register.
這個Red Hat Subscription Manager訂閱管理器,它會讓你一直register,解決辦法:禁用就好
-
腳本文件: /usr/lib/yum-plugins/subscription-manager.py
-
配置文件: /etc/yum/pluginconf.d/subscription-manager.conf
-
調用了腳本 /usr/share/rhsm/repolib.py
-
去重寫或者更新/etc/yum.repos.d/redhat.repo文件。
每次yum調用(不禁掉plugins的情況下),都會更新此文件。
因此,為了不沖突,可以如下操作:停止掉該插件的使用,在配置文件中把enable=0即可。
[root@micocube ~] vim /etc/yum/pluginconf.d/subscription-manager.conf [main] enabled=0 #將它禁用掉
當進行運行安裝命令時可能會報錯
[root@localhost yum.repos.d]# yum install glibc.i686 已加載插件:fastestmirror, product-id, search-disabled-repos Determining fastest mirrors * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com http://mirrors.aliyun.com/centos/%24releasever/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found 正在嘗試其它鏡像。 To address this issue please refer to the below wiki article https://wiki.centos.org/yum-errors If above article doesn't help to resolve this issue please use https://bugs.centos.org/. http://mirrors.aliyuncs.com/centos/%24releasever/os/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; 拒絕連接"
這是因為下載的阿里雲的yum源文件里Centos-7.repo文件中$releasever這個變量在Centos-7.repo文件中沒有被識別出來。
可以去aliyun的鏡像官網上查看下正確地址:https://mirrors.aliyun.com/centos/7/os/x86_64/repodata/repomd.xml
解決辦法:將$releasever換成7
[root@localhost yum.repos.d]# sed -i 's/$releasever/7/g' Centos-7.repo
再次清除緩存
yum clean all
再次可以用yum search vim測試