centos 8 换源
centos 8 换源
进入 root,切换至 yum.repos.d 目录
cd /etc/yum.repos.d/
创建新文件夹并将源文件备份为 repo.bak
mkdir backup && mv *repo backup/
下载国内 yum 源文件
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
更新下载yum源地址
sed -i -e"s|mirrors.cloud.aliyuncs.com|mirrors.aliyun.com|g " /etc/yum.repos.d/CentOS-*;sed -i -e "s|releasever|releasever-stream|g" /etc/yum.repos.d/CentOS-*
生成缓存
yum clean all && yum makecache
第二种:
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