Redhad 7改用CentOS7 yum源【亲测】

1、遇到问题

[root@node1 ~]# yum search docker
Loaded plugins: 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.
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
================================================================ Matched: docker ================================================================
subscription-manager-plugin-container.x86_64 : A plugin for handling container content.
[root@node1 ~]#

redhat 默认自带的 yum 源需要注册,才能更新。我们想不花钱,需要替换掉redhat的yum源,最好是国内的源。

2、解决办法

CentOS几乎和redhat是一样的,所以无需担心软件包是否可安装,安装之后是否有问题。
但是更换CentOS源,坑很多,折腾了一上午,终于解决。
其中参考了博文:https://blog.csdn.net/hongbin_xu/article/details/79316614

(1)删除redhat自带的yum包

[root@node1 ~]# rpm -qa|grep yum|xargs rpm -e --nodeps
warning: /etc/yum/pluginconf.d/langpacks.conf saved as /etc/yum/pluginconf.d/langpacks.conf.rpmsave
[root@node1 ~]# rpm -qa |grep yum
[root@node1 ~]# 
[root@node1 ~]# rpm -qa|grep python-urlgrabber|xargs rpm -e --nodeps

(2)下载yum软件包
https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/
这里写图片描述

从阿里镜像中查找需要的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-154.el7.centos.noarch.rpm 
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-42.el7.noarch.rpm 
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-42.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/yum-langpacks-0.4.2-7.el7.noarch.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/yum-rhn-plugin-2.0.1-9.el7.noarch.rpm
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/rpm-4.11.3-25.el7.x86_64.rpm

(3)安装依赖

[root@node1 ~]# rpm -ivh python-urlgrabber-3.10-8.el7.noarch.rpm
warning: python-urlgrabber-3.10-8.el7.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:python-urlgrabber-3.10-8.el7     ################################# [100%]
[root@node1 ~]#
[root@node1 ~]# rpm -Uvh rpm-4.11.3-25.el7.x86_64.rpm --nodeps
warning: rpm-4.11.3-25.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:rpm-4.11.3-25.el7                ################################# [ 50%]
Cleaning up / removing...
   2:rpm-4.11.3-21.el7                ################################# [100%]
[root@node1 ~]#

(4)yum包

[root@node1 ~]# rpm -ivh yum-*
warning: yum-3.4.3-154.el7.centos.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:yum-metadata-parser-1.1.4-10.el7 ################################# [ 17%]
   2:yum-plugin-fastestmirror-1.1.31-4################################# [ 33%]
   3:yum-3.4.3-154.el7.centos         ################################# [ 50%]
   4:yum-langpacks-0.4.2-7.el7        ################################# [ 67%]
   5:yum-rhn-plugin-2.0.1-9.el7       ################################# [ 83%]
   6:yum-utils-1.1.31-42.el7          ################################# [100%]
[root@node1 ~]#

3、更新源

下面更新源即可使用CentOS yum源了

[root@node1 ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

更新缓存时时报错

[root@node1 ~]# yum makecache
Loaded plugins: fastestmirror, 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.
http://mirrors.aliyun.com/centos/%24releasever/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
To address this issue please refer to the below knowledge base article 

https://access.redhat.com/articles/1320623

If above article doesn't help to resolve this issue please create a bug on 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; No route to host"
Trying other mirror.
http://mirrors.aliyuncs.com/centos/%24releasever/os/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; No route to host"
Trying other mirror.
http://mirrors.aliyuncs.com/centos/%24releasever/os/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; No route to host"
Trying other mirror.
http://mirrors.aliyuncs.com/centos/%24releasever/os/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; No route to host"
Trying other mirror.
http://mirrors.aliyuncs.com/centos/%24releasever/os/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; No route to host"
Trying other mirror.
http://mirrors.aliyuncs.com/centos/%24releasever/os/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; No route to host"
Trying other mirror.
http://mirrors.aliyuncs.com/centos/%24releasever/os/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; No route to host"
Trying other mirror.
http://mirrors.aliyuncs.com/centos/%24releasever/os/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; No route to host"
Trying other mirror.

尝试CentOS-Base.repo内容更改为163的源

#CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$7 - Base - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=os
baseurl=http://mirrors.163.com/centos/7/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$7 - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/7/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$7 - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/7/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$7 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/7/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
[root@node1 yum.repos.d]# vi CentOS-Base.repo
[root@node1 yum.repos.d]# yum makecache
Loaded plugins: fastestmirror, 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.
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                                                                                              | 156 kB  00:00:05     
(2/12): base/x86_64/filelists_db                                                                                          | 6.7 MB  00:00:06     
(3/12): base/x86_64/other_db                                                                                              | 2.5 MB  00:00:00     
(4/12): base/x86_64/primary_db                                                                                            | 5.7 MB  00:00:03     
(5/12): extras/x86_64/prestodelta                                                                                         | 129 kB  00:00:05     
(6/12): extras/x86_64/primary_db                                                                                          | 185 kB  00:00:00     
(7/12): extras/x86_64/other_db                                                                                            | 121 kB  00:00:00     
(8/12): extras/x86_64/filelists_db                                                                                        | 709 kB  00:00:10     
(9/12): updates/x86_64/filelists_db                                                                                       | 4.2 MB  00:00:06     
(10/12): updates/x86_64/prestodelta                                                                                       | 960 kB  00:00:06     
(11/12): updates/x86_64/primary_db                                                                                        | 6.9 MB  00:00:01     
(12/12): updates/x86_64/other_db                                                                                          | 734 kB  00:00:01     
Determining fastest mirrors
Metadata Cache Created
[root@node1 yum.repos.d]# 
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值