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

打印 上一主题 下一主题

主题 1946|帖子 1946|积分 5838

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

x
步调1、备份yum源文件
    1)进入/etc/yum.repos.d/目次,检察是否yum源文件是否存在。
  1. [root@localhost /]# cd /etc/yum.repos.d/
  2. [root@localhost yum.repos.d]# ll
  3. 总用量 60
  4. -rw-------. 1 root root 2523 7月  30 2024 CentOS-Base.repo
  5. -rw-r--r--. 1 root root 1309 5月  21 2024 CentOS-CR.repo
  6. -rw-r--r--. 1 root root  649 5月  21 2024 CentOS-Debuginfo.repo
  7. -rw-r--r--. 1 root root  314 5月  21 2024 CentOS-fasttrack.repo
  8. -rw-r--r--. 1 root root  630 5月  21 2024 CentOS-Media.repo
  9. -rw-r--r--. 1 root root  998 12月 11 2018 CentOS-SCLo-scl.repo.bak
  10. -rw-r--r--. 1 root root  181 7月  31 2024 CentOS-SCLo-scl-rh.repo
  11. -rw-r--r--. 1 root root 1159 7月  31 2024 CentOS-SCLo-scl-rh.repo.bak
  12. -rw-r--r--. 1 root root 1331 5月  21 2024 CentOS-Sources.repo
  13. -rw-r--r--. 1 root root 9454 5月  21 2024 CentOS-Vault.repo
  14. -rw-r--r--. 1 root root  616 5月  21 2024 CentOS-x86_64-kernel.repo
  15. -rw-r--r--. 1 root root 1358 9月   5 2021 epel.repo
  16. -rw-r--r--. 1 root root 1457 9月   5 2021 epel-testing.repo
复制代码
  2)实行mv CentOS-Base.repo CentOS-Base.repo.bak 将原始yum源文件备份至本目次下。
  1. [root@localhost yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.bak
  2. [root@localhost yum.repos.d]# ll
  3. 总用量 60
  4. -rw-------. 1 root root 2523 7月  30 2024 CentOS-Base.repo.bak
  5. -rw-r--r--. 1 root root 1309 5月  21 2024 CentOS-CR.repo
  6. -rw-r--r--. 1 root root  649 5月  21 2024 CentOS-Debuginfo.repo
  7. -rw-r--r--. 1 root root  314 5月  21 2024 CentOS-fasttrack.repo
  8. -rw-r--r--. 1 root root  630 5月  21 2024 CentOS-Media.repo
  9. -rw-r--r--. 1 root root  998 12月 11 2018 CentOS-SCLo-scl.repo.bak
  10. -rw-r--r--. 1 root root  181 7月  31 2024 CentOS-SCLo-scl-rh.repo
  11. -rw-r--r--. 1 root root 1159 7月  31 2024 CentOS-SCLo-scl-rh.repo.bak
  12. -rw-r--r--. 1 root root 1331 5月  21 2024 CentOS-Sources.repo
  13. -rw-r--r--. 1 root root 9454 5月  21 2024 CentOS-Vault.repo
  14. -rw-r--r--. 1 root root  616 5月  21 2024 CentOS-x86_64-kernel.repo
  15. -rw-r--r--. 1 root root 1358 9月   5 2021 epel.repo
  16. -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/下。
  1. [root@localhost yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
  2. --2025-02-18 15:31:35--  http://mirrors.aliyun.com/repo/Centos-7.repo
  3. 正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 116.196.140.238, 116.196.140.235, 116.196.140.231, ...
  4. 正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|116.196.140.238|:80... 已连接。
  5. 已发出 HTTP 请求,正在等待回应... 200 OK
  6. 长度:2523 (2.5K) [application/octet-stream]
  7. 正在保存至: “/etc/yum.repos.d/CentOS-Base.repo”
  8. 100%[==========================================================================================================>] 2,523       --.-K/s 用时 0s      
  9. 2025-02-18 15:31:35 (74.1 MB/s) - 已保存 “/etc/yum.repos.d/CentOS-Base.repo” [2523/2523])
  10. [root@localhost yum.repos.d]#
复制代码
  2)检察/etc/yum.repos.d/目次下新下载的文件
  1. [root@localhost yum.repos.d]# ll
  2. 总用量 64
  3. -rw-r--r--  1 root root 2523 8月   4 2022 CentOS-Base.repo
  4. -rw-------. 1 root root 2523 7月  30 2024 CentOS-Base.repo.bak
  5. -rw-r--r--. 1 root root 1309 5月  21 2024 CentOS-CR.repo
  6. -rw-r--r--. 1 root root  649 5月  21 2024 CentOS-Debuginfo.repo
  7. -rw-r--r--. 1 root root  314 5月  21 2024 CentOS-fasttrack.repo
  8. -rw-r--r--. 1 root root  630 5月  21 2024 CentOS-Media.repo
  9. -rw-r--r--. 1 root root  998 12月 11 2018 CentOS-SCLo-scl.repo.bak
  10. -rw-r--r--. 1 root root  181 7月  31 2024 CentOS-SCLo-scl-rh.repo
  11. -rw-r--r--. 1 root root 1159 7月  31 2024 CentOS-SCLo-scl-rh.repo.bak
  12. -rw-r--r--. 1 root root 1331 5月  21 2024 CentOS-Sources.repo
  13. -rw-r--r--. 1 root root 9454 5月  21 2024 CentOS-Vault.repo
  14. -rw-r--r--. 1 root root  616 5月  21 2024 CentOS-x86_64-kernel.repo
  15. -rw-r--r--. 1 root root 1358 9月   5 2021 epel.repo
  16. -rw-r--r--. 1 root root 1457 9月   5 2021 epel-testing.repo
复制代码
  3)运行 yum clean all 扫除缓存
  1. [root@localhost yum.repos.d]# yum clean all
  2. 已加载插件:fastestmirror
  3. 正在清理软件源: base centos-sclo-rh epel extras updates
  4. Cleaning up list of fastest mirrors
复制代码
  4)运行 yum makecache 生成新的缓存
  1. [root@localhost yum.repos.d]# yum makecache
  2. 已加载插件:fastestmirror
  3. Determining fastest mirrors
  4. epel/x86_64/metalink                                                                                                         | 5.1 kB  00:00:00     
  5. * base: mirrors.cloud.aliyuncs.com
  6. * epel: mirror.math.princeton.edu
  7. * extras: mirrors.cloud.aliyuncs.com
  8. * updates: mirrors.cloud.aliyuncs.com
  9. base                                                                                                                         | 3.6 kB  00:00:00     
  10. centos-sclo-rh                                                                                                               | 3.0 kB  00:00:00     
  11. https://repo.jing.rocks/fedora-buffet/archive/epel/7/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed to connect to 240b:10:f00:1b00::240: 网络不可达"
  12. 正在尝试其它镜像。
  13. epel                                                                                                                         | 4.3 kB  00:00:00     
  14. extras                                                                                                                       | 2.9 kB  00:00:00     
  15. updates                                                                                                                      | 2.9 kB  00:00:00     
  16. (1/19): base/7/x86_64/group_gz                                                                                               | 153 kB  00:00:00     
  17. (2/19): base/7/x86_64/other_db                                                                                               | 2.6 MB  00:00:02     
  18. (3/19): centos-sclo-rh/primary_db                                                                                            | 3.4 MB  00:00:05     
  19. epel/x86_64/group              FAILED                                                                             ] 1.4 MB/s | 9.9 MB  00:01:09 ETA
  20. https://repo.jing.rocks/fedora-buffet/archive/epel/7/x86_64/repodata/9cfdefede5c3cf769a448c2a7d0a6441d6dbd7ba215833153a284c50c76faa56-comps-Everything.x86_64.xml: [Errno 14] curl#7 - "Failed to connect to 240b:10:f00:1b00::240: Network is unreachable"
  21. 正在尝试其它镜像。
  22. epel/x86_64/filelists_db       FAILED                                          
  23. https://repo.jing.rocks/fedora-buffet/archive/epel/7/x86_64/repodata/1e0f3b42efd8b5d54a6aa9feb1f03c7de2bb414b92268c3db5965bd38648b2da-filelists.sqlite.gz: [Errno 14] curl#7 - "Failed to connect to 240b:10:f00:1b00::240: Network is unreachable"
  24. 正在尝试其它镜像。
  25. (4/19): centos-sclo-rh/other_db                                                                                              | 1.6 MB  00:00:02     
  26. (5/19): epel/x86_64/prestodelta                                                                                              |  592 B  00:00:00     
  27. base/7/x86_64/filelists_db     FAILED                                                                             ] 1.3 MB/s |  16 MB  00:01:10 ETA
  28. http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/d6d94c7d406fe7ad4902a97104b39a0d8299451832a97f31d71653ba982c955b-filelists.sqlite.bz2: [Errno 14] curl#56 - "Recv failure: Connection reset by peer"
  29. 正在尝试其它镜像。
  30. base/7/x86_64/primary_db       FAILED                                          
  31. http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/6d0c3a488c282fe537794b5946b01e28c7f44db79097bb06826e1c0c88bad5ef-primary.sqlite.bz2: [Errno 14] curl#56 - "Recv failure: Connection reset by peer"
  32. 正在尝试其它镜像。
  33. (6/19): extras/7/x86_64/filelists_db                                                                                         | 305 kB  00:00:00     
  34. (7/19): extras/7/x86_64/primary_db                                                                                           | 253 kB  00:00:00     
  35. (8/19): epel/x86_64/updateinfo                                                                                               | 1.0 MB  00:00:05     
  36. (9/19): extras/7/x86_64/other_db                                                                                             | 154 kB  00:00:00     
  37. (10/19): epel/x86_64/other_db                                                                                                | 4.1 MB  00:00:02     
  38. (11/19): centos-sclo-rh/filelists_db                                                                                         |  12 MB  00:00:17     
  39. (12/19): updates/7/x86_64/filelists_db                                                                                       |  15 MB  00:00:15     
  40. (13/19): epel/x86_64/group                                                                                                   | 399 kB  00:00:00     
  41. (14/19): updates/7/x86_64/other_db                                                                                           | 1.6 MB  00:00:01     
  42. (15/19): epel/x86_64/filelists_db                                                                                            |  15 MB  00:00:02     
  43. (16/19): base/7/x86_64/primary_db                                                                                            | 6.1 MB  00:00:06     
  44. (17/19): base/7/x86_64/filelists_db                                                                                          | 7.2 MB  00:00:07     
  45. (18/19): updates/7/x86_64/primary_db                                                                                         |  27 MB  00:00:28     
  46. (19/19): epel/x86_64/primary_db                                                                                              | 8.7 MB  00:00:34     
  47. 元数据缓存已建立
  48. [root@localhost yum.repos.d]#
复制代码
  5)运行 yum repolist all 检察yum软件仓库
  1. [root@localhost yum.repos.d]# yum repolist all
  2. 已加载插件:fastestmirror
  3. Loading mirror speeds from cached hostfile
  4. * base: mirrors.cloud.aliyuncs.com
  5. * epel: mirror.math.princeton.edu
  6. * extras: mirrors.cloud.aliyuncs.com
  7. * updates: mirrors.cloud.aliyuncs.com
  8. 源标识
  9. base/7/x86_64                                        CentOS-7 - Base - mirrors.aliyun.com                                               启用: 10,072
  10. base-debuginfo/x86_64                                CentOS-7 - Debuginfo                                                               禁用
  11. base-source/7                                        CentOS-7 - Base Sources                                                            禁用
  12. c7-media                                             CentOS-7 - Media                                                                   禁用
  13. centos-kernel/7/x86_64                               CentOS LTS Kernels for x86_64                                                      禁用
  14. centos-kernel-experimental/7/x86_64                  CentOS Experimental Kernels for x86_64                                             禁用
  15. centos-sclo-rh                                       CentOS-7 - SCLo rh                                                                 启用:  8,170
  16. centosplus/7/x86_64                                  CentOS-7 - Plus - mirrors.aliyun.com                                               禁用
  17. centosplus-source/7                                  CentOS-7 - Plus Sources                                                            禁用
  18. contrib/7/x86_64                                     CentOS-7 - Contrib - mirrors.aliyun.com                                            禁用
  19. cr/7/x86_64                                          CentOS-7 - cr                                                                      禁用
  20. epel/x86_64                                          Extra Packages for Enterprise Linux 7 - x86_64                                     启用: 13,791
  21. epel-debuginfo/x86_64                                Extra Packages for Enterprise Linux 7 - x86_64 - Debug                             禁用
  22. epel-source/x86_64                                   Extra Packages for Enterprise Linux 7 - x86_64 - Source                            禁用
  23. epel-testing/x86_64                                  Extra Packages for Enterprise Linux 7 - Testing - x86_64                           禁用
  24. epel-testing-debuginfo/x86_64                        Extra Packages for Enterprise Linux 7 - Testing - x86_64 - Debug                   禁用
  25. epel-testing-source/x86_64                           Extra Packages for Enterprise Linux 7 - Testing - x86_64 - Source                  禁用
  26. extras/7/x86_64                                      CentOS-7 - Extras - mirrors.aliyun.com                                             启用:    526
  27. extras-source/7                                      CentOS-7 - Extras Sources                                                          禁用
  28. fasttrack/7/x86_64                                   CentOS-7 - fasttrack                                                               禁用
  29. updates/7/x86_64                                     CentOS-7 - Updates - mirrors.aliyun.com                                            启用:  6,173
  30. updates-source/7                                     CentOS-7 - Updates Sources                                                         禁用
  31. repolist: 38,732
复制代码
  6)实行 yum install -y ntp 测试安装
  1. [root@localhost yum.repos.d]# yum install -y ntp
  2. 已加载插件:fastestmirror
  3. Loading mirror speeds from cached hostfile
  4. * base: mirrors.cloud.aliyuncs.com
  5. * epel: mirror.math.princeton.edu
  6. * extras: mirrors.cloud.aliyuncs.com
  7. * updates: mirrors.cloud.aliyuncs.com
  8. 正在解决依赖关系
  9. --> 正在检查事务
  10. ---> 软件包 ntp.x86_64.0.4.2.6p5-29.el7.centos.2 将被 安装
  11. --> 正在处理依赖关系 ntpdate = 4.2.6p5-29.el7.centos.2,它被软件包 ntp-4.2.6p5-29.el7.centos.2.x86_64 需要
  12. --> 正在处理依赖关系 libopts.so.25()(64bit),它被软件包 ntp-4.2.6p5-29.el7.centos.2.x86_64 需要
  13. --> 正在检查事务
  14. ---> 软件包 autogen-libopts.x86_64.0.5.18-5.el7 将被 安装
  15. ---> 软件包 ntpdate.x86_64.0.4.2.6p5-29.el7.centos.2 将被 安装
  16. --> 解决依赖关系完成
  17. 依赖关系解决
  18. ====================================================================================================================================================
  19. Package                               架构                         版本                                           源                          大小
  20. ====================================================================================================================================================
  21. 正在安装:
  22. ntp                                   x86_64                       4.2.6p5-29.el7.centos.2                        base                       549 k
  23. 为依赖而安装:
  24. autogen-libopts                       x86_64                       5.18-5.el7                                     base                        66 k
  25. ntpdate                               x86_64                       4.2.6p5-29.el7.centos.2                        base                        87 k
  26. 事务概要
  27. ====================================================================================================================================================
  28. 安装  1 软件包 (+2 依赖软件包)
  29. 总下载量:701 k
  30. 安装大小:1.6 M
  31. Downloading packages:
  32. (1/3): autogen-libopts-5.18-5.el7.x86_64.rpm                                                                                 |  66 kB  00:00:00     
  33. (2/3): ntpdate-4.2.6p5-29.el7.centos.2.x86_64.rpm                                                                            |  87 kB  00:00:00     
  34. (3/3): ntp-4.2.6p5-29.el7.centos.2.x86_64.rpm                                                                                | 549 kB  00:00:00     
  35. ----------------------------------------------------------------------------------------------------------------------------------------------------
  36. 总计                                                                                                                929 kB/s | 701 kB  00:00:00     
  37. Running transaction check
  38. Running transaction test
  39. Transaction test succeeded
  40. Running transaction
  41.   正在安装    : autogen-libopts-5.18-5.el7.x86_64                                                                                               1/3
  42.   正在安装    : ntpdate-4.2.6p5-29.el7.centos.2.x86_64                                                                                          2/3
  43.   正在安装    : ntp-4.2.6p5-29.el7.centos.2.x86_64                                                                                              3/3
  44.   验证中      : ntpdate-4.2.6p5-29.el7.centos.2.x86_64                                                                                          1/3
  45.   验证中      : ntp-4.2.6p5-29.el7.centos.2.x86_64                                                                                              2/3
  46.   验证中      : autogen-libopts-5.18-5.el7.x86_64                                                                                               3/3
  47. 已安装:
  48.   ntp.x86_64 0:4.2.6p5-29.el7.centos.2                                                                                                              
  49. 作为依赖被安装:
  50.   autogen-libopts.x86_64 0:5.18-5.el7                                    ntpdate.x86_64 0:4.2.6p5-29.el7.centos.2                                   
  51. 完毕!
  52. [root@localhost yum.repos.d]#
复制代码


免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

自由的羽毛

论坛元老
这个人很懒什么都没写!
快速回复 返回顶部 返回列表