CentOS-7.5 更换清华大学 yum 源

如题所述

第1个回答  2022-06-16
1、更换 yum 源的原因

国外网站连接响应太慢

国内 yum 源响应速度快

2、国内 yum 源

阿里云 yum 源

清华大学 yum 源

中科大 yum 源

网易 yum 源

3、更换清华大学 yum 源

1)建议先备份 CentOS-Base.repo

sudo  cp  /etc/yum.repos.d/CentOS-Base.repo   /etc/yum.repos.d/CentOS-Base.repo.bak

然后编辑 /etc/yum.repos.d/CentOS-Base.repo 文件,在以 mirrorlist= 开头的行前面加 # 注释掉;

并将以 baseurl= 开头的行取消注释(如果被注释的话),把该行内的域名(例如mirror.centos.org)替换为 mirrors.tuna.tsinghua.edu.cn。

2)实际操作

[root@shell ~]#

[root@shell ~]# cp  /etc/yum.repos.d/CentOS-Base.repo  /etc/yum.repos.d/CentOS-Base.repo.bak

[root@shell ~]#

[root@shell ~]# vi  /etc/yum.repos.d/CentOS-Base.repo

修改说明:

yum源配置总共有4项,但是更改方式都一样。都是将每一小块以“mirrorlist=”开头的那一行注释掉,然后将每一小块以“baseurl= ”开头的那一行前面的注释取消,最后将每一小块以“baseurl= ”开头的那一行内的centos官方域名(mirror.centos.org)更换为清华大学的域名(mirrors.tuna.tsinghua.edu.cn)即可

清华大学 yum 源配置实例: 

[root@shell ~]# 

[root@shell ~]# yum  clean  all                    #清空yum缓存

[root@shell ~]# yum  makecache                    #更新yum源缓存

[root@shell ~]# yum  repolist 

[root@shell ~]#

[root@shell ~]# yum  list  httpd  mariadb  php
相似回答