centos stream 9更换国内yum源
时间: 2025-01-22 07:13:28 浏览: 84
### 更改 CentOS Stream 9 的 YUM 源至国内源
为了提高软件包下载速度和稳定性,在 CentOS Stream 9 上配置国内 YUM 源是一个常见的优化措施。以下是具体的操作流程:
#### 备份原始配置文件
建议先备份现有的 `yum` 配置文件,以防出现问题时可以恢复默认设置。
```bash
sudo cp /etc/yum.repos.d/CentOS-Stream.repo /etc/yum.repos.d/CentOS-Stream.repo.bak
```
#### 修改或替换为阿里云源为例
编辑 `/etc/yum.repos.d/CentOS-Stream.repo` 文件,将其内容更改为如下所示[^1]:
```ini
[baseos]
name=CentOS-$releasever - BaseOS
mirrorlist=https://mirrors.aliyun.com/centos/$stream/BaseOS/x86_64/os/
gpgcheck=1
enabled=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-centosofficial
[appstream]
name=CentOS-$releasever - AppStream
mirrorlist=https://mirrors.aliyun.com/centos/$stream/AppStream/x86_64/os/
gpgcheck=1
enabled=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-KEY-centosofficial
```
#### 清除缓存并重建数据库
完成上述更改之后,清除旧的元数据缓存,并重新构建新的缓存以使修改生效。
```bash
sudo yum clean all
sudo yum makecache
```
这样就完成了将 CentOS Stream 9 默认源切换到阿里云国内镜像站的过程。这不仅加快了依赖项解析的速度,也提高了整体系统的响应效率。
阅读全文
相关推荐


















