如何在CentOS 8和RHEL 8服务器上启用EPEL仓库

如何在CentOS 8和RHEL 8服务器上启用EPEL仓库

EPEL 代表 “Extra Packages for Enterprise Linux”,它是一个自由开源的附加软件包仓库,可用于 CentOS 和 RHEL 服务器。顾名思义,EPEL 仓库提供了额外的软件包,这些软件在 CentOS 8RHEL 8 的默认软件包仓库中不可用。

在本文中,我们将演示如何在 CentOS 8 和 RHEL 8 服务器上启用和使用 EPEL 存储库。

EPEL 仓库的先决条件

  • 最小化安装的 CentOS 8 和 RHEL 8 服务器
  • root 或 sudo 管理员权限
  • 网络连接

在 RHEL 8.x 服务器上安装并启用 EPEL 仓库

登录或 SSH 到你的 RHEL 8.x 服务器,并执行以下 dnf 命令来安装 EPEL rpm 包,

  1. <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>

上面命令的输出将如下所示,

如何在CentOS 8和RHEL 8服务器上启用EPEL仓库

dnf-install-epel-repo-rehl8

EPEL rpm 包成功安装后,它将自动启用并配置其 yum/dnf 仓库。运行以下 dnfyum 命令,以验证是否启用了 EPEL 仓库,

  1. <span class="pun">[</span><span class="pln">root@linuxtechi </span><span class="pun">~]#</span><span class="pln"> dnf repolist epel</span>
  2. <span class="pun">或者</span>
  3. <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>

如何在CentOS 8和RHEL 8服务器上启用EPEL仓库

epel-repolist-rhel8

在 CentOS 8.x 服务器上安装并启用 EPEL 仓库

登录或 SSH 到你的 CentOS 8 服务器,并执行以下 dnfyum 命令来安装 epel-release rpm 软件包。在 CentOS 8 服务器中,EPEL rpm 在其默认软件包仓库中。

  1. <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>
  2. <span class="pun">或者</span>
  3. <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 仓库的状态,

  1. <span class="pun">[</span><span class="pln">root@linuxtechi </span><span class="pun">~]#</span><span class="pln"> dnf repolist epel</span>
  2. <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>
  3. <span class="pln">repo </span><span class="kwd">id</span><span class="pln"> repo name status</span>
  4. <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>
  5. <span class="pun">[</span><span class="pln">root@linuxtechi </span><span class="pun">~]#</span>
  6. <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>
  7. <span class="pun">……………………</span>
  8. <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>
  9. <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>
  10. <span class="typ">Repo</span><span class="pun">-</span><span class="pln">status </span><span class="pun">:</span><span class="pln"> enabled</span>
  11. <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>
  12. <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>
  13. <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>
  14. <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>
  15. <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>
  16. <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>
  17. <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>
  18. <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>
  19. <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>
  20. <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>
  21. <span class="pun">[</span><span class="pln">root@linuxtechi </span><span class="pun">~]#</span>

以上命令的输出说明我们已经成功启用了 EPEL 仓库。让我们在 EPEL 仓库上执行一些基本操作。

列出 EPEL 仓库种所有可用包

如果要列出 EPEL 仓库中的所有的软件包,请运行以下 dnf 命令,

  1. <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>
  2. <span class="pun">……………</span>
  3. <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>
  4. <span class="typ">Installed</span><span class="pln"> </span><span class="typ">Packages</span>
  5. <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>
  6. <span class="typ">Available</span><span class="pln"> </span><span class="typ">Packages</span>
  7. <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>
  8. <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>
  9. <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>
  10. <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>
  11. <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>
  12. <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>
  13. <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>
  14. <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>
  15. <span class="pun">…………………………</span>
  16. <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>
  17. <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>
  18. <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>
  19. <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>
  20. <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>
  21. <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>
  22. <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>
  23. <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>
  24. <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>
  25. <span class="pun">[</span><span class="pln">root@linuxtechi </span><span class="pun">~]#</span>

从 EPEL 仓库中搜索软件包

假设我们要搜索 EPEL 仓库中的 Zabbix 包,请执行以下 dnf 命令,

  1. <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>

上面命令的输出类似下面这样,

如何在CentOS 8和RHEL 8服务器上启用EPEL仓库

epel-repo-search-package-centos8

从 EPEL 仓库安装软件包

假设我们要从 EPEL 仓库安装 htop 包,运行以下 dnf 命令,

语法:

  1. <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>
  1. <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>

相关推荐