上一篇 分享链接 返回 返回顶部

CentOS系统yum换源

发布人:破云 - 小叮当 发布时间:2024-06-17 05:02 阅读量:624

1、备份默认的repo文件

# cd /etc/yum.repos.d/
# mkdir backup
# mv *.repo backup/

 

2、更换为阿里云的yum源

创建一个新的repo文件,把所有配置都放在同一个文件

# touch Aliyun-Centos-Stream-8.repo
# vim Aliyun-Centos-Stream-8.repo

把以下配置拷贝到Aliyun-Centos-Stream-8.repo文件并保存

[BaseOS]
name=BaseOS
baseurl=https://mirrors.aliyun.com/centos/8-stream/BaseOS/x86_64/os/
enabled=1
gpgcheck=0

[Appstream]
name=Appstream
baseurl=https://mirrors.aliyun.com/centos/8-stream/AppStream/x86_64/os/
enabled=1
gpgcheck=0

[Extras]
name=Extras
baseurl=https://mirrors.aliyun.com/centos/8-stream/extras/x86_64/os/
enabled=1
gpgcheck=0

[PowerTools]
name=PowerTools
baseurl=https://mirrors.aliyun.com/centos/8-stream/PowerTools/x86_64/os/
enabled=1
gpgcheck=0

清理原本的yum软件源列表

# yum clean all

更新新的yum软件源列表

# yum makecache

 

3、更换为163的yum源

创建新文件163-Centos-Stream-8.repo

# touch 163-Centos-Stream-8.repo

把以下配置拷贝到163-Centos-Stream-8.repo

[BaseOS]
name=BaseOS
baseurl=https://mirrors.163.com/centos/8-stream/BaseOS/x86_64/os/
enabled=1
gpgcheck=0

[Appstream]
name=Appstream
baseurl=https://mirrors.163.com/centos/8-stream/AppStream/x86_64/os/
enabled=1
gpgcheck=0

[Extras]
name=Extras
baseurl=https://mirrors.163.com/centos/8-stream/extras/x86_64/os/
enabled=1
gpgcheck=0

[PowerTools]
name=PowerTools
baseurl=https://mirrors.163.com/centos/8-stream/PowerTools/x86_64/os/
enabled=1
gpgcheck=0

之后清理并更新yum软件源列表

4、更换为华为云的yum源

创建新文件huaweiyun-Centos-Stream-8.repo

# touch huaweiyun-Centos-Stream-8.repo

把以下配置拷贝到huaweiyun-Centos-Stream-8.repo

[BaseOS]
name=BaseOS
baseurl=https://repo.huaweicloud.com/centos/8-stream/BaseOS/x86_64/os/
enabled=1
gpgcheck=0

[Appstream]
name=Appstream
baseurl=https://repo.huaweicloud.com/centos/8-stream/AppStream/x86_64/os/
enabled=1
gpgcheck=0

[Extras]
name=Extras
baseurl=https://repo.huaweicloud.com/centos/8-stream/extras/x86_64/os/
enabled=1
gpgcheck=0

[PowerTools]
name=PowerTools
baseurl=https://repo.huaweicloud.com/centos/8-stream/PowerTools/x86_64/os/
enabled=1
gpgcheck=0

之后清理并更新yum软件源列表

5、更换为清华大学的yum源

创建新文件tsinghua-Centos-Stream-8.repo

把以下配置拷贝到tsinghua-Centos-Stream-8.repo

[BaseOS]
name=BaseOS
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/8-stream/BaseOS/x86_64/os/
enabled=1
gpgcheck=0

[Appstream]
name=Appstream
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/8-stream/AppStream/x86_64/os/
enabled=1
gpgcheck=0

[Extras]
name=Extras
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/8-stream/extras/x86_64/os/
enabled=1
gpgcheck=0

[PowerTools]
name=PowerTools
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/8-stream/PowerTools/x86_64/os/
enabled=1
gpgcheck=0

之后清理并更新yum软件源列表

目录结构
全文