每次使用yum安裝軟件都會出現(xiàn)一個fastestmirror的插件掩完,都要等半天。所以禁用掉插件后再手動配置鏡像源會加快安裝速度硼砰。
禁用fastestmirror 插件
參考:
http://www.cnblogs.com/starof/p/4773209.html
禁用fastestmirror插件
vi /etc/yum/pluginconf.d/fastestmirror.conf
#修改內(nèi)容
enabled = 1//由1改為0且蓬,禁用該插件
或者禁用所有插件【不推薦】
vi /etc/yum.conf
#修改內(nèi)容
plugins=1 //改為0,不使用插件
啟用清華源
參考:
https://mirror.tuna.tsinghua.edu.cn/help/centos/
首先備份 CentOS-Base.repo
sudo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
編輯 /etc/yum.repos.d/CentOS-Base.repo
vi /etc/yum.repos.d/CentOS-Base.repo
將以下內(nèi)容寫入
# 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
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
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
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
啟用清華EPEL源
參考:
https://mirror.tuna.tsinghua.edu.cn/help/epel/
http://harttle.com/2016/08/08/vim-search-in-file.html
如果你之前沒有安裝epel源题翰,在替換為清華源后恶阴,epel安裝時本身就是清華的epel'源了,就不用執(zhí)行這一步了豹障,如果你之前安裝了系統(tǒng)鏡像源和標準epel源冯事,又需要修改epel源的話,需要進行本次操作沼填。
首先從CentOS Extras這個源(tuna也有鏡像)里安裝epel-release:
yum install epel-release
當前tuna已經(jīng)在epel的官方鏡像列表里桅咆,所以不需要其他配置,mirrorlist機制就能讓你的服務(wù)器就近使用tuna的鏡像坞笙。如果你想強制 你的服務(wù)器使用tuna的鏡像岩饼,可以修改/etc/yum.repos.d/epel.repo ,將baseurl 開頭的行取消注釋(刪掉# )薛夜,并注釋mirrorlist 開頭的行(在頭部加一個# )籍茧。
vi /etc/yum.repos.d/epel.repo
在命令模式下輸入:%s/^#base/base
去掉所有的baseurl的注釋
在命令模式下輸入:%s/^mirror/#mirror
去掉所有的baseurl的注釋
接下來,把這個文件里的http://download.fedoraproject.org/pub
替換成https://mirrors.tuna.tsinghua.edu.cn
即可
:%s#http://download.fedoraproject.org/pub#https://mirrors.tuna.tsinghua.edu.cn
下面是替換后的內(nèi)容
[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/7/$basearch
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
[epel-debuginfo]
name=Extra Packages for Enterprise Linux 7 - $basearch - Debug
baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/7/$basearch/debug
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=1
[epel-source]
name=Extra Packages for Enterprise Linux 7 - $basearch - Source
baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/7/SRPMS
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=1