马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
x
步调1、备份yum源文件
1)进入/etc/yum.repos.d/目次,检察是否yum源文件是否存在。
- [root@localhost /]# cd /etc/yum.repos.d/
- [root@localhost 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 root 649 5月 21 2024 CentOS-Debuginfo.repo
- -rw-r--r--. 1 root root 314 5月 21 2024 CentOS-fasttrack.repo
- -rw-r--r--. 1 root root 630 5月 21 2024 CentOS-Media.repo
- -rw-r--r--. 1 root root 998 12月 11 2018 CentOS-SCLo-scl.repo.bak
- -rw-r--r--. 1 root root 181 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 root 616 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源文件备份至本目次下。
- [root@localhost yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.bak
- [root@localhost yum.repos.d]# 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 root 649 5月 21 2024 CentOS-Debuginfo.repo
- -rw-r--r--. 1 root root 314 5月 21 2024 CentOS-fasttrack.repo
- -rw-r--r--. 1 root root 630 5月 21 2024 CentOS-Media.repo
- -rw-r--r--. 1 root root 998 12月 11 2018 CentOS-SCLo-scl.repo.bak
- -rw-r--r--. 1 root root 181 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 root 616 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/下。
- [root@localhost 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) [application/octet-stream]
- 正在保存至: “/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” [2523/2523])
- [root@localhost yum.repos.d]#
复制代码 2)检察/etc/yum.repos.d/目次下新下载的文件
- [root@localhost 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 root 649 5月 21 2024 CentOS-Debuginfo.repo
- -rw-r--r--. 1 root root 314 5月 21 2024 CentOS-fasttrack.repo
- -rw-r--r--. 1 root root 630 5月 21 2024 CentOS-Media.repo
- -rw-r--r--. 1 root root 998 12月 11 2018 CentOS-SCLo-scl.repo.bak
- -rw-r--r--. 1 root root 181 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 root 616 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 扫除缓存
- [root@localhost yum.repos.d]# yum clean all
- 已加载插件:fastestmirror
- 正在清理软件源: base centos-sclo-rh epel extras updates
- Cleaning up list of fastest mirrors
复制代码 4)运行 yum makecache 生成新的缓存
- [root@localhost yum.repos.d]# yum makecache
- 已加载插件:fastestmirror
- Determining fastest mirrors
- epel/x86_64/metalink | 5.1 kB 00: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 kB 00:00:00
- centos-sclo-rh | 3.0 kB 00:00:00
- 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: 网络不可达"
- 正在尝试其它镜像。
- epel | 4.3 kB 00:00:00
- extras | 2.9 kB 00:00:00
- updates | 2.9 kB 00:00:00
- (1/19): base/7/x86_64/group_gz | 153 kB 00:00:00
- (2/19): base/7/x86_64/other_db | 2.6 MB 00:00:02
- (3/19): centos-sclo-rh/primary_db | 3.4 MB 00:00:05
- epel/x86_64/group FAILED ] 1.4 MB/s | 9.9 MB 00:01:09 ETA
- 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"
- 正在尝试其它镜像。
- epel/x86_64/filelists_db FAILED
- 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"
- 正在尝试其它镜像。
- (4/19): centos-sclo-rh/other_db | 1.6 MB 00:00:02
- (5/19): epel/x86_64/prestodelta | 592 B 00:00:00
- base/7/x86_64/filelists_db FAILED ] 1.3 MB/s | 16 MB 00:01:10 ETA
- 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"
- 正在尝试其它镜像。
- base/7/x86_64/primary_db FAILED
- http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/6d0c3a488c282fe537794b5946b01e28c7f44db79097bb06826e1c0c88bad5ef-primary.sqlite.bz2: [Errno 14] curl#56 - "Recv failure: Connection reset by peer"
- 正在尝试其它镜像。
- (6/19): extras/7/x86_64/filelists_db | 305 kB 00:00:00
- (7/19): extras/7/x86_64/primary_db | 253 kB 00:00:00
- (8/19): epel/x86_64/updateinfo | 1.0 MB 00:00:05
- (9/19): extras/7/x86_64/other_db | 154 kB 00:00:00
- (10/19): epel/x86_64/other_db | 4.1 MB 00:00:02
- (11/19): centos-sclo-rh/filelists_db | 12 MB 00:00:17
- (12/19): updates/7/x86_64/filelists_db | 15 MB 00:00:15
- (13/19): epel/x86_64/group | 399 kB 00:00:00
- (14/19): updates/7/x86_64/other_db | 1.6 MB 00:00:01
- (15/19): epel/x86_64/filelists_db | 15 MB 00:00:02
- (16/19): base/7/x86_64/primary_db | 6.1 MB 00:00:06
- (17/19): base/7/x86_64/filelists_db | 7.2 MB 00:00:07
- (18/19): updates/7/x86_64/primary_db | 27 MB 00:00:28
- (19/19): epel/x86_64/primary_db | 8.7 MB 00:00:34
- 元数据缓存已建立
- [root@localhost yum.repos.d]#
复制代码 5)运行 yum repolist all 检察yum软件仓库
- [root@localhost yum.repos.d]# 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 测试安装
- [root@localhost yum.repos.d]# 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 kB 00:00:00
- (2/3): ntpdate-4.2.6p5-29.el7.centos.2.x86_64.rpm | 87 kB 00:00:00
- (3/3): ntp-4.2.6p5-29.el7.centos.2.x86_64.rpm | 549 kB 00:00:00
- ----------------------------------------------------------------------------------------------------------------------------------------------------
- 总计 929 kB/s | 701 kB 00: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
- 完毕!
- [root@localhost yum.repos.d]#
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |