centos9 配置yum源(清华源)

sudo cp -r /etc/yum.repos.d /etc/yum.repos.d.backup

备份yum源

sudo vim /etc/yum.repos.d/CentOS-Base.repo

编辑yum源仓库

[baseos]  
name=CentOS Stream $releasever - BaseOS  
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/9-stream/BaseOS/$basearch/os/  
gpgcheck=1  
enabled=1  
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial  
  
[appstream]  
name=CentOS Stream $releasever - AppStream  
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-stream/9-stream/AppStream/$basearch/os/  
gpgcheck=1  
enabled=1  
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

将此代码,插入打开的文件中,将之前文件清空,插入即可。

yum clean all  

yum makecache 

清理文件,建立缓存。

### 配置CentOS系统的Yum为清华大学镜像 对于希望提高软件包下载速度以及稳定性的情况,在CentOS系统中将默认的yum更换为清华大学镜像是一种常见做法。具体操作如下: #### 修改现有库文件指向清华源 进入`/etc/yum.repos.d/`目录下编辑现有的`.repo`文件,通常会涉及到`CentOS-Base.repo`这样的基础仓库配置文件。 建议先备份原始的repo文件以防出现问题可以恢复: ```bash mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup ``` 接着创建一个新的名为`CentOS-Base.repo`的文件并加入以下内容来指定使用清华大学提供的镜像站作为新的yum[^1]: ```ini # CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the update status of each mirror to pick mirrors that are updated to date and close to you. You should use this instead of editing the file by hand. [base] name=CentOS-$releasever - Base - 163.com mirrorlist=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/ gpgcheck=1 enabled=1 gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos/RPM-GPG-KEY-CentOS-7 #released updates [updates] name=CentOS-$releasever - Updates - 163.com mirrorlist=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/ gpgcheck=1 enabled=1 gpgkey=https://mirors.tuna.tsinghua.edu.cn/centos/RPM-GPG-KEY-CentOS-7 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras - 163.com mirrorlist=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/ gpgcheck=1 enabled=1 gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos/RPM-GPG-KEY-CentOS-7 ``` 完成上述更改之后,可以通过运行命令刷新缓存使新设置生效: ```bash yum clean all && yum makecache ``` 这样就可以成功地把yum切换到了清华大学所提供的镜像站点上,从而享受更快更稳定的更新体验了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值