网站搜索

如何在 CentOS 和 RHEL 上使用 Yum 安装软件包组


CentOS/RHEL 上,您可以单独安装软件包,也可以在一次操作中以组的形式安装多个软件包。软件包组包含执行相关任务的软件包,例如开发工具、Web 服务器(例如 LAMP 或 LEMP)、桌面(也可以用作瘦客户端的最小桌面)等等。

另请阅读:列出 RHEL、CentOS 和 Fedora 中所有已安装软件包的 3 种方法

在本指南中,我们将解释如何在 CentOS、RHEL 和 Fedora 发行版中使用 YUM 软件包管理器安装一组软件包。

从 yum 版本 3.4.2 开始,引入了 groups 命令,现在可以在 Fedora-19+CentOS/RHEL-7+ 上运行;它汇集了处理组的所有子命令。

要列出所有 yum 存储库中的可用组,请使用 list 子命令,如下所示:

yum groups list
OR
yum grouplist
Loaded plugins: changelog, fastestmirror
There is no installed groups file.
Maybe run: yum groups mark convert (see man yum)
Loading mirror speeds from cached hostfile
 * base: mirrors.linode.com
 * epel: mirror.freethought-internet.co.uk
 * extras: mirrors.linode.com
 * updates: mirrors.linode.com
Available Environment Groups:
   Minimal Install
   Compute Node
   Infrastructure Server
   File and Print Server
   MATE Desktop
   Basic Web Server
   Virtualization Host
   Server with GUI
   GNOME Desktop
   KDE Plasma Workspaces
   Development and Creative Workstation
Available Groups:
   CIFS file server
   Compatibility Libraries
   Console Internet Tools
....

您可以使用summary子命令查看组的总数:

yum groups summary
Loaded plugins: changelog, fastestmirror
There is no installed groups file.
Maybe run: yum groups mark convert (see man yum)
Loading mirror speeds from cached hostfile
 * base: mirrors.linode.com
 * epel: mirror.freethought-internet.co.uk
 * extras: mirrors.linode.com
 * updates: mirrors.linode.com
Available Environment Groups: 11
Available Groups: 38
Done

在继续安装一组软件包之前,您可以使用 info 子命令查看组 ID、组的简短描述以及不同类别(强制、默认和可选软件包)下包含的各种软件包。

yum groups info "Development Tools"
Loaded plugins: changelog, fastestmirror
There is no installed groups file.
Maybe run: yum groups mark convert (see man yum)
Loading mirror speeds from cached hostfile
 * base: mirrors.linode.com
 * epel: mirror.freethought-internet.co.uk
 * extras: mirrors.linode.com
 * updates: mirrors.linode.com

Group: Development Tools
 Group-Id: development
 Description: A basic development environment.
 Mandatory Packages:
   +autoconf
   +automake
    binutils
   +bison
   +flex
    gcc
   +gcc-c++
    gettext
   +libtool
    make
   +patch
    pkgconfig
    redhat-rpm-config
   +rpm-build
   +rpm-sign
...

要安装一组软件包,例如开发工具(基本开发环境),请使用 install 子命令,如下所示。

yum groups install "Development Tools"
Loaded plugins: changelog, fastestmirror
There is no installed groups file.
Maybe run: yum groups mark convert (see man yum)
base                                                                                                                                                 | 3.6 kB  00:00:00     
epel/x86_64/metalink                                                                                                                                 |  23 kB  00:00:00     
epel                                                                                                                                                 | 4.3 kB  00:00:00     
extras                                                                                                                                               | 3.4 kB  00:00:00     
mariadb                                                                                                                                              | 2.9 kB  00:00:00     
updates                                                                                                                                              | 3.4 kB  00:00:00     
(1/4): extras/7/x86_64/primary_db                                                                                                                    | 129 kB  00:00:15     
(2/4): updates/7/x86_64/primary_db                                                                                                                   | 3.6 MB  00:00:15     
(3/4): epel/x86_64/primary_db                                                                                                                        | 6.1 MB  00:00:15     
(4/4): epel/x86_64/updateinfo                                                                                                                        | 838 kB  00:00:15     
Loading mirror speeds from cached hostfile
 * base: mirrors.linode.com
 * epel: mirror.freethought-internet.co.uk
 * extras: mirrors.linode.com
 * updates: mirrors.linode.com
Resolving Dependencies
--> Running transaction check
---> Package autoconf.noarch 0:2.69-11.el7 will be installed
--> Processing Dependency: m4 >= 1.4.14 for package: autoconf-2.69-11.el7.noarch
---> Package automake.noarch 0:1.13.4-3.el7 will be installed
...

要删除一个组(这会从系统中删除该组中的所有包),只需使用remove子命令即可。

yum groups remove "Development Tools"

您还可以使用以下命令将组标记为已安装。

yum groups mark install "Development Tools"

目前为止就这样了!您可以在 yum 手册页的 groups 小节下找到更多子命令及其说明。

您可能还想阅读以下有关 Yum 包管理器的文章。

  1. 如何安装和使用“yum-utils”来维护 Yum 并提高其性能
  2. 使用 Yum 命令禁用/锁定某些软件包更新的 4 种方法
  3. 如何修复 Yum 错误:数据库磁盘映像格式错误
  4. 如何使用“Yum History”查找已安装或已删除的软件包信息

在本指南中,我们解释了如何在 CentOS、RHEL 和 Fedora 中使用 YUM 包管理器安装一组包。使用下面的评论表将您对本文的疑问或观点发送给我们。