CentOS 7 禁用fastestmirror插件并配置清华镜

2017-05-08  本文已影响0人  izhangxm

每次使用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
上一篇 下一篇

猜你喜欢

热点阅读