This system is not registered with an entitlement server. You can use subscription-manager to register.

由于redhat 的更新包只对注册的用户生效,所以需要自己手动更改成CentOS 的更新包,CentOS几乎和redhat是一样的,所以无需担心软件包是否可安装,安装之后是否有问题。

操作系统:Red Hat Enterprise Linux Server release 7.9 (Maipo)

1.     首先查看redhat 7.9系统本身所安装的那些yum 软件包

[root@rhel7 ~]#  rpm -qa | grep yum

yum-rhn-plugin-2.0.1-10.el7.noarch

yum-3.4.3-168.el7.noarch

PackageKit-yum-1.1.10-2.el7.x86_64

yum-langpacks-0.4.2-7.el7.noarch

yum-utils-1.1.31-54.el7_8.noarch

yum-metadata-parser-1.1.4-10.el7.x86_64

2.     卸载这些软件包

[root@rhel7 ~]#  rpm -e yum-rhn-plugin-2.0.1-10.el7.noarch --nodeps

[root@rhel7 ~]#  rpm -e yum-3.4.3-168.el7.noarch --nodeps

[root@rhel7 ~]#  rpm -e PackageKit-yum-1.1.10-2.el7.x86_64 --nodeps

[root@rhel7 ~]#  rpm -e yum-langpacks-0.4.2-7.el7.noarch --nodeps

警告:/etc/yum/pluginconf.d/langpacks.conf 已另存为 /etc/yum/pluginconf.d/langpacks.conf.rpmsave

[root@rhel7 ~]#  rpm -e yum-utils-1.1.31-54.el7_8.noarch --nodeps

[root@rhel7 ~]#  rpm -e yum-metadata-parser-1.1.4-10.el7.x86_64 --nodeps

3.     保证本机电脑能上网

[root@rhel7 ~]#  ping mirrors.163.com

PING mirrors.163.com (106.225.229.135) 56(84) bytes of data.

64 bytes from mirrors.163.com (106.225.229.135): icmp_seq=1 ttl=128 time=4.64 ms

64 bytes from mirrors.163.com (106.225.229.135): icmp_seq=2 ttl=128 time=5.34 ms

64 bytes from mirrors.163.com (106.225.229.135): icmp_seq=3 ttl=128 time=4.72 ms

4.     进入以下网站上面查看软件包的版本是否升级或者找到自己系统所对应的文件包版本更新

网易开源镜像站:

清华大学开源软件镜像站:

5.     找到自己所需要的版本下载

[root@rhel7 ~]#  wget 7/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm

[root@rhel7 ~]#  wget 7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm

[root@rhel7 ~]#  wget 7/os/x86_64/Packages/yum-utils-1.1.31-54.el7_8.noarch.rpm

[root@rhel7 ~]#  wget 7/os/x86_64/Packages/yum-updateonboot-1.1.31-54.el7_8.noarch.rpm

[root@rhel7 ~]#  wget 7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm

6.     查看下载完成结果

[root@rhel7 ~]#  ll *rpm

-rw-r--r-- 1 root root 1298856 10 月 15 2020 yum-3.4.3-168.el7.centos.noarch.rpm

-rw-r--r-- 1 root root   28348 7 月   4 2014 yum-metadata-parser-1.1.4-10.el7.x86_64.rpm

-rw-r--r-- 1 root root   35216 5 月  14 2020 yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm

-rw-r--r-- 1 root root   28024 5 月  14 2020 yum-updateonboot-1.1.31-54.el7_8.noarch.rpm

-rw-r--r-- 1 root root  124852 5 月  14 2020 yum-utils-1.1.31-54.el7_8.noarch.rpm

7.     安装软件包

[root@rhel7 ~]#  rpm -ivh yum-*

警告:yum-3.4.3-168.el7.centos.noarch.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY

准备中...                          ################################# [100%]

正在升级/安装...

   1:yum-metadata-parser-1.1.4-10.el7 ################################# [ 20%]

   2:yum-plugin-fastestmirror-1.1.31-5################################# [ 40%]

   3:yum-3.4.3-168.el7.centos         ################################# [ 60%]

   4:yum-updateonboot-1.1.31-54.el7_8 ################################# [ 80%]

   5:yum-utils-1.1.31-54.el7_8        ################################# [100%]

8.     新建repo 配置文件

[root@rhel7 ~]# vim /etc/yum.repos.d/CentOS7-Base-163.repo

# 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.9.2009 - Base - 163.com

#mirrorlist=

baseurl=7.9.2009/os/$basearch/

gpgcheck=1

gpgkey=RPM-GPG-KEY-CentOS-7

 

#released updates

[updates]

name=CentOS-7.9.2009 - Updates - 163.com

#mirrorlist=

baseurl=7.9.2009/updates/$basearch/

gpgcheck=1

gpgkey=RPM-GPG-KEY-CentOS-7

 

#additional packages that may be useful

[extras]

name=CentOS-7.9.2009 - Extras - 163.com

#mirrorlist=

baseurl=7.9.2009/extras/$basearch/

gpgcheck=1

gpgkey=RPM-GPG-KEY-CentOS-7

 

#additional packages that extend functionality of existing packages

[centosplus]

name=CentOS-7.9.2009 - Plus - 163.com

baseurl=7.9.2009/centosplus/$basearch/

gpgcheck=1

enabled=0

gpgkey=RPM-GPG-KEY-CentOS-7

9.     至此YUM 网络源已经安装完成,运行以下命令生成缓存

[root@rhel7 ~]#  yum clean all

已加载插件:fastestmirror, product-id, search-disabled-repos, subscription-manager

 

This system is not registered with an entitlement server. You can use subscription-manager to register.

 

正在清理软件源: base extras updates

[root@rhel7 ~]#  yum makecache

已加载插件:fastestmirror, product-id, search-disabled-repos, subscription-manager

 

This system is not registered with an entitlement server. You can use subscription-manager to register.

 

Determining fastest mirrors

base                                                                                                                                         | 3.6 kB  00:00:00    

extras                                                                                                                                       | 2.9 kB  00:00:00    

updates                                                                                                                                      | 2.9 kB  00:00:00    

(1/10): base/x86_64/group_gz                                                                                                                 | 153 kB  00:00:00    

(2/10): base/x86_64/filelists_db                                                                                                             | 7.2 MB  00:00:02    

(3/10): base/x86_64/primary_db                                                                                                               | 6.1 MB  00:00:01    

(4/10): extras/x86_64/primary_db                                                                                                             | 242 kB  00:00:00    

(5/10): extras/x86_64/filelists_db                                                                                                           | 235 kB  00:00:00    

(6/10): base/x86_64/other_db                                                                                                                 | 2.6 MB  00:00:01    

(7/10): extras/x86_64/other_db                                                                                                               | 143 kB  00:00:00    

(8/10): updates/x86_64/primary_db                                                                                                            | 9.6 MB  00:00:02    

(9/10): updates/x86_64/filelists_db                                                                                                          | 5.5 MB  00:00:02    

(10/10): updates/x86_64/other_db                                                                                                             | 706 kB  00:00:00    

元数据缓存已建立

10.    测试安装是否正常

[root@rhel7 ~]#  yum -y install gcc

已加载插件:fastestmirror, product-id, search-disabled-repos, subscription-manager

 

This system is not registered with an entitlement server. You can use subscription-manager to register.

 

Loading mirror speeds from cached hostfile

正在解决依赖关系

-->  正在检查事务

--->  软件包 gcc.x86_64.0.4.8.5-44.el7 将被 安装

-->  正在处理依赖关系 cpp = 4.8.5-44.el7,它被软件包 gcc-4.8.5-44.el7.x86_64 需要

-->  正在处理依赖关系 glibc-devel >= 2.2.90-12,它被软件包 gcc-4.8.5-44.el7.x86_64 需要

-->  正在检查事务

--->  软件包 cpp.x86_64.0.4.8.5-44.el7 将被 安装

--->  软件包 glibc-devel.x86_64.0.2.17-324.el7_9 将被 安装

-->  正在处理依赖关系 glibc-headers = 2.17-324.el7_9,它被软件包 glibc-devel-2.17-324.el7_9.x86_64 需要

-->  正在处理依赖关系 glibc = 2.17-324.el7_9,它被软件包 glibc-devel-2.17-324.el7_9.x86_64 需要

-->  正在处理依赖关系 glibc-headers,它被软件包 glibc-devel-2.17-324.el7_9.x86_64 需要

-->  正在检查事务

--->  软件包 glibc.x86_64.0.2.17-317.el7 将被 升级

-->  正在处理依赖关系 glibc = 2.17-317.el7,它被软件包 glibc-common-2.17-317.el7.x86_64 需要

--->  软件包 glibc.x86_64.0.2.17-324.el7_9 将被 更新

--->  软件包 glibc-headers.x86_64.0.2.17-324.el7_9 将被 安装

-->  正在处理依赖关系 kernel-headers >= 2.2.1,它被软件包 glibc-headers-2.17-324.el7_9.x86_64 需要

-->  正在处理依赖关系 kernel-headers,它被软件包 glibc-headers-2.17-324.el7_9.x86_64 需要

-->  正在检查事务

--->  软件包 glibc-common.x86_64.0.2.17-317.el7 将被 升级

--->  软件包 glibc-common.x86_64.0.2.17-324.el7_9 将被 更新

--->  软件包 kernel-headers.x86_64.0.3.10.0-1160.36.2.el7 将被 安装

-->  解决依赖关系完成

 

依赖关系解决

 

====================================================================================================================================================================

 Package                                   架构                             版本                                             源                                 大小

====================================================================================================================================================================

正在安装:

 gcc                                      x86_64                           4.8.5-44.el7                                     base                               16 M

为依赖而安装:

 cpp                                      x86_64                           4.8.5-44.el7                                     base                              5.9 M

 glibc-devel                              x86_64                           2.17-324.el7_9                                   updates                           1.1 M

 glibc-headers                            x86_64                           2.17-324.el7_9                                   updates                           691 k

 kernel-headers                           x86_64                           3.10.0-1160.36.2.el7                             updates                           9.0 M

为依赖而更新:

 glibc                                    x86_64                           2.17-324.el7_9                                   updates                           3.6 M

 glibc-common                             x86_64                           2.17-324.el7_9                                   updates                            12 M

 

事务概要

====================================================================================================================================================================

安装  1 软件包 (+4 依赖软件包)

升级           ( 2 依赖软件包)

 

总下载量:48 M

Downloading packages:

No Presto metadata available for updates

警告:/var/cache/yum/x86_64/$releasever/updates/packages/glibc-2.17-324.el7_9.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY |  18 MB  00:00:05 ETA

glibc-2.17-324.el7_9.x86_64.rpm  的公钥尚未安装

(1/7): glibc-2.17-324.el7_9.x86_64.rpm                                                                                                       | 3.6 MB  00:00:02    

cpp-4.8.5-44.el7.x86_64.rpm  的公钥尚未安装rpm                       42% [========================                                 ] 5.5 MB/s |  20 MB  00:00:04 ETA

(2/7): cpp-4.8.5-44.el7.x86_64.rpm                                                                                                           | 5.9 MB  00:00:02    

(3/7): glibc-common-2.17-324.el7_9.x86_64.rpm                                                                                                |  12 MB  00:00:04    

(4/7): glibc-devel-2.17-324.el7_9.x86_64.rpm                                                                                                 | 1.1 MB  00:00:02    

(5/7): gcc-4.8.5-44.el7.x86_64.rpm                                                                                                           |  16 MB  00:00:04    

(6/7): glibc-headers-2.17-324.el7_9.x86_64.rpm                                                                                               | 691 kB  00:00:00    

(7/7): kernel-headers-3.10.0-1160.36.2.el7.x86_64.rpm                                                                                        | 9.0 MB  00:00:05    

--------------------------------------------------------------------------------------------------------------------------------------------------------------------

总计                                                                                                                                4.8 MB/s |  48 MB  00:00:10    

从 RPM-GPG-KEY-CentOS-7 检索密钥

导入 GPG key 0xF4A80EB5:

  用户ID     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"

  指纹       : 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5

  来自       : RPM-GPG-KEY-CentOS-7

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

警告:RPM 数据库已被非 yum 程序修改。

**  发现 2 个已存在的 RPM 数据库问题, 'yum check' 输出如下:

PackageKit-1.1.10-2.el7.x86_64  有缺少的需求 PackageKit-backend

rhn-check-2.0.2-24.el7.x86_64  有缺少的需求 yum-rhn-plugin >= ('0', '1.6.4', '1')

   正在更新    : glibc-common-2.17-324.el7_9.x86_64                                                                                                              1/9

   正在更新    : glibc-2.17-324.el7_9.x86_64                                                                                                                     2/9

   正在安装    : cpp-4.8.5-44.el7.x86_64                                                                                                                         3/9

   正在安装    : kernel-headers-3.10.0-1160.36.2.el7.x86_64                                                                                                      4/9

   正在安装    : glibc-headers-2.17-324.el7_9.x86_64                                                                                                             5/9

   正在安装    : glibc-devel-2.17-324.el7_9.x86_64                                                                                                               6/9

   正在安装    : gcc-4.8.5-44.el7.x86_64                                                                                                                         7/9

   清理        : glibc-common-2.17-317.el7.x86_64                                                                                                                8/9

   清理        : glibc-2.17-317.el7.x86_64                                                                                                                       9/9

   验证中      : glibc-2.17-324.el7_9.x86_64                                                                                                                     1/9

   验证中      : glibc-headers-2.17-324.el7_9.x86_64                                                                                                             2/9

   验证中      : cpp-4.8.5-44.el7.x86_64                                                                                                                         3/9

   验证中      : glibc-devel-2.17-324.el7_9.x86_64                                                                                                               4/9

   验证中      : gcc-4.8.5-44.el7.x86_64                                                                                                                         5/9

   验证中      : kernel-headers-3.10.0-1160.36.2.el7.x86_64                                                                                                      6/9

   验证中      : glibc-common-2.17-324.el7_9.x86_64                                                                                                              7/9

   验证中      : glibc-2.17-317.el7.x86_64                                                                                                                       8/9

   验证中      : glibc-common-2.17-317.el7.x86_64                                                                                                                9/9

 

已安装:

  gcc.x86_64 0:4.8.5-44.el7                                                                                                                                         

 

作为依赖被安装:

  cpp.x86_64 0:4.8.5-44.el7     glibc-devel.x86_64 0:2.17-324.el7_9     glibc-headers.x86_64 0:2.17-324.el7_9     kernel-headers.x86_64 0:3.10.0-1160.36.2.el7   

 

作为依赖被升级:

  glibc.x86_64 0:2.17-324.el7_9                                                 glibc-common.x86_64 0:2.17-324.el7_9                                               

 

完毕!

到这里安装完成,以后安装所需包,可以不用本地yum源了,直接使用网络yum源。