秋风瑟瑟 2019-11-05
EPEL 代表 “Extra Packages for Enterprise Linux”,它是一个自由开源的附加软件包仓库,可用于 CentOS 和 RHEL 服务器。顾名思义,EPEL 仓库提供了额外的软件包,这些软件在 CentOS 8 和 RHEL 8 的默认软件包仓库中不可用。
在本文中,我们将演示如何在 CentOS 8 和 RHEL 8 服务器上启用和使用 EPEL 存储库。
登录或 SSH 到你的 RHEL 8.x 服务器,并执行以下 dnf
命令来安装 EPEL rpm 包,
<span class="pun">[</span><span class="pln">root@linuxtechi </span><span class="pun">~]#</span><span class="pln"> dnf install https</span><span class="pun">:</span><span class="com">//dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y</span>
上面命令的输出将如下所示,
dnf-install-epel-repo-rehl8
EPEL rpm 包成功安装后,它将自动启用并配置其 yum/dnf 仓库。运行以下 dnf
或 yum
命令,以验证是否启用了 EPEL 仓库,
<span class="pun">[</span><span class="pln">root@linuxtechi </span><span class="pun">~]#</span><span class="pln"> dnf repolist epel</span>
<span class="pun">或者</span>
<span class="pun">[</span><span class="pln">root@linuxtechi </span><span class="pun">~]#</span><span class="pln"> dnf repolist epel </span><span class="pun">-</span><span class="pln">v</span>
epel-repolist-rhel8
登录或 SSH 到你的 CentOS 8 服务器,并执行以下 dnf
或 yum
命令来安装 epel-release
rpm 软件包。在 CentOS 8 服务器中,EPEL rpm 在其默认软件包仓库中。
<span class="pun">[</span><span class="pln">root@linuxtechi </span><span class="pun">~]#</span><span class="pln"> dnf install epel</span><span class="pun">-</span><span class="pln">release </span><span class="pun">-</span><span class="pln">y</span>
<span class="pun">或者</span>
<span class="pun">[</span><span class="pln">root@linuxtechi </span><span class="pun">~]#</span><span class="pln"> </span><span class="kwd">yum</span><span class="pln"> install epel</span><span class="pun">-</span><span class="pln">release </span><span class="pun">-</span><span class="pln">y</span>
执行以下命令来验证 CentOS 8 服务器上 EPEL 仓库的状态,
<span class="pun">[</span><span class="pln">root@linuxtechi </span><span class="pun">~]#</span><span class="pln"> dnf repolist epel</span>
<span class="typ">Last</span><span class="pln"> metadata expiration check</span><span class="pun">:</span><span class="pln"> </span><span class="lit">0</span><span class="pun">:</span><span class="lit">00</span><span class="pun">:</span><span class="lit">03</span><span class="pln"> ago on </span><span class="typ">Sun</span><span class="pln"> </span><span class="lit">13</span><span class="pln"> </span><span class="typ">Oct</span><span class="pln"> </span><span class="lit">2019</span><span class="pln"> </span><span class="lit">04</span><span class="pun">:</span><span class="lit">18</span><span class="pun">:</span><span class="lit">05</span><span class="pln"> AM BST</span><span class="pun">.</span>
<span class="pln">repo </span><span class="kwd">id</span><span class="pln"> repo name status</span>
<span class="pun">*</span><span class="pln">epel </span><span class="typ">Extra</span><span class="pln"> </span><span class="typ">Packages</span><span class="pln"> </span><span class="kwd">for</span><span class="pln"> </span><span class="typ">Enterprise</span><span class="pln"> </span><span class="typ">Linux</span><span class="pln"> </span><span class="lit">8</span><span class="pln"> </span><span class="pun">-</span><span class="pln"> x86_64 </span><span class="lit">1</span><span class="pun">,</span><span class="lit">977</span>
<span class="pun">[</span><span class="pln">root@linuxtechi </span><span class="pun">~]#</span>
<span class="pun">[</span><span class="pln">root@linuxtechi </span><span class="pun">~]#</span><span class="pln"> dnf repolist epel </span><span class="pun">-</span><span class="pln">v</span>
<span class="pun">……………………</span>
<span class="typ">Repo</span><span class="pun">-</span><span class="kwd">id</span><span class="pln"> </span><span class="pun">:</span><span class="pln"> epel</span>
<span class="typ">Repo</span><span class="pun">-</span><span class="pln">name </span><span class="pun">:</span><span class="pln"> </span><span class="typ">Extra</span><span class="pln"> </span><span class="typ">Packages</span><span class="pln"> </span><span class="kwd">for</span><span class="pln"> </span><span class="typ">Enterprise</span><span class="pln"> </span><span class="typ">Linux</span><span class="pln"> </span><span class="lit">8</span><span class="pln"> </span><span class="pun">-</span><span class="pln"> x86_64</span>
<span class="typ">Repo</span><span class="pun">-</span><span class="pln">status </span><span class="pun">:</span><span class="pln"> enabled</span>
<span class="typ">Repo</span><span class="pun">-</span><span class="pln">revision</span><span class="pun">:</span><span class="pln"> </span><span class="lit">1570844166</span>
<span class="typ">Repo</span><span class="pun">-</span><span class="pln">updated </span><span class="pun">:</span><span class="pln"> </span><span class="typ">Sat</span><span class="pln"> </span><span class="lit">12</span><span class="pln"> </span><span class="typ">Oct</span><span class="pln"> </span><span class="lit">2019</span><span class="pln"> </span><span class="lit">02</span><span class="pun">:</span><span class="lit">36</span><span class="pun">:</span><span class="lit">32</span><span class="pln"> AM BST</span>
<span class="typ">Repo</span><span class="pun">-</span><span class="pln">pkgs </span><span class="pun">:</span><span class="pln"> </span><span class="lit">1</span><span class="pun">,</span><span class="lit">977</span>
<span class="typ">Repo</span><span class="pun">-</span><span class="kwd">size</span><span class="pln"> </span><span class="pun">:</span><span class="pln"> </span><span class="lit">2.1</span><span class="pln"> G</span>
<span class="typ">Repo</span><span class="pun">-</span><span class="pln">metalink</span><span class="pun">:</span><span class="pln"> https</span><span class="pun">:</span><span class="com">//mirrors.fedoraproject.org/metalink?repo=epel-8&arch=x86_64&infra=stock&content=centos</span>
<span class="pln"> </span><span class="typ">Updated</span><span class="pln"> </span><span class="pun">:</span><span class="pln"> </span><span class="typ">Sun</span><span class="pln"> </span><span class="lit">13</span><span class="pln"> </span><span class="typ">Oct</span><span class="pln"> </span><span class="lit">2019</span><span class="pln"> </span><span class="lit">04</span><span class="pun">:</span><span class="lit">28</span><span class="pun">:</span><span class="lit">24</span><span class="pln"> AM BST</span>
<span class="typ">Repo</span><span class="pun">-</span><span class="pln">baseurl </span><span class="pun">:</span><span class="pln"> rsync</span><span class="pun">:</span><span class="com">//repos.del.extreme-ix.org/epel/8/Everything/x86_64/ (34 more)</span>
<span class="typ">Repo</span><span class="pun">-</span><span class="pln">expire </span><span class="pun">:</span><span class="pln"> </span><span class="lit">172</span><span class="pun">,</span><span class="lit">800</span><span class="pln"> second</span><span class="pun">(</span><span class="pln">s</span><span class="pun">)</span><span class="pln"> </span><span class="pun">(</span><span class="kwd">last</span><span class="pun">:</span><span class="pln"> </span><span class="typ">Sun</span><span class="pln"> </span><span class="lit">13</span><span class="pln"> </span><span class="typ">Oct</span><span class="pln"> </span><span class="lit">2019</span><span class="pln"> </span><span class="lit">04</span><span class="pun">:</span><span class="lit">28</span><span class="pun">:</span><span class="lit">24</span><span class="pln"> AM BST</span><span class="pun">)</span>
<span class="typ">Repo</span><span class="pun">-</span><span class="pln">filename</span><span class="pun">:</span><span class="pln"> </span><span class="str">/etc/</span><span class="kwd">yum</span><span class="pun">.</span><span class="pln">repos</span><span class="pun">.</span><span class="pln">d</span><span class="pun">/</span><span class="pln">epel</span><span class="pun">.</span><span class="pln">repo</span>
<span class="typ">Total</span><span class="pln"> packages</span><span class="pun">:</span><span class="pln"> </span><span class="lit">1</span><span class="pun">,</span><span class="lit">977</span>
<span class="pun">[</span><span class="pln">root@linuxtechi </span><span class="pun">~]#</span>
以上命令的输出说明我们已经成功启用了 EPEL 仓库。让我们在 EPEL 仓库上执行一些基本操作。
如果要列出 EPEL 仓库中的所有的软件包,请运行以下 dnf
命令,
<span class="pun">[</span><span class="pln">root@linuxtechi </span><span class="pun">~]#</span><span class="pln"> dnf repository</span><span class="pun">-</span><span class="pln">packages epel </span><span class="kwd">list</span>
<span class="pun">……………</span>
<span class="typ">Last</span><span class="pln"> metadata expiration check</span><span class="pun">:</span><span class="pln"> </span><span class="lit">0</span><span class="pun">:</span><span class="lit">38</span><span class="pun">:</span><span class="lit">18</span><span class="pln"> ago on </span><span class="typ">Sun</span><span class="pln"> </span><span class="lit">13</span><span class="pln"> </span><span class="typ">Oct</span><span class="pln"> </span><span class="lit">2019</span><span class="pln"> </span><span class="lit">04</span><span class="pun">:</span><span class="lit">28</span><span class="pun">:</span><span class="lit">24</span><span class="pln"> AM BST</span><span class="pun">.</span>
<span class="typ">Installed</span><span class="pln"> </span><span class="typ">Packages</span>
<span class="pln">epel</span><span class="pun">-</span><span class="pln">release</span><span class="pun">.</span><span class="pln">noarch </span><span class="lit">8</span><span class="pun">-</span><span class="lit">6.el8</span><span class="pln"> </span><span class="lit">@epel</span>
<span class="typ">Available</span><span class="pln"> </span><span class="typ">Packages</span>
<span class="typ">BackupPC</span><span class="pun">.</span><span class="pln">x86_64 </span><span class="lit">4.3</span><span class="pun">.</span><span class="lit">1</span><span class="pun">-</span><span class="lit">2.el8</span><span class="pln"> epel</span>
<span class="typ">BackupPC</span><span class="pun">-</span><span class="pln">XS</span><span class="pun">.</span><span class="pln">x86_64 </span><span class="lit">0.59</span><span class="pun">-</span><span class="lit">3.el8</span><span class="pln"> epel</span>
<span class="pln">CGSI</span><span class="pun">-</span><span class="pln">gSOAP</span><span class="pun">.</span><span class="pln">x86_64 </span><span class="lit">1.3</span><span class="pun">.</span><span class="lit">11</span><span class="pun">-</span><span class="lit">7.el8</span><span class="pln"> epel</span>
<span class="pln">CGSI</span><span class="pun">-</span><span class="pln">gSOAP</span><span class="pun">-</span><span class="pln">devel</span><span class="pun">.</span><span class="pln">x86_64 </span><span class="lit">1.3</span><span class="pun">.</span><span class="lit">11</span><span class="pun">-</span><span class="lit">7.el8</span><span class="pln"> epel</span>
<span class="typ">Field3D</span><span class="pun">.</span><span class="pln">x86_64 </span><span class="lit">1.7</span><span class="pun">.</span><span class="lit">2</span><span class="pun">-</span><span class="lit">16.el8</span><span class="pln"> epel</span>
<span class="typ">Field3D</span><span class="pun">-</span><span class="pln">devel</span><span class="pun">.</span><span class="pln">x86_64 </span><span class="lit">1.7</span><span class="pun">.</span><span class="lit">2</span><span class="pun">-</span><span class="lit">16.el8</span><span class="pln"> epel</span>
<span class="typ">GraphicsMagick</span><span class="pun">.</span><span class="pln">x86_64 </span><span class="lit">1.3</span><span class="pun">.</span><span class="lit">33</span><span class="pun">-</span><span class="lit">1.el8</span><span class="pln"> epel</span>
<span class="typ">GraphicsMagick</span><span class="pun">-</span><span class="pln">c</span><span class="pun">++.</span><span class="pln">x86_64 </span><span class="lit">1.3</span><span class="pun">.</span><span class="lit">33</span><span class="pun">-</span><span class="lit">1.el8</span><span class="pln"> epel</span>
<span class="pun">…………………………</span>
<span class="pln">zabbix40</span><span class="pun">-</span><span class="pln">web</span><span class="pun">-</span><span class="pln">mysql</span><span class="pun">.</span><span class="pln">noarch </span><span class="lit">4.0</span><span class="pun">.</span><span class="lit">12</span><span class="pun">-</span><span class="lit">1.el8</span><span class="pln"> epel</span>
<span class="pln">zabbix40</span><span class="pun">-</span><span class="pln">web</span><span class="pun">-</span><span class="pln">pgsql</span><span class="pun">.</span><span class="pln">noarch </span><span class="lit">4.0</span><span class="pun">.</span><span class="lit">12</span><span class="pun">-</span><span class="lit">1.el8</span><span class="pln"> epel</span>
<span class="pln">zerofree</span><span class="pun">.</span><span class="pln">x86_64 </span><span class="lit">1.1</span><span class="pun">.</span><span class="lit">1</span><span class="pun">-</span><span class="lit">3.el8</span><span class="pln"> epel</span>
<span class="pln">zimg</span><span class="pun">.</span><span class="pln">x86_64 </span><span class="lit">2.8</span><span class="pun">-</span><span class="lit">4.el8</span><span class="pln"> epel</span>
<span class="pln">zimg</span><span class="pun">-</span><span class="pln">devel</span><span class="pun">.</span><span class="pln">x86_64 </span><span class="lit">2.8</span><span class="pun">-</span><span class="lit">4.el8</span><span class="pln"> epel</span>
<span class="pln">zstd</span><span class="pun">.</span><span class="pln">x86_64 </span><span class="lit">1.4</span><span class="pun">.</span><span class="lit">2</span><span class="pun">-</span><span class="lit">1.el8</span><span class="pln"> epel</span>
<span class="pln">zvbi</span><span class="pun">.</span><span class="pln">x86_64 </span><span class="lit">0.2</span><span class="pun">.</span><span class="lit">35</span><span class="pun">-</span><span class="lit">9.el8</span><span class="pln"> epel</span>
<span class="pln">zvbi</span><span class="pun">-</span><span class="pln">devel</span><span class="pun">.</span><span class="pln">x86_64 </span><span class="lit">0.2</span><span class="pun">.</span><span class="lit">35</span><span class="pun">-</span><span class="lit">9.el8</span><span class="pln"> epel</span>
<span class="pln">zvbi</span><span class="pun">-</span><span class="pln">fonts</span><span class="pun">.</span><span class="pln">noarch </span><span class="lit">0.2</span><span class="pun">.</span><span class="lit">35</span><span class="pun">-</span><span class="lit">9.el8</span><span class="pln"> epel</span>
<span class="pun">[</span><span class="pln">root@linuxtechi </span><span class="pun">~]#</span>
假设我们要搜索 EPEL 仓库中的 Zabbix 包,请执行以下 dnf
命令,
<span class="pun">[</span><span class="pln">root@linuxtechi </span><span class="pun">~]#</span><span class="pln"> dnf repository</span><span class="pun">-</span><span class="pln">packages epel </span><span class="kwd">list</span><span class="pln"> </span><span class="pun">|</span><span class="pln"> </span><span class="kwd">grep</span><span class="pln"> </span><span class="pun">-</span><span class="pln">i zabbix</span>
上面命令的输出类似下面这样,
epel-repo-search-package-centos8
假设我们要从 EPEL 仓库安装 htop 包,运行以下 dnf
命令,
语法:
<span class="com">#</span><span class="pln"> dnf </span><span class="pun">–</span><span class="pln">enablerepo</span><span class="pun">=”</span><span class="pln">epel</span><span class="pun">”</span><span class="pln"> install </span><span class="pun"><包名></span>
<span class="pun">[</span><span class="pln">root@linuxtechi </span><span class="pun">~]#</span><span class="pln"> dnf </span><span class="pun">--</span><span class="pln">enablerepo</span><span class="pun">=</span><span class="str">"epel"</span><span class="pln"> install </span><span class="kwd">htop</span><span class="pln"> </span><span class="pun">-</span><span class="pln">y</span>
更新CA证书就可以,不过在此同时需要临时禁用epel源并更新就可以了,命令如下:yum --disablerepo=epel -y update ca-certificates. 运行过后,一切好使。