CentOS7.X/Stream 8 更换源的方法
CentOS 官方在 2024 年 6 月 30 日停止了对 CentOS 8 的更新和维护,这意味着它们将不再提供安全更新、软件更新或其他技术支持。
CentOS 7更换yum源命令:
首先备份你当前的yum源配置文件,以防需要恢复:
命令1:sudo cp -a /etc/yum.repos.d /etc/yum.repos.d.backup
清除原有的yum源配置文件:
命令2:sudo rm -f /etc/yum.repos.d/*.repo
下载(二选一)CentOS 7的yum源配置文件:
centos7命令(阿里源):curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
centos7命令(腾讯源)curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.tencent.com/repo/centos7_base.repo
清除yum缓存并生成新的缓存:yum clean all && yum makecache
安装wgte(验证是否成功):yum install wget
Stream 8 更换源的方法:
CentOS Stream 8 因官方停止支持,所以对应的源也失效了。
首先备份/etc/yum.repos.d/下的所有文件,然后清空这个文件夹。
然后在这个目录新建一个文件,如采用阿里的源,将以下代码保存,命名为: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 clean all
更新
yum makecache