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

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
To enable custom repositories:
yum-config-manager --enable

查看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下载
python-kitchen-1.1.1-5.el7.noarch.rpm
python-chardet-2.2.1-1.el7_1.noarch.rpm
yum-3.4.3-161.el7.centos.noarch.rpm
yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
yum-utils-1.1.31-50.el7.noarch.rpm
yum-updateonboot-1.1.31-50.el7.noarch.rpm
yum-plugin-fastestmirror-1.1.31-50.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测试

这个Red Hat Subscription Manager订阅管理器,它会让你一直register,解决办法:禁用就好
因此,为了不冲突,可以如下操作:停止掉该插件的使用,在配置文件中把enable=0即可。
[root@micocube ~] vim /etc/yum/pluginconf.d/subscription-manager.conf
[main]
enabled=0 #将它禁用掉

但是我在执行yum makecache时报错,报错信息如下:

Loaded plugins: fastestmirror, langpacks, priorities
Repository epel is listed more than once in the configuration
Cleaning repos: base epel extras updates
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors
[root@hadoop01 yum.repos.d]# yum makecache
Loaded plugins: fastestmirror, langpacks, priorities
Repository epel is listed more than once in the configuration
Determining fastest mirrors

http://mirrors.aliyuncs.com/centos/%24releasever/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/$releasever/os/x86_64/repodata/repomd.xml: (28, ‘Connection timed out after 30000 milliseconds‘)
Trying other mirror.
http://mirrors.cloud.aliyuncs.com/centos/%24releasever/os/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: mirrors.cloud.aliyuncs.com; Unknown error"
Trying other mirror.
http://mirrors.aliyuncs.com/centos/%24releasever/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/$releasever/os/x86_64/repodata/repomd.xml: (28, ‘Connection timed out after 30001 milliseconds‘)
Trying other mirror.
http://mirrors.aliyuncs.com/centos/%24releasever/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/$releasever/os/x86_64/repodata/repomd.xml: (28, ‘Connection timed out after 30001 milliseconds‘)
Trying other mirror.
http://mirrors.aliyuncs.com/centos/%24releasever/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/$releasever/os/x86_64/repodata/repomd.xml: (28, ‘Connection timed out after 30001 milliseconds‘)
Trying other mirror.
http://mirrors.aliyuncs.com/centos/%24releasever/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/$releasever/os/x86_64/repodata/repomd.xml: (28, ‘Connection timed out after 30001 milliseconds‘)
Trying other mirror.
http://mirrors.aliyuncs.com/centos/%24releasever/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/$releasever/os/x86_64/repodata/repomd.xml: (28, ‘Connection timed out after 30001 milliseconds‘)
Trying other mirror.
...

【解决方法】
在网上找了好多帖子,都没能解决我的问题,后来看到是HTTP请求失败,尝试本地访问之前wget下来的 CentOS-Base.repo 发现其中的:

http://mirrors.aliyun.com/centos/$releasever/os/$basearch/

等URL通过http的形式根本无法访问,此时将变量$releasever改为7(我的系统是centos 7),发现可以访问了,顺便将所有的变量$releasever都改为7。感觉这个变量$releasever根本就没起作用呀。

改完之后,执行yum clean all 以及 yum makecache 成功。

oaded plugins: fastestmirror, langpacks
Determining fastest mirrors

  • base: mirrors.aliyun.com
  • extras: mirrors.aliyun.com
  • updates: mirrors.aliyun.com
    base | 3.6 kB 00:00:00
    extras | 3.4 kB 00:00:00
    updates | 3.4 kB 00:00:00
    (1/12): base/x86_64/group_gz | 166 kB 00:00:00
    (2/12): base/x86_64/primary_db | 6.0 MB 00:00:00
    (3/12): base/x86_64/filelists_db | 7.1 MB 00:00:00
    (4/12): base/x86_64/other_db | 2.6 MB 00:00:00
    (5/12): extras/x86_64/prestodelta | 73 kB 00:00:00
    (6/12): extras/x86_64/primary_db | 215 kB 00:00:00
    (7/12): extras/x86_64/other_db | 131 kB 00:00:00
    (8/12): extras/x86_64/filelists_db | 249 kB 00:00:00
    (9/12): updates/x86_64/prestodelta | 945 kB 00:00:00
    (10/12): updates/x86_64/filelists_db | 5.2 MB 00:00:00
    (11/12): updates/x86_64/other_db | 764 kB 00:00:00
    (12/12): updates/x86_64/primary_db | 7.4 MB 00:00:00
    Metadata Cache Created

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

上一篇:Spring 学习——基于Spring WebSocket 和STOMP实现简单的聊天功能


下一篇:【转】ubuntu开启SSH服务,并允许ROOT权限远程登录。