首先保证你的服务器能联网
运行yum repolist 显示当前yum源
yum repolist
进入yum源设置的文件目录下
cd /etc/yum.repos.d
ls
可以看到跟我们现在使用的yum源对应的仓库有3个
可以直接删掉这3个文件或者不删,我们看看等会会出现什么情况
用此创建并编辑vi CentOS-Base.repo
vi CentOS-Base.repo
然后复制以下代码段,进行新的aliyun源的更换
[base] name=CentOS-8-stream - Base - mirrors.aliyun.com baseurl=https://mirrors.aliyun.com/centos/8-stream/BaseOS/$basearch/os/ gpgcheck=1 gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official #additional packages that may be useful [extras] name=CentOS-8-stream - Extras - mirrors.aliyun.com baseurl=https://mirrors.aliyun.com/centos/8-stream/extras/$basearch/os/ gpgcheck=1 gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official #additional packages that extend functionality of existing packages [centosplus] name=CentOS-8-stream - Plus - mirrors.aliyun.com baseurl=https://mirrors.aliyun.com/centos/8-stream/centosplus/$basearch/os/ gpgcheck=1 enabled=0 gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official [PowerTools] name=CentOS-8-stream - PowerTools - mirrors.aliyun.com baseurl=https://mirrors.aliyun.com/centos/8-stream/PowerTools/$basearch/os/ gpgcheck=1 enabled=0 gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official [AppStream] name=CentOS-8-stream - AppStream - mirrors.aliyun.com baseurl=https://mirrors.aliyun.com/centos/8-stream/AppStream/$basearch/os/ gpgcheck=1 gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
记得保存
然后再次运行yum repolist
yum repolist
可以看到我们新的yum源了
我们的设置已经成功了,还没有运行更新,中间还有2个不能使用的旧yum源需要删掉不然还是会报错的
ls
rm 文件名
这里删除了2个多余文件
清除缓存中的rpm头文件和包文件yum clean all
yum clean all
新建源
yum makecache
现在已经成功换源。但是有时候更新的时候还是会提示有包冲突
使用yum update --allowerasing 更新并替换所有冲突包即可
yum update --allowerasing
相关文章
标签:centos