RHEL7 yum源配置

LEVEL7發表於2021-08-20

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源。


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31516603/viewspace-2788098/,如需轉載,請註明出處,否則將追究法律責任。

相關文章