Redhat 未注册 yum解决办法

Redhat 未注册 yum解决办法

问题出现

在使用 redhat 7 的时候,使用yum 安装某些软件的时候,发现会出现一些如下的错误:

One of the configured repositories failed (CentOS-Base),
safe thing yum can do is fail. There are a few ways to work "fix" this:
     1. Contact the upstream for the repository and get them to fix the problem.
     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).
     3. Disable the repository, so yum won't use it by default. Yum will then
        just ignore the repository until you permanently enable it again or use
        --enablerepo for temporary usage:
            yum-config-manager --disable base
     4. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:
            yum-config-manager --save --setopt=base.skip_if_unavailable=true
failure: repodata/repomd.xml from base: [Errno 256] No more mirrors to try.
http://mirrors.aliyun.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed connect to mirrors.aliyun.com:80; Operation now in progress"
http://mirrors.aliyun.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed connect to mirrors.aliyun.com:80; Operation now in progress"
http://mirrors.aliyun.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed connect to mirrors.aliyun.com:80; Operation now in progress"
http://mirrors.aliyun.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed connect to mirrors.aliyun.com:80; Operation now in progress"
http://mirrors.aliyun.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed connect to mirrors.aliyun.com:80; Operation now in progress"
http://mirrors.aliyun.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyun.com/centos/7/os/x86_64/repodata/repomd.xml: (28, 'Connection timed out after 3251 milliseconds')
http://mirrors.aliyun.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed connect to mirrors.aliyun.com:80; Operation now in progress"
http://mirrors.aliyun.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed connect to mirrors.aliyun.com:80; Operation now in progress"

并且使用yum update 的时候,会出现一个问题:
未知的名称或服务,正在尝试其它镜像

删除CentOS-Base.repo 之后,发现更新没有问题,但是会有一个提示:

已加载插件:langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

到此查阅资料发现原来是系统未注册到红帽,所以yum功能受到了限制。如果要使用的话,只能删除系统自带的yum源,配置其它源

解决办法

1、准备相关的软件包
准备其他yum源的软件包,这里采用Centos 7 的源,使用网易的镜像网站,下载地址为 http://mirrors.163.com/centos/
具体地址 http://mirrors.163.com/centos/7/os/x86_64/Packages/
所需要的相关包有(这里取的是当前最新的包):
rpm-4.11.3-32.el7.x86_64.rpm
yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
python-urlgrabber-3.10-8.el7.noarch.rpm
yum-3.4.3-158.el7.centos.noarch.rpm
yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm

这里在/etc/yum.repos.d/ 下建立了一个 yumbak 目录用来存储下载的软件包
找到对应包的下载路径之后,记录到该文件下的一个文件 download.log 中
其内容为:

# cat download.log 
http://mirrors.163.com/centos/7/os/x86_64/Packages/rpm-4.11.3-32.el7.x86_64.rpm
http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
http://mirrors.163.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-8.el7.noarch.rpm
http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-158.el7.centos.noarch.rpm
http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm

下载命令:

wget -P /etc/yum.repos.d/yumbak/ -i /etc/yum.repos.d/yumbak/download.log

2、卸载当前的yum源
准备好其他的yum源软件包之后,就要开始卸载 redhat 7 自带的yum源了
查看当前系统所安装的yum 软件包,使用命令 rpm -qa|grep yum

#rpm -qa|grep yum
yum-utils-1.1.31-34.el7.noarch
PackageKit-yum-1.0.7-5.el7.x86_64
yum-3.4.3-132.el7.noarch
yum-metadata-parser-1.1.4-10.el7.x86_64
yum-rhn-plugin-2.0.1-5.el7.noarch
yum-langpacks-0.4.2-4.el7.noarch

删除原有的yum源

rpm -qa|grep yum|xargs rpm -e --nodeps

3、安装
进入到下载目录进行安装
使用以下命令进行安装,在安装的时候可能系统会提示存在文件冲突,所以这里采取强制安装的方式,即在执行安装语句的时候加上选项 --force

rpm -ivh --force rpm-4.11.3-32.el7.x86_64.rpm yum-metadata-parser-1.1.4-10.el7.x86_64.rpm python-urlgrabber-3.10-8.el7.noarch.rpm yum-3.4.3-158.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm

4、配置文件
这里继续使用网易镜像的配置文,下载地址http://mirrors.163.com/.help/centos.html
Centos7的镜像下载链接为:http://mirrors.163.com/.help/CentOS7-Base-163.repo

使用以下命令,该文将放在 /etc/yum.repos.d 文件夹下

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo

文件下载好以后,还要更换版本号,即更改文件中的变量 $releasever
使用以下命令

sed -i "s/\$releasever/7/g" /etc/yum.repos.d/CentOS-Base.repo

或者使用vim /etc/yum.repos.d/CentOS-Base.repo 进入命令模式,执行以下命令

1,$s/$releasever/7/g

到此配置文件就完成了

5、完成
清除原有缓存,建立新缓存:
yum clean all
yum makecache
直到出现 元数据缓存已建立
至此,yum源已成功替换为Centos 7 的yum源了
再使用 yum update 一切正常,就可愉快的使用yum 进行各种软件的安装了

  • 2
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值