前言:epel源为“红帽系”的操作系统提供的额外的软件包,适用于RHEL,CentOS,
在安装ansible和其他软件时。会使用到epel源。
在安装epel源之前,首先安装一个叫:epel-release的软件包,这个软件包会自动配置yum仓库。
好,废话不多说,下面开始配置epel源
1.移除系统自带的yum仓库
[root@www82 ~]# cd /etc/yum.repos.d/ ###进入到yum仓库的目录
[root@www82 yum.repos.d]# ls #####发现系统自带的yum仓库,创建个bak目录,把系统自带地yum
仓库,全部移地bak目录中
bak CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo rhe17.repo
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo
[root@www82 yum.repos.d]# mv C* bak/ ######把系统自带地yum仓库,全部移地bak目录中
[root@www82 yum.repos.d]# ls ######在查看,只保留一个自己配的yum源,
bak rhe17.repo
2.到阿里开源镜像中下载相应的repo文件,注意:此操作需要联网,需要把网卡的网关和DNS设置好,此操作需要用到wget软件包,没有的直接:yum -y install wget去安装
[root@www82 yum.repos.d]# wget http://mirrors.aliyun.com/repo/Centos-7.repo
#####下载repo文件,下面的是下载过程
--2021-08-10 06:20:48-- http://mirrors.aliyun.com/repo/Centos-7.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 111.6.227.173, 111.6.234.239, 111.6.227.174, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|111.6.227.173|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2523 (2.5K) [application/octet-stream]
Saving to: ‘Centos-7.repo’
100%[============================================================================================================>] 2,523 --.-K/s in 0s
2021-08-10 06:20:48 (359 MB/s) - ‘Centos-7.repo’ saved [2523/2523]
[root@www82 yum.repos.d]# ls ###再次查看,发现已经下载Centos-7.repo文件,
bak Centos-7.repo rhe17.repo
[root@www82 yum.repos.d]# mv rhe17.repo bak/ ###把自己配的本地yum源,也移动到bak目录中,
[root@www82 yum.repos.d]# ls ######只保留刚才下载的repo文件
bak Centos-7.repo
3.清楚缓存,重新生成缓存
[root@www82 yum.repos.d]# yum clean all ###清楚缓存
[root@www82 yum.repos.d]# yum makecache ###生成缓存
4.安装epel源
[root@www82 yum.repos.d]# yum install -y epel-release ###下载epel源
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:7-11 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
======================================================================================================================================================
...... ###此处省略
Installed:
epel-release.noarch 0:7-11
Complete! ###下载完成
[root@www82 yum.repos.d]# ls ###在此查看又多出来两个repo文件
bak Centos-7.repo epel.repo epel-testing.repo
5.使用阿里开源镜像提供的epel源
[root@www82 yum.repos.d]# wget -O /etc/yum.repos.d/epel-7.repo http://mirrors.aliyun.com/repo/epel-7.repo ###下载epelyum源
--2021-08-10 06:34:45-- http://mirrors.aliyun.com/repo/epel-7.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 111.6.234.240, 111.6.252.118, 111.6.252.115, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|111.6.234.240|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 664 [application/octet-stream]
Saving to: ‘/etc/yum.repos.d/epel-7.repo’
100%[============================================================================================================>] 664 --.-K/s in 0s
2021-08-10 06:34:45 (92.1 MB/s) - ‘/etc/yum.repos.d/epel-7.repo’ saved [664/664]
[root@www82 yum.repos.d]# ls ###在查看又多一个repo文件
bak Centos-7.repo epel-7.repo epel.repo epel-testing.repo
6.清除缓存,重新生成缓存
[root@www82 yum.repos.d]# yum clean all ###清除缓存
Loaded plugins: fastestmirror
Repository epel is listed more than once in the configuration
Repository epel-debuginfo is listed more than once in the configuration
Repository epel-source is listed more than once in the configuration
Cleaning repos: base epel extras updates
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors
[root@www82 yum.repos.d]# yum makecache ###生成缓存
Loaded plugins: fastestmirror
Repository epel is listed more than once in the configuration
Repository epel-debuginfo is listed more than once in the configuration
Repository epel-source is listed more than once in the configuration
Determining fastest mirrors
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/16): base/7/x86_64/group_gz | 153 kB 00:00:00
(2/16): base/7/x86_64/filelists_db | 7.2 MB 00:00:03
(3/16): base/7/x86_64/primary_db | 6.1 MB 00:00:02
(4/16): epel/x86_64/group_gz | 96 kB 00:00:00
(5/16): epel/x86_64/updateinfo | 1.0 MB 00:00:00
(6/16): epel/x86_64/prestodelta | 2.8 kB 00:00:00
(7/16): base/7/x86_64/other_db | 2.6 MB 00:00:01
(8/16): epel/x86_64/primary_db | 6.9 MB 00:00:03
(9/16): extras/7/x86_64/primary_db | 242 kB 00:00:00
(10/16): extras/7/x86_64/filelists_db | 235 kB 00:00:00
(11/16): extras/7/x86_64/other_db | 143 kB 00:00:00
(12/16): epel/x86_64/other_db | 3.4 MB 00:00:02
(13/16): updates/7/x86_64/filelists_db | 5.5 MB 00:00:03
(14/16): updates/7/x86_64/other_db | 688 kB 00:00:00
(15/16): updates/7/x86_64/primary_db | 9.6 MB 00:00:05
(16/16): epel/x86_64/filelists_db | 12 MB 00:00:09
Metadata Cache Created
7.测试epel源------>安装ansible,nginx
[root@www82 yum.repos.d]# yum install -y ansible ###安装ansible
Loaded plugins: fastestmirror
Repository epel is listed more than once in the configuration
Repository epel-debuginfo is listed more than once in the configuration
Repository epel-source is listed more than once in the configuration
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package ansible.noarch 0:2.9.23-1.el7 will be installed
...... 此处省略
Installed:
ansible.noarch 0:2.9.23-1.el7
Dependency Installed:
PyYAML.x86_64 0:3.10-11.el7 libyaml.x86_64 0:0.1.4-11.el7_0 python-babel.noarch 0:0.9.6-8.el7
python-backports.x86_64 0:1.0-8.el7 python-backports-ssl_match_hostname.noarch 0:3.5.0.1-1.el7 python-cffi.x86_64 0:1.6.0-5.el7
python-enum34.noarch 0:1.0.4-1.el7 python-idna.noarch 0:2.4-1.el7 python-ipaddress.noarch 0:1.0.16-2.el7
python-jinja2.noarch 0:2.7.2-4.el7 python-markupsafe.x86_64 0:0.11-10.el7 python-paramiko.noarch 0:2.1.1-9.el7
python-ply.noarch 0:3.4-11.el7 python-pycparser.noarch 0:2.14-1.el7 python-setuptools.noarch 0:0.9.8-7.el7
python-six.noarch 0:1.9.0-2.el7 python2-cryptography.x86_64 0:1.7.2-2.el7 python2-httplib2.noarch 0:0.18.1-3.el7
python2-jmespath.noarch 0:0.9.4-2.el7 python2-pyasn1.noarch 0:0.1.9-7.el7 sshpass.x86_64 0:1.06-2.el7
Complete! ######完成安装,说明epel源可用