219ca4d7-cb7b-8062-a07b-c6f6d0e3fa本指南将帮助你配置 CentOS Stream 9 使用阿里云的镜像源,以加速软件包的下载和安装。 操作步骤: 重新编辑 .repo 文件: 打开 CentOS Stream 9 的软件仓库配置文件。
sudo vi /etc/yum.repos.d/CentOS-Stream.repo
粘贴并覆盖配置: 将以下修正后的配置粘贴到打开的文件中,覆盖原有内容并保存。
[baseos]
name=CentOS Stream 9 - BaseOS
baseurl=https://mirrors.aliyun.com/centos-stream/9-stream/BaseOS/x86_64/os/
enabled=1
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos-stream/RPM-GPG-KEY-CentOS-Official
[appstream]
name=CentOS Stream 9 - AppStream
baseurl=https://mirrors.aliyun.com/centos-stream/9-stream/AppStream/x86_64/os/
enabled=1
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos-stream/RPM-GPG-KEY-CentOS-Official
更新缓存:
清理旧的缓存并创建新的缓存。
sudo dnf clean all
sudo dnf makecache
验证仓库是否可用:
列出当前系统启用的软件仓库,确认阿里源已成功添加。
sudo dnf repolist
其他常用操作
查看仓库信息:
查看已配置仓库的详细信息。
sudo dnf repoinfo
安装 EPEL 仓库:
EPEL (Extra Packages for Enterprise Linux) 仓库提供了额外的软件包。
sudo dnf install epel-release
禁用 GPG 检查 (不推荐):
你可以通过修改 /etc/dnf/dnf.conf 文件禁用 GPG 签名检查。强烈建议不要禁用 GPG 检查,以确保软件包的安全性。
gpgcheck=0
导入 CentOS 官方 GPG Key (如果禁用 GPG 检查):
如果确实需要禁用 GPG 检查,可以尝试导入 CentOS 官方的 GPG Key。同样不推荐此操作。
sudo rpm --importhttp://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-Official
请注意,禁用 GPG 检查会降低系统的安全性。建议始终启用 GPG 检查,以验证软件包的完整性和来源。