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
| # yum install axel yum-plugin-fastestmirror yum-axelget
# yum --disableplugin=axelget YumCommand
# 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
| # yum install epel-release
# rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
# yum localinstall http://download1.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm
# 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
| # mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
# 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
|
Centos 其他版本的配置
对于 Centos 不同的版本,更换 CentOS-Base.repo
文件的命令如下。
1 2 3 4
| wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
|
配置 EPEL 源为阿里云镜像源
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| # cp /etc/yum.repos.d/epel-7.repo /etc/yum.repos.d/epel-7.repo.bak
# 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
|
Centos7 卸载 EPEL 源
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| # rpm -qa | grep epel
# yum remove epel-release-7-11.noarch
# 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
|
Docker 镜像配置 YUM 源为阿里云镜像源
若希望 Docker 的 Centos7 镜像配置 YUM 源为阿里云镜像源,可以参考以下的 Dockerfile 内容。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| FROM centos:7
MAINTAINER clay<clay@gmail.com>
# 下载软件源 ADD http://mirrors.aliyun.com/repo/Centos-7.repo /etc/yum.repos.d
# 更新软件源 RUN mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak \ && mv /etc/yum.repos.d/Centos-7.repo /etc/yum.repos.d/CentOS-Base.repo \ && yum clean all -y \ && yum makecache -y \ && yum update -y
# 其他操作(省略)
|