自由的羽毛 发表于 2025-3-26 19:36:45

CentOS 7设置网络yum源(阿里)超详细步调

步调1、备份yum源文件
    1)进入/etc/yum.repos.d/目次,检察是否yum源文件是否存在。
# cd /etc/yum.repos.d/
# ll
总用量 60
-rw-------. 1 root root 2523 7月30 2024 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 5月21 2024 CentOS-CR.repo
-rw-r--r--. 1 root root649 5月21 2024 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root314 5月21 2024 CentOS-fasttrack.repo
-rw-r--r--. 1 root root630 5月21 2024 CentOS-Media.repo
-rw-r--r--. 1 root root998 12月 11 2018 CentOS-SCLo-scl.repo.bak
-rw-r--r--. 1 root root181 7月31 2024 CentOS-SCLo-scl-rh.repo
-rw-r--r--. 1 root root 1159 7月31 2024 CentOS-SCLo-scl-rh.repo.bak
-rw-r--r--. 1 root root 1331 5月21 2024 CentOS-Sources.repo
-rw-r--r--. 1 root root 9454 5月21 2024 CentOS-Vault.repo
-rw-r--r--. 1 root root616 5月21 2024 CentOS-x86_64-kernel.repo
-rw-r--r--. 1 root root 1358 9月   5 2021 epel.repo
-rw-r--r--. 1 root root 1457 9月   5 2021 epel-testing.repo   2)实行mv CentOS-Base.repo CentOS-Base.repo.bak 将原始yum源文件备份至本目次下。
# mv CentOS-Base.repo CentOS-Base.repo.bak
# ll
总用量 60
-rw-------. 1 root root 2523 7月30 2024 CentOS-Base.repo.bak
-rw-r--r--. 1 root root 1309 5月21 2024 CentOS-CR.repo
-rw-r--r--. 1 root root649 5月21 2024 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root314 5月21 2024 CentOS-fasttrack.repo
-rw-r--r--. 1 root root630 5月21 2024 CentOS-Media.repo
-rw-r--r--. 1 root root998 12月 11 2018 CentOS-SCLo-scl.repo.bak
-rw-r--r--. 1 root root181 7月31 2024 CentOS-SCLo-scl-rh.repo
-rw-r--r--. 1 root root 1159 7月31 2024 CentOS-SCLo-scl-rh.repo.bak
-rw-r--r--. 1 root root 1331 5月21 2024 CentOS-Sources.repo
-rw-r--r--. 1 root root 9454 5月21 2024 CentOS-Vault.repo
-rw-r--r--. 1 root root616 5月21 2024 CentOS-x86_64-kernel.repo
-rw-r--r--. 1 root root 1358 9月   5 2021 epel.repo
-rw-r--r--. 1 root root 1457 9月   5 2021 epel-testing.repo   步调2、获取阿里yum源设置文件(需要确保虚拟机连接外网正常)。
    1)实行 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo 下载文件至/etc/yum.repos.d/下。
# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
--2025-02-18 15:31:35--http://mirrors.aliyun.com/repo/Centos-7.repo
正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 116.196.140.238, 116.196.140.235, 116.196.140.231, ...
正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|116.196.140.238|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:2523 (2.5K)
正在保存至: “/etc/yum.repos.d/CentOS-Base.repo”

100%[==========================================================================================================>] 2,523       --.-K/s 用时 0s      

2025-02-18 15:31:35 (74.1 MB/s) - 已保存 “/etc/yum.repos.d/CentOS-Base.repo” )

#   2)检察/etc/yum.repos.d/目次下新下载的文件
# ll
总用量 64
-rw-r--r--1 root root 2523 8月   4 2022 CentOS-Base.repo
-rw-------. 1 root root 2523 7月30 2024 CentOS-Base.repo.bak
-rw-r--r--. 1 root root 1309 5月21 2024 CentOS-CR.repo
-rw-r--r--. 1 root root649 5月21 2024 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root314 5月21 2024 CentOS-fasttrack.repo
-rw-r--r--. 1 root root630 5月21 2024 CentOS-Media.repo
-rw-r--r--. 1 root root998 12月 11 2018 CentOS-SCLo-scl.repo.bak
-rw-r--r--. 1 root root181 7月31 2024 CentOS-SCLo-scl-rh.repo
-rw-r--r--. 1 root root 1159 7月31 2024 CentOS-SCLo-scl-rh.repo.bak
-rw-r--r--. 1 root root 1331 5月21 2024 CentOS-Sources.repo
-rw-r--r--. 1 root root 9454 5月21 2024 CentOS-Vault.repo
-rw-r--r--. 1 root root616 5月21 2024 CentOS-x86_64-kernel.repo
-rw-r--r--. 1 root root 1358 9月   5 2021 epel.repo
-rw-r--r--. 1 root root 1457 9月   5 2021 epel-testing.repo   3)运行 yum clean all 扫除缓存
# yum clean all
已加载插件:fastestmirror
正在清理软件源: base centos-sclo-rh epel extras updates
Cleaning up list of fastest mirrors   4)运行 yum makecache 生成新的缓存
# yum makecache
已加载插件:fastestmirror
Determining fastest mirrors
epel/x86_64/metalink                                                                                                         | 5.1 kB00:00:00   
* base: mirrors.cloud.aliyuncs.com
* epel: mirror.math.princeton.edu
* extras: mirrors.cloud.aliyuncs.com
* updates: mirrors.cloud.aliyuncs.com
base                                                                                                                         | 3.6 kB00:00:00   
centos-sclo-rh                                                                                                               | 3.0 kB00:00:00   
https://repo.jing.rocks/fedora-buffet/archive/epel/7/x86_64/repodata/repomd.xml: curl#7 - "Failed to connect to 240b:10:f00:1b00::240: 网络不可达"
正在尝试其它镜像。
epel                                                                                                                         | 4.3 kB00:00:00   
extras                                                                                                                     | 2.9 kB00:00:00   
updates                                                                                                                      | 2.9 kB00:00:00   
(1/19): base/7/x86_64/group_gz                                                                                             | 153 kB00:00:00   
(2/19): base/7/x86_64/other_db                                                                                             | 2.6 MB00:00:02   
(3/19): centos-sclo-rh/primary_db                                                                                          | 3.4 MB00:00:05   
epel/x86_64/group            FAILED                                                                           ] 1.4 MB/s | 9.9 MB00:01:09 ETA
https://repo.jing.rocks/fedora-buffet/archive/epel/7/x86_64/repodata/9cfdefede5c3cf769a448c2a7d0a6441d6dbd7ba215833153a284c50c76faa56-comps-Everything.x86_64.xml: curl#7 - "Failed to connect to 240b:10:f00:1b00::240: Network is unreachable"
正在尝试其它镜像。
epel/x86_64/filelists_db       FAILED                                          
https://repo.jing.rocks/fedora-buffet/archive/epel/7/x86_64/repodata/1e0f3b42efd8b5d54a6aa9feb1f03c7de2bb414b92268c3db5965bd38648b2da-filelists.sqlite.gz: curl#7 - "Failed to connect to 240b:10:f00:1b00::240: Network is unreachable"
正在尝试其它镜像。
(4/19): centos-sclo-rh/other_db                                                                                              | 1.6 MB00:00:02   
(5/19): epel/x86_64/prestodelta                                                                                              |592 B00:00:00   
base/7/x86_64/filelists_db   FAILED                                                                           ] 1.3 MB/s |16 MB00:01:10 ETA
http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/d6d94c7d406fe7ad4902a97104b39a0d8299451832a97f31d71653ba982c955b-filelists.sqlite.bz2: curl#56 - "Recv failure: Connection reset by peer"
正在尝试其它镜像。
base/7/x86_64/primary_db       FAILED                                          
http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/6d0c3a488c282fe537794b5946b01e28c7f44db79097bb06826e1c0c88bad5ef-primary.sqlite.bz2: curl#56 - "Recv failure: Connection reset by peer"
正在尝试其它镜像。
(6/19): extras/7/x86_64/filelists_db                                                                                       | 305 kB00:00:00   
(7/19): extras/7/x86_64/primary_db                                                                                           | 253 kB00:00:00   
(8/19): epel/x86_64/updateinfo                                                                                             | 1.0 MB00:00:05   
(9/19): extras/7/x86_64/other_db                                                                                             | 154 kB00:00:00   
(10/19): epel/x86_64/other_db                                                                                                | 4.1 MB00:00:02   
(11/19): centos-sclo-rh/filelists_db                                                                                       |12 MB00:00:17   
(12/19): updates/7/x86_64/filelists_db                                                                                       |15 MB00:00:15   
(13/19): epel/x86_64/group                                                                                                   | 399 kB00:00:00   
(14/19): updates/7/x86_64/other_db                                                                                           | 1.6 MB00:00:01   
(15/19): epel/x86_64/filelists_db                                                                                          |15 MB00:00:02   
(16/19): base/7/x86_64/primary_db                                                                                          | 6.1 MB00:00:06   
(17/19): base/7/x86_64/filelists_db                                                                                          | 7.2 MB00:00:07   
(18/19): updates/7/x86_64/primary_db                                                                                       |27 MB00:00:28   
(19/19): epel/x86_64/primary_db                                                                                              | 8.7 MB00:00:34   
元数据缓存已建立
#   5)运行 yum repolist all 检察yum软件仓库
# yum repolist all
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.cloud.aliyuncs.com
* epel: mirror.math.princeton.edu
* extras: mirrors.cloud.aliyuncs.com
* updates: mirrors.cloud.aliyuncs.com
源标识
base/7/x86_64                                        CentOS-7 - Base - mirrors.aliyun.com                                             启用: 10,072
base-debuginfo/x86_64                              CentOS-7 - Debuginfo                                                               禁用
base-source/7                                        CentOS-7 - Base Sources                                                            禁用
c7-media                                             CentOS-7 - Media                                                                   禁用
centos-kernel/7/x86_64                               CentOS LTS Kernels for x86_64                                                      禁用
centos-kernel-experimental/7/x86_64                  CentOS Experimental Kernels for x86_64                                             禁用
centos-sclo-rh                                       CentOS-7 - SCLo rh                                                               启用:8,170
centosplus/7/x86_64                                  CentOS-7 - Plus - mirrors.aliyun.com                                             禁用
centosplus-source/7                                  CentOS-7 - Plus Sources                                                            禁用
contrib/7/x86_64                                     CentOS-7 - Contrib - mirrors.aliyun.com                                          禁用
cr/7/x86_64                                          CentOS-7 - cr                                                                      禁用
epel/x86_64                                          Extra Packages for Enterprise Linux 7 - x86_64                                     启用: 13,791
epel-debuginfo/x86_64                              Extra Packages for Enterprise Linux 7 - x86_64 - Debug                           禁用
epel-source/x86_64                                 Extra Packages for Enterprise Linux 7 - x86_64 - Source                            禁用
epel-testing/x86_64                                  Extra Packages for Enterprise Linux 7 - Testing - x86_64                           禁用
epel-testing-debuginfo/x86_64                        Extra Packages for Enterprise Linux 7 - Testing - x86_64 - Debug                   禁用
epel-testing-source/x86_64                           Extra Packages for Enterprise Linux 7 - Testing - x86_64 - Source                  禁用
extras/7/x86_64                                    CentOS-7 - Extras - mirrors.aliyun.com                                             启用:    526
extras-source/7                                    CentOS-7 - Extras Sources                                                          禁用
fasttrack/7/x86_64                                 CentOS-7 - fasttrack                                                               禁用
updates/7/x86_64                                     CentOS-7 - Updates - mirrors.aliyun.com                                          启用:6,173
updates-source/7                                     CentOS-7 - Updates Sources                                                         禁用
repolist: 38,732   6)实行 yum install -y ntp 测试安装
# yum install -y ntp
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.cloud.aliyuncs.com
* epel: mirror.math.princeton.edu
* extras: mirrors.cloud.aliyuncs.com
* updates: mirrors.cloud.aliyuncs.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 ntp.x86_64.0.4.2.6p5-29.el7.centos.2 将被 安装
--> 正在处理依赖关系 ntpdate = 4.2.6p5-29.el7.centos.2,它被软件包 ntp-4.2.6p5-29.el7.centos.2.x86_64 需要
--> 正在处理依赖关系 libopts.so.25()(64bit),它被软件包 ntp-4.2.6p5-29.el7.centos.2.x86_64 需要
--> 正在检查事务
---> 软件包 autogen-libopts.x86_64.0.5.18-5.el7 将被 安装
---> 软件包 ntpdate.x86_64.0.4.2.6p5-29.el7.centos.2 将被 安装
--> 解决依赖关系完成

依赖关系解决

====================================================================================================================================================
Package                               架构                         版本                                           源                        大小
====================================================================================================================================================
正在安装:
ntp                                 x86_64                     4.2.6p5-29.el7.centos.2                        base                     549 k
为依赖而安装:
autogen-libopts                     x86_64                     5.18-5.el7                                     base                        66 k
ntpdate                               x86_64                     4.2.6p5-29.el7.centos.2                        base                        87 k

事务概要
====================================================================================================================================================
安装1 软件包 (+2 依赖软件包)

总下载量:701 k
安装大小:1.6 M
Downloading packages:
(1/3): autogen-libopts-5.18-5.el7.x86_64.rpm                                                                                 |66 kB00:00:00   
(2/3): ntpdate-4.2.6p5-29.el7.centos.2.x86_64.rpm                                                                            |87 kB00:00:00   
(3/3): ntp-4.2.6p5-29.el7.centos.2.x86_64.rpm                                                                              | 549 kB00:00:00   
----------------------------------------------------------------------------------------------------------------------------------------------------
总计                                                                                                                929 kB/s | 701 kB00:00:00   
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装    : autogen-libopts-5.18-5.el7.x86_64                                                                                             1/3
正在安装    : ntpdate-4.2.6p5-29.el7.centos.2.x86_64                                                                                          2/3
正在安装    : ntp-4.2.6p5-29.el7.centos.2.x86_64                                                                                              3/3
验证中      : ntpdate-4.2.6p5-29.el7.centos.2.x86_64                                                                                          1/3
验证中      : ntp-4.2.6p5-29.el7.centos.2.x86_64                                                                                              2/3
验证中      : autogen-libopts-5.18-5.el7.x86_64                                                                                             3/3

已安装:
ntp.x86_64 0:4.2.6p5-29.el7.centos.2                                                                                                            

作为依赖被安装:
autogen-libopts.x86_64 0:5.18-5.el7                                    ntpdate.x86_64 0:4.2.6p5-29.el7.centos.2                                 

完毕!
#

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页: [1]
查看完整版本: CentOS 7设置网络yum源(阿里)超详细步调