1坑鱼、更換 yum 源的原因
國外網(wǎng)站連接響應太慢
國內(nèi) yum 源響應速度快
2雁乡、國內(nèi) yum 源
阿里云 yum 源
清華大學?yum 源
中科大?yum 源
網(wǎng)易?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=?開頭的行取消注釋(如果被注釋的話)坝橡,把該行內(nèi)的域名(例如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=?”開頭的那一行內(nèi)的centos官方域名(mirror.centos.org)更換為清華大學的域名(mirrors.tuna.tsinghua.edu.cn)即可
清華大學 yum 源配置實例:?
# 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