Rocky Linux 更换 阿里云的镜像源

  1. 备份原有的*.repo文件
csharp 复制代码
 mkdir /etc/yum.repos.d/bak
 mv /etc/yum.repos.d/*.repo  /etc/yum.repos.d/bak
  1. 创建阿里云镜像仓库
csharp 复制代码
sudo tee /etc/yum.repos.d/rocky-aliyun.repo > /dev/null <<'EOF'
[baseos]
name=Rocky Linux $releasever - BaseOS - Aliyun
baseurl=https://mirrors.aliyun.com/rockylinux/$releasever/BaseOS/$basearch/os/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial

[appstream]
name=Rocky Linux $releasever - AppStream - Aliyun
baseurl=https://mirrors.aliyun.com/rockylinux/$releasever/AppStream/$basearch/os/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial

[extras]
name=Rocky Linux $releasever - Extras - Aliyun
baseurl=https://mirrors.aliyun.com/rockylinux/$releasever/extras/$basearch/os/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial

[crb]
name=Rocky Linux $releasever - CRB - Aliyun
baseurl=https://mirrors.aliyun.com/rockylinux/$releasever/CRB/$basearch/os/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial
EOF

清理缓存

csharp 复制代码
dnf clean all

缓存仓库信息

csharp 复制代码
dnf makecache
  1. 安装软件测试
csharp 复制代码
[root@redis-slave01 yum.repos.d]# time dnf -y install nginx
Last metadata expiration check: 0:01:18 ago on Thu Apr 16 17:12:45 2026.
Dependencies resolved.
=============================================================================================================================================================================
 Package                                    Architecture                    Version                                                 Repository                          Size
=============================================================================================================================================================================
Installing:
 nginx                                      x86_64                          2:1.20.1-24.el9_7.2.rocky.0.1                           appstream                           37 k
Installing dependencies:
 nginx-core                                 x86_64                          2:1.20.1-24.el9_7.2.rocky.0.1                           appstream                          567 k
 nginx-filesystem                           noarch                          2:1.20.1-24.el9_7.2.rocky.0.1                           appstream                           10 k
 rocky-logos-httpd                          noarch                          90.16-1.el9                                             appstream                           24 k

Transaction Summary
=============================================================================================================================================================================
Install  4 Packages

Total download size: 638 k
Installed size: 1.8 M
Downloading Packages:
(1/4): nginx-filesystem-1.20.1-24.el9_7.2.rocky.0.1.noarch.rpm                                                                                59 kB/s |  10 kB     00:00
(2/4): nginx-1.20.1-24.el9_7.2.rocky.0.1.x86_64.rpm                                                                                          161 kB/s |  37 kB     00:00
(3/4): rocky-logos-httpd-90.16-1.el9.noarch.rpm                                                                                              167 kB/s |  24 kB     00:00
(4/4): nginx-core-1.20.1-24.el9_7.2.rocky.0.1.x86_64.rpm                                                                                     278 kB/s | 567 kB     00:02
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                        312 kB/s | 638 kB     00:02
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                     1/1
  Running scriptlet: nginx-filesystem-2:1.20.1-24.el9_7.2.rocky.0.1.noarch                                                                                               1/4
  Installing       : nginx-filesystem-2:1.20.1-24.el9_7.2.rocky.0.1.noarch                                                                                               1/4
  Installing       : nginx-core-2:1.20.1-24.el9_7.2.rocky.0.1.x86_64                                                                                                     2/4
  Installing       : rocky-logos-httpd-90.16-1.el9.noarch                                                                                                                3/4
  Installing       : nginx-2:1.20.1-24.el9_7.2.rocky.0.1.x86_64                                                                                                          4/4
  Running scriptlet: nginx-2:1.20.1-24.el9_7.2.rocky.0.1.x86_64                                                                                                          4/4
  Verifying        : nginx-2:1.20.1-24.el9_7.2.rocky.0.1.x86_64                                                                                                          1/4
  Verifying        : nginx-core-2:1.20.1-24.el9_7.2.rocky.0.1.x86_64                                                                                                     2/4
  Verifying        : nginx-filesystem-2:1.20.1-24.el9_7.2.rocky.0.1.noarch                                                                                               3/4
  Verifying        : rocky-logos-httpd-90.16-1.el9.noarch                                                                                                                4/4

Installed:
  nginx-2:1.20.1-24.el9_7.2.rocky.0.1.x86_64          nginx-core-2:1.20.1-24.el9_7.2.rocky.0.1.x86_64          nginx-filesystem-2:1.20.1-24.el9_7.2.rocky.0.1.noarch
  rocky-logos-httpd-90.16-1.el9.noarch

Complete!

real    0m2.951s
user    0m0.487s
sys     0m0.219s

可以看出安装速度非常快。

相关推荐
皓月盈江4 小时前
Hexo博客Butterfly5.7.0主题网站信息:本站访客数和本站总浏览量的数据一直加载不显示的解决方法
linux·hexo·butterfly·busuanzi·vercount·本站访客数·本站总浏览量
程序猿老A4 小时前
云服务器怎么配置视频存储?
运维·服务器·音视频
H.莓飛4 小时前
【数据结构】堆_OJ题
linux·数据结构·算法
程序员老陆4 小时前
Docker 命令全景指南:从镜像构建到生产运维
运维·docker·容器
硅基手札4 小时前
【linux内核专栏 09】内核模块与 kbuild
linux·架构
流浪0014 小时前
Linux系统篇43——线程(八) 线程的数据不一致问题,从 ticket-- 的非原子性说起
linux·操作系统·线程·线程安全·锁
Είναι η κοπέλα5 小时前
WSL2 部署 AI 开发环境:内核级 Linux + GPU 直通
linux·运维·人工智能
其实防守也摸鱼5 小时前
网安自测题:掌握核心知识点的实用练习
linux·运维·服务器·前端·数据库·sql·xss
木白CPP5 小时前
[QNX] 深入理解 Resource Manager 接口设计
linux·服务器·数据库
AlfredZhao5 小时前
别再 rm 日志了:Linux 下安全清空日志文件的正确姿势
linux