CentOS系统yum换源
技术教程 2024-06-17 05:00 1428

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软件源列表

标签:

  • 换源
  • yum
  • linux
  • Linux
  • centos
  • CentOS
Powered by ©智简魔方