Centos7 管理 YUM 源与 EPEL 源

YUM 相关的配置文件及目录

1
2
3
主配置文件:/etc/yum.conf
资源库配置目录:/etc/yum.repos.d
重要文件: /etc/yum.repos.d/CentOS-Base.repo

YUM 安装加速插件

1
2
3
4
5
6
7
8
9
10
11
12
13
# 安装axelget插件
# yum install axel yum-plugin-fastestmirror yum-axelget

# 如果临时不想启用axelget插件,可参考以下命令
# yum --disableplugin=axelget YumCommand

# 更改axelget插件默认的并发下载线程数,编辑Python源码文件,修改以下内容即可
# vim /usr/lib/yum-plugins/axelget.py
maxconn = 15
maxconn = conduit.confInt('main', 'maxconn', default=15)

# 查看实际并发下载的效果
# yum --debuglevel=3 YumCommand

添加常用的 YUM 源

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# 添加epel源
# yum install epel-release

# 添加nux-dextop源
# rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm

# 添加rpmfusion free源
# yum localinstall http://download1.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm

# 添加rpmfusion nonfree源(闭源软件的源,不建议使用)
# yum localinstall http://download1.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-7.noarch.rpm

# 清理数据
# yum clean all

# 生成缓存
# yum makecache

# 查看已安装的源
# yum repolist

配置 YUM 源为阿里云镜像源

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 备份YUM源
# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak

# 下载阿里云的YUM源
# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

# 或者
# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

# 清理数据
# yum clean all

# 生成缓存
# yum makecache

# 查看已安装的源
# yum repolist

配置 EPEL 源为阿里云镜像源

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# 备份EPEL源
# cp /etc/yum.repos.d/epel-7.repo /etc/yum.repos.d/epel-7.repo.bak

# 下载阿里云的EPEL源
# wget -O /etc/yum.repos.d/epel-7.repo https://mirrors.aliyun.com/repo/epel-7.repo

# 或者
# curl -o /etc/yum.repos.d/epel-7.repo https://mirrors.aliyun.com/repo/epel-7.repo

# 清理数据
# yum clean all

# 生成缓存
# yum makecache

# 查看已安装的源
# yum repolist

# 提示:配置EPEL源为阿里云镜像源后,依然可以正常使用"yum install epel-release"命令安装EPEL源

Centos7 卸载 EPEL 源

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# 查找epel已安装的rpm包
# rpm -qa | grep epel

# 卸载epel已安装的rpm包
# yum remove epel-release-7-11.noarch

# 确保epel相关文件已删除
# rm /etc/yum.repos.d/epel.repo
# rm /etc/yum.repos.depel-testing.repo
# rm /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7

# 清理数据
# yum clean all

# 生成缓存
# yum makecache

# 查看已安装的源
# yum repolist

禁用 YUM 源

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 查看所有仓库源
# yum repolist all

# 查看所有已启用的仓库源
# yum repolist

# 更新软件,并临时禁用某个仓库源
# yum --disablerepo=Atom update -y

# 永久启用某个仓库源
# yum-config-manager --enable Atom

# 永久禁用某个仓库源
# yum-config-manager --disable Atom