centos9 yum 清华源
时间: 2025-02-02 22:02:17 浏览: 99
### 配置 CentOS 9 的 YUM 使用清华大学镜像源
对于 CentOS 9 来说,配置 YUM 使用清华大学镜像源涉及修改特定的仓库配置文件。具体操作如下:
#### 修改 BaseOS 和 AppStream 源
需要编辑 `/etc/yum.repos.d/CentOS-Linux-BaseOS.repo` 文件以及 `/etc/yum.repos.d/CentOS-Linux-AppStream.repo` 文件,在这些文件中找到 `baseurl` 字段并将其更改为指向清华大学的镜像地址。
针对 **BaseOS** 库:
```ini
[BaseOS]
name=CentOS Linux $releasever - BaseOS
mirrorlist=
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/BaseOS/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
```
针对 **AppStream** 库:
```ini
[AppStream]
name=CentOS Linux $releasever - AppStream
mirrorlist=
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/AppStream/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
```
上述更改确保了系统能够从清华大学提供的稳定服务器获取软件包更新[^1]。
#### 更新 EPEL 源 (如果已安装)
如果有额外启用扩展库的需求,则可以按照相同的方式调整EPEL源设置。通过下载最新的EPEL配置文件来实现这一点,使用curl工具可以直接完成此过程:
```bash
sudo curl -o /etc/yum.repos.d/epel.repo https://mirrors.tuna.tsinghua.edu.cn/epel/epel-release-latest-9.noarch.rpm
```
这一步骤会将默认的EPEL源替换为清华大学维护的一个版本[^2]。
最后建议执行一次完整的缓存清理与同步操作以应用新的配置变更:
```bash
sudo yum clean all && sudo yum makecache
```
这样就完成了整个切换至清华大学YUM源的过程。
阅读全文
相关推荐

















