AlmaLinux yum/dnf repo/mirrors 国内镜像列表及更换方法

AlmaLinux Mirrors | 官方镜像列表 | 国内镜像列表及更换方法

Posted by sysin on 2024-06-15
Estimated Reading Time 4 Minutes
Words 856 In Total
更新日期:2024-06-15 13:12:16,阅读量:

请访问原文链接:AlmaLinux yum/dnf repo/mirrors 国内镜像列表及更换方法 查看最新版。原创作品,转载请保留出处。

作者主页:sysin.org


almalinux-logo

高校镜像推荐 mirror.sjtu.edu.cnmirrors.zju.edu.cn
商业公司镜像推荐 mirrors.aliyun.com
其他多数镜像不全,要么没有 almalinux,要么没有 rocky。
当然可以根据个人喜好、地理位置、访问体验等因素来选择。

AlmaLinux

该项配置方法兼容 AlmaLinux 8、9 和 10。

AlmaLinux 9 默认 repo 如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
[root@localhost ~]# dnf repolist
repo id repo name
appstream AlmaLinux 9 - AppStream
baseos AlmaLinux 9 - BaseOS
extras AlmaLinux 9 - Extras
# 安装 epel 后增加
epel Extra Packages for Enterprise Linux 9 - x86_64

# 文件列表如下
[root@localhost ~]# ll /etc/yum.repos.d/
almalinux-appstream.repo
almalinux-baseos.repo
almalinux-crb.repo
almalinux-extras.repo
almalinux-highavailability.repo
almalinux-nfv.repo
almalinux-plus.repo
almalinux-resilientstorage.repo
almalinux-rt.repo
almalinux-sap.repo
almalinux-saphana.repo
epel-testing.repo
epel.repo

官方镜像列表

官方列表:https://mirrors.almalinux.org/,CN 开头的站点。

例如:

NameSponsorStatusContinentRegionFTPHTTPHTTPSRSYNCIPv6
mirrors.aliyun.comAlibaba Cloud Computing Co.,Ltd.okAsiaCNMirrorMirror
mirror.sjtu.edu.cnShanghai Jiao Tong University Network Information CenterexpiredASCNMirror

基本系统

AlmaLinux 国内镜像源更换方法如下。

阿里云示例(本次模板使用):

1
2
3
4
5
6
7
8
9
10
11
12
# 配置
# 注意:“# baseurl” 中间有个空格(AlmaLinux 专有)
sed -e 's|^mirrorlist=|#mirrorlist=|g' \
-e 's|^# baseurl=https://repo.almalinux.org|baseurl=https://mirrors.aliyun.com|g' \
-i.bak \
/etc/yum.repos.d/almalinux*.repo

# 恢复 (sysin)
sed -e 's|^#mirrorlist=|mirrorlist=|g' \
-e 's|^baseurl=https://mirrors.aliyun.com|# baseurl=https://repo.almalinux.org|g' \
-i.bak \
/etc/yum.repos.d/almalinux*.repo

上海交通大学示例(mirror 没有 s):

mirror.sjtu.edu.cn = mirrors.sjtug.sjtu.edu.cn

1
2
3
4
5
6
7
8
9
10
11
12
# 配置
# 注意:“# baseurl” 中间有个空格(AlmaLinux 专有)
sed -e 's|^mirrorlist=|#mirrorlist=|g' \
-e 's|^# baseurl=https://repo.almalinux.org|baseurl=https://mirror.sjtu.edu.cn|g' \
-i.bak \
/etc/yum.repos.d/almalinux*.repo

# 恢复 (sysin)
sed -e 's|^#mirrorlist=|mirrorlist=|g' \
-e 's|^baseurl=https://mirror.sjtu.edu.cn|# baseurl=https://repo.almalinux.org|g' \
-i.bak \
/etc/yum.repos.d/almalinux*.repo

更换其他镜像,对应按照上面替换 Mirror Name 即可。

例如:

EPEL

若安装了 epel,同时修改如下:

阿里云 epel 示例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
sed -e 's|^metalink=|#metalink=|g' \
-e 's|^#baseurl=https://download.example/pub|baseurl=https://mirrors.aliyun.com|g' \
-e 's|^#baseurl=https://download.fedoraproject.org/pub|baseurl=https://mirrors.aliyun.com|g' \
-i.bak \
/etc/yum.repos.d/epel*.repo
# 注意 (sysin):
# CentOS 8、AlmaLinux 9 与 Rocky Linux 8/9 中 #baseurl=https://download.example/pub
# 而 AlmaLinux 8 早期版本是:#baseurl=https://download.fedoraproject.org/pub
# 故增加一句上述地址的替换

# 恢复
sed -e 's|^#metalink=|metalink=|g' \
-e 's|^baseurl=https://mirrors.aliyun.com|#baseurl=https://download.example/pub|g' \
-i.bak \
/etc/yum.repos.d/epel*.repo

上海交通大学 epel 示例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 注意 (sysin):上海交通大学地址多一个 fedora
sed -e 's|^metalink=|#metalink=|g' \
-e 's|^#baseurl=https://download.example/pub|baseurl=https://mirror.sjtu.edu.cn/fedora|g' \
-e 's|^#baseurl=https://download.fedoraproject.org/pub|baseurl=https://mirror.sjtu.edu.cn/fedora|g' \
-i.bak \
/etc/yum.repos.d/epel*.repo
# 注意 (sysin):
# CentOS 8、AlmaLinux 9 与 Rocky Linux 8/9 中 #baseurl=https://download.example/pub
# 而 AlmaLinux 8 早期版本是:#baseurl=https://download.fedoraproject.org/pub
# 故增加一句上述地址的替换

# 恢复
sed -e 's|^#metalink=|metalink=|g' \
-e 's|^baseurl=https://mirror.sjtu.edu.cn/fedora|#baseurl=https://download.example/pub|g' \
-i.bak \
/etc/yum.repos.d/epel*.repo

其他替换地址如:

清理并重新生成软件包信息缓存

1
2
3
4
5
# 备注:yum=dnf
yum clean all
rm -rf /var/cache/yum
yum makecache
#yum autoremove #此命令需要已经 makecache

更多:Linux 产品链接汇总


捐助本站 ❤️ Donate

点击访问官方网站


文章用于推荐和分享优秀的软件产品及其相关技术,所有软件默认提供官方原版(免费版或试用版),免费分享。对于部分产品笔者加入了自己的理解和分析,方便学习和研究使用。任何内容若侵犯了您的版权,请联系作者删除。如果您喜欢这篇文章或者觉得它对您有所帮助,或者发现有不当之处,欢迎您发表评论,也欢迎您分享这个网站,或者赞赏一下作者,谢谢!

支付宝赞赏 微信赞赏

赞赏一下


☑️ 尊敬的读者,欢迎留言❗️
敬请注册!点击 “登录” - “用户注册”(已知不支持 21.cn/189.cn 邮箱)。 请勿使用联合登录(已关闭)