如何在 CentOS/RHEL 上使用 EPEL 倉庫啟用和安裝第三方軟體包


在本文中,我們將嘗試學習如何在 Linux 中新增 EPEL 倉庫。EPEL(Enterprise Linux 的額外軟體包)是一個開源且免費的社群驅動的倉庫,由 Fedora 社群團隊提供,為 Linux 發行版提供高質量且優秀的附加軟體。它包含 Red Hat Enterprise Linux、CentOS、Scientific Linux 以及大多數僅由 Fedora 團隊維護的倉庫。

為什麼要使用 EPEL 倉庫來獲取軟體包

  • 提供許多可以使用 yum 安裝的開源軟體包。
  • EPEL 倉庫是開源的,並且 100% 免費使用。
  • 不會有任何相容性問題,並且它們不會提供任何核心重複的軟體包。
  • 這些由 Fedora 團隊維護。

在 CentOS/RHEL 中啟用倉庫

我們需要使用 Wget 下載檔案以獲取“.rpm”並使用 RPM 命令進行安裝。我們需要以 root 使用者身份執行以下命令。

適用於 Centos 7 或 RHEL 7

# wget http://dl.fedoraprokect.org/pub/epl/7/x86_64/e/epel-release-7.6.noarch.rpm
# rpm –ivh epelrelease-7-6.noarch.rpm

適用於 Centos 6.x 64 位或 32 位

32 位

# wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
# rpm -ivh epel-release-6-8.noarch.rpm

64 位

# wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -ivh epel-release-6-8.noarch.rpm

驗證 EPEL 倉庫

由於上述命令將在我們的 yum 倉庫中安裝 EPEL 倉庫,因此我們可以使用以下命令驗證 EPEL 倉庫是否已啟用。

# yum repolist
yum repoli
Loaded plugins: fastestmirror
Determining fastest mirrors
epel/metalink                                        | 12 kB 00:00
   * base: linux.cc.lehigh.edu
   * epel: ftp.osuosl.org
   * extras: mirror.fusioncloud.co
   * remi-safe: fr.mirror.babylon.network
   * rpmforge: mirror.lug.udel.edu
* updates: centos.mirror.constant.com
WandiscoSVN | 951 B 00:00
base | 3.7 kB 00:00
base/primary_db | 4.7 MB 00:00
epel | 4.3 kB 00:00
epel/primary_db | 5.8 MB 00:00
extras | 3.4 kB 00:00
extras/primary_db | 36 kB 00:00
remi-safe | 2.9 kB 00:00
remi-safe/primary_db | 285 kB 00:00
rpmforge | 1.9 kB 00:00
updates | 3.4 kB 00:00
updates/primary_db | 726 kB 00:00
repo id                                repo name status
WandiscoSVN                            Wandisco SVN Repo 73
base                                   CentOS-6 - Base 6,696
epel                                   Extra Packages for Enterprise Linux 6 - x86_64 12,156
extras                                 CentOS-6 - Extras 60
remi-safe                              Safe Remi's RPM repository for Enterprise Linux 6 - x86_64 659
rpmforge                               RHEL 6 - RPMforge.net - dag 245
updates                                CentOS-6 - Updates 111
repolist:
20,000
As we install the repositories all the yum repositories are located at /etc/yum.repos.d/epel.repo

如何使用 EPEL 倉庫

我們使用 YUM 命令來搜尋和安裝軟體包。如果我們想使用 EPEL 倉庫安裝 MySQL,我們可以執行以下命令來檢視它是否可用

# yum --enablerepo=epel info mysql
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
   * base: linux.cc.lehigh.edu
   * epel: ftp.osuosl.org
   * extras: mirror.fusioncloud.co
   * remi-safe: fr.mirror.babylon.network
   * rpmforge: mirror.lug.udel.edu
   * updates: centos.mirror.constant.co
Installed Packages
Name          : mysql
Arch          : x86_64
Version       : 5.1.73
Release       : 5.el6_6
Size          : 2.4 M
Repo          : installed
From repo     : base
Summary       : MySQL client programs and shared libraries
URL           : https://mysql.com.tw
License       : GPLv2 with exceptions
Description   : MySQL is a multi-user, multi-threaded SQL database server. MySQL is a
              : client/server implementation consisting of a server daemon (mysqld)
              : and many different client programs and libraries. The base package
              : contains the standard MySQL client programs and generic MySQL files
Available Packages
Name          : mysql
Arch          : x86_64
Version       : 5.1.73
Release       : 7.el6
Size          : 894 k
Repo          : base
Summary       : MySQL client programs and shared libraries
URL           : https://mysql.com.tw
License       : GPLv2 with exceptions
Description   : MySQL is a multi-user, multi-threaded SQL database server. MySQL is a
              : client/server implementation consisting of a server daemon (mysqld)
              : and many different client programs and libraries. The base package
              : contains the standard MySQL client programs and generic MySQL files.

要使用 EPEL 倉庫安裝 MySQL,我們需要執行以下命令 -

有時倉庫不會自動更新,那麼我們需要將倉庫列表新增到我們的本地 yum 倉庫中,這裡為了演示目的,我將 MySQL 社群版 5.6 新增到我們的本地倉庫。

# vi /etc/yum. reposes. d/mysql. reports
# Enable to use MySQL 5.6
[mysql56-community]
name=MySQL 5.6 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

現在我們將使用 EPEL 倉庫安裝 mysql

# yum --enablerepo-epel install mysql
Loaded plugins: fastestmirror
Setting up Install Process
Loading mirror speeds from cached hostfile
   * base: linux.cc.lehigh.edu
   * epel: ftp.osuosl.org
   * extras: mirror.fusioncloud.co
   * remi-safe: fr.mirror.babylon.network
   * rpmforge: mirror.lug.udel.edu
   * updates: centos.mirror.constant.com
Resolving Dependencies
--> Running transaction check
---> Package mysql.x86_64 0:5.1.73-5.el6_6 will be updated
--> Processing Dependency: mysql = 5.1.73-5.el6_6 for package: mysql-server-5.1. 73-5.el6_6.x86_64
---> Package mysql.x86_64 0:5.1.73-7.el6 will be an update
--> Processing Dependency: mysql-libs = 5.1.73-7.el6 for package: mysql-5.1.73-7 .el6.x86_64
--> Running transaction check
---> Package mysql-libs.x86_64 0:5.1.73-5.el6_6 will be updated
---> Package mysql-libs.x86_64 0:5.1.73-7.el6 will be an update
---> Package mysql-server.x86_64 0:5.1.73-5.el6_6 will be updated
---> Package mysql-server.x86_64 0:5.1.73-7.el6 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Updating:
mysql x86_64 5.1.73-7.el6 base 894 k
Updating for dependencies:
mysql-libs x86_64 5.1.73-7.el6 base 1.2 M
mysql-server x86_64 5.1.73-7.el6 base 8.6 M

Transaction Summary
================================================================================
Upgrade 3 Package(s)

Total download size: 11 M
Is this ok [y/N]:

透過使用 EPEL,我們可以從 CentOS / RHEL(Red Hat Enterprise Linux)上的 EPEL 倉庫安裝受信任且安全的第三方軟體包。

更新於:2020 年 1 月 21 日

823 次瀏覽

開啟你的 職業生涯

透過完成課程獲得認證

開始學習
廣告

© . All rights reserved.