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

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

相关推荐
斯班奇的好朋友阿法法7 小时前
中科方德(NFSChina)离线安装 RPM 包
运维
milo.qu8 小时前
RockyLinux9.7 docker部署Jisti Meet
linux·docker·容器
GanGanGanGan_8 小时前
CentOS 7.9 glibc 2.17 源码编译升级到 glibc 2.31
linux·运维·centos·glibc
charlie1145141918 小时前
嵌入式Linux驱动开发——class 和 device 模型 - 自动创建设备节点的幕后机制
linux·运维·驱动开发
杨云龙UP10 小时前
SQL Server2022部署:Windows Server 2016下安装、SSMS配置、备份还原与1433端口放通全流程_20260508
运维·服务器·数据库·sql·sqlserver·2022
梦想与想象-广州大智汇10 小时前
自建docker加速镜像,使用 Cloudflare Workers/Pages 部署加速教程
运维·docker·容器
枳实-叶10 小时前
【Linux驱动开发】第四天:dmesg日志全解+驱动加载失败极速排查
linux·运维·驱动开发
武超杰10 小时前
Nginx从入门到精通
运维·nginx
wdfk_prog11 小时前
正常关闭虚拟机时,不要点“关机”,而要点“关闭客户机”
linux·c语言·网络·ide·vscode
weixin_7042660511 小时前
Nginx 反向代理 + 6 种负载均衡策略
运维·nginx