CentOS-7.5 更換清華大學(xué) yum 源

1、更換 yum 源的原因

國外網(wǎng)站連接響應(yīng)太慢

國內(nèi) yum 源響應(yīng)速度快


2、國內(nèi) yum 源

阿里云 yum 源

清華大學(xué)?yum 源

中科大?yum 源

網(wǎng)易?yum 源


3、更換清華大學(xué)?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=?開頭的行取消注釋(如果被注釋的話),把該行內(nèi)的域名(例如mirror.centos.org)替換為?mirrors.tuna.tsinghua.edu.cn。

2)實(shí)際操作

[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項(xiàng),但是更改方式都一樣。都是將每一小塊以“mirrorlist=”開頭的那一行注釋掉,然后將每一小塊以“baseurl=?”開頭的那一行前面的注釋取消,最后將每一小塊以“baseurl=?”開頭的那一行內(nèi)的centos官方域名(mirror.centos.org)更換為清華大學(xué)的域名(mirrors.tuna.tsinghua.edu.cn)即可

清華大學(xué) yum 源配置實(shí)例:?

# 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 and

# geographically close to the client.? You should use this for CentOS updates

# unless you are manually picking other mirrors.

#

# If the mirrorlist= does not work for you, as a fall back you can try the

# remarked out baseurl= line instead.

#

#

[base]

name=CentOS-$releasever - Base

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra

baseurl=http://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates

[updates]

name=CentOS-$releasever - Updates

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra

baseurl=http://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful

[extras]

name=CentOS-$releasever - Extras

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra

baseurl=http://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages

[centosplus]

name=CentOS-$releasever - Plus

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra

baseurl=http://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/

gpgcheck=1

enabled=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

[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

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容