1. 首页 > 知识 > Linux

Linux(Redhat 7.0) yum无法使用和subscription-manager提示

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测试


本文由傻鸟发布,不代表傻鸟立场,转载联系作者并注明出处:https://www.shaniao.net/linux/101.html

加载中~

联系我们

在线咨询:点击这里给我发消息

微信号:

工作日:10:30-15:30,节假日休息