0

0

Redhad 7改用CentOS7 yum源【亲测】

蓮花仙者

蓮花仙者

发布时间:2025-07-11 09:40:22

|

318人浏览过

|

来源于php中文网

原创

1、遇到问题

在RedHat系统中,默认的yum源需要注册到RedHat Subscription Management才能更新。为了避免花费,我们需要替换为国内的yum源。

2、解决办法

由于CentOS和RedHat系统非常相似,替换为CentOS的yum源是可行的,但过程中可能遇到一些挑战。以下是解决方案的详细步骤,参考了博文:https://www.php.cn/link/95d8f6ff68222377d570a652eb96f082

(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软件包

Redhad 7改用CentOS7 yum源【亲测】

从阿里镜像中查找所需的yum包:

Remover
Remover

几秒钟去除图中不需要的元素

下载
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.

尝试将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=https://www.php.cn/link/588fad4e41a1544c03e7d5625c37cbf0

baseurl=https://www.php.cn/link/8f5f383cc40b32666bf48521713980f4 gpgcheck=1 gpgkey=https://www.php.cn/link/aa799ad70bea3029d4141c7b773c1a46

released updates

[updates] name=CentOS-$7 - Updates - 163.com

mirrorlist=https://www.php.cn/link/1a795f72604e4e1d35075019929d5b95

baseurl=https://www.php.cn/link/e8d2fc41fb98705874a309ed648806a0 gpgcheck=1 gpgkey=https://www.php.cn/link/aa799ad70bea3029d4141c7b773c1a46

additional packages that may be useful

[extras] name=CentOS-$7 - Extras - 163.com

mirrorlist=https://www.php.cn/link/edb636f69bf78b885117a47ec1a455d4

baseurl=https://www.php.cn/link/bf6423635e56a99e9df17852c6bfadca gpgcheck=1 gpgkey=https://www.php.cn/link/aa799ad70bea3029d4141c7b773c1a46

additional packages that extend functionality of existing packages

[centosplus] name=CentOS-$7 - Plus - 163.com baseurl=https://www.php.cn/link/ea14b04d59d604daf500d9a35bdd01be gpgcheck=1 enabled=0 gpgkey=https://www.php.cn/link/aa799ad70bea3029d4141c7b773c1a46

[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]#

相关专题

更多
http与https有哪些区别
http与https有哪些区别

http与https的区别:1、协议安全性;2、连接方式;3、证书管理;4、连接状态;5、端口号;6、资源消耗;7、兼容性。本专题为大家提供相关的文章、下载、课程内容,供大家免费下载体验。

1986

2024.08.16

centos
centos

PHP中文网为大家提供centos相关信息,CentOS(Community Enterprise Operating System,中文意思是社区企业操作系统)是Linux发行版之一,是免费的、开源的、可以重新分发的开源操作系统,PHP中文网提供centos相关文章,以及安装教程。

431

2023.06.16

常见的linux系统有哪些
常见的linux系统有哪些

linux系统有Ubuntu、Fedora、CentOS、Debian、openSUSE、Arch Linux、Gentoo、Slackware、Linux Mint、Kali Linux。更多关于linux系统的文章详情请阅读本专题下面的文章。php中文网欢迎大家前来学习。

804

2023.10.27

高德地图升级方法汇总
高德地图升级方法汇总

本专题整合了高德地图升级相关教程,阅读专题下面的文章了解更多详细内容。

68

2026.01.16

全民K歌得高分教程大全
全民K歌得高分教程大全

本专题整合了全民K歌得高分技巧汇总,阅读专题下面的文章了解更多详细内容。

123

2026.01.16

C++ 单元测试与代码质量保障
C++ 单元测试与代码质量保障

本专题系统讲解 C++ 在单元测试与代码质量保障方面的实战方法,包括测试驱动开发理念、Google Test/Google Mock 的使用、测试用例设计、边界条件验证、持续集成中的自动化测试流程,以及常见代码质量问题的发现与修复。通过工程化示例,帮助开发者建立 可测试、可维护、高质量的 C++ 项目体系。

34

2026.01.16

java数据库连接教程大全
java数据库连接教程大全

本专题整合了java数据库连接相关教程,阅读专题下面的文章了解更多详细内容。

39

2026.01.15

Java音频处理教程汇总
Java音频处理教程汇总

本专题整合了java音频处理教程大全,阅读专题下面的文章了解更多详细内容。

19

2026.01.15

windows查看wifi密码教程大全
windows查看wifi密码教程大全

本专题整合了windows查看wifi密码教程大全,阅读专题下面的文章了解更多详细内容。

85

2026.01.15

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
相关推荐
/
热门推荐
/
最新课程
最新Python教程 从入门到精通
最新Python教程 从入门到精通

共4课时 | 4.3万人学习

Django 教程
Django 教程

共28课时 | 3.2万人学习

SciPy 教程
SciPy 教程

共10课时 | 1.2万人学习

关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号