centos8.5.2111更换yum源
时间: 2023-11-11 18:58:48 浏览: 232
要更换 CentOS 8.5.2111 的 yum 源,可以按照以下步骤进行操作:
1. 打开终端,使用 root 权限登录。
2. 备份原始的 yum 源文件,以防止操作不当造成问题:
```
cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
```
3. 使用编辑器(如 vi 或 nano)打开 yum 源文件:
```
vi /etc/yum.repos.d/CentOS-Base.repo
```
4. 注释掉原始的镜像源配置,将其内容修改为如下所示:
```bash
[BaseOS]
name=CentOS-$releasever - Base
baseurl=https://mirrors.cloud.tencent.com/centos/$releasever/BaseOS/$basearch/os/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
#released updates
[AppStream]
name=CentOS-$releasever - AppStream
baseurl=https://mirrors.cloud.tencent.com/centos/$releasever/AppStream/$basearch/os/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
#additional packages that may be useful
[Extras]
name=CentOS-$releasever - Extras
baseurl=https://mirrors.cloud.tencent.com/centos/$releasever/Extras/$basearch/os/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
#additional packages that extend functionality of existing packages
[PowerTools]
name=CentOS-$releasever - PowerTools
baseurl=https://mirrors.cloud.tencent.com/centos/$releasever/PowerTools/$basearch/os/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
#contrib - packages by Centos Users
[Contrib]
name=CentOS-$releasever - Contrib
baseurl=https://mirrors.cloud.tencent.com/centos/$releasever/Contrib/$basearch/os/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
```
这里使用了腾讯云的镜像源,你也可以选择其他可靠的源。
5. 保存并关闭文件。
6. 清除缓存并生成新的缓存:
```
yum clean all
yum makecache
```
7. 完成后,你应该已经成功更换了 CentOS 的 yum 源。
阅读全文