CentOS 7 禁用fastestmirror插件并配置清華鏡像源

每次使用yum安裝軟件都會出現一個fastestmirror的插件,都要等半天。所以禁用掉插件后再手動配置鏡像源會加快安裝速度。

禁用fastestmirror 插件

參考:
http://www.cnblogs.com/starof/p/4773209.html

禁用fastestmirror插件

vi  /etc/yum/pluginconf.d/fastestmirror.conf  
#修改內容
enabled = 1//由1改為0,禁用該插件

或者禁用所有插件【不推薦】

vi /etc/yum.conf
#修改內容
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

將以下內容寫入

# 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'源了,就不用執行這一步了,如果你之前安裝了系統鏡像源和標準epel源,又需要修改epel源的話,需要進行本次操作。

首先從CentOS Extras這個源(tuna也有鏡像)里安裝epel-release:

yum install epel-release

當前tuna已經在epel的官方鏡像列表里,所以不需要其他配置,mirrorlist機制就能讓你的服務器就近使用tuna的鏡像。如果你想強制 你的服務器使用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

下面是替換后的內容

[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
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容