如何在 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://www.mysqlserver.cn 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://www.mysqlserver.cn 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 仓库安装受信任且安全的第三方软件包。
广告