第 3 章 使用方法

本章论述了重建和使用 Red Hat Software Collections 3.2 所需的步骤,以及部署使用 Red Hat Software Collections 的应用程序。

3.1. 使用 Red Hat Software Collections

3.1.1. 从 Software Collection 运行可执行文件

要从特定的 Software Collection 运行可执行文件,在 shell 提示符下输入以下命令:
scl enable software_collection... 'command...'
或者,使用以下命令:
scl enable software_collection... -- command...
software_collection 替换为您要使用的空间分隔的 Software Collections 列表,并使用您要运行的命令替换 software_collection。例如,要执行存储在名为 hello.pl 的 Perl 程序以及 perl526 Software Collection 中的 Perl 解释器,请输入:
~]$ scl enable rh-perl526 'perl hello.pl'
Hello, World!
您可以使用 scl 工具执行任何命令,从而导致它使用所选 Software Collection 的可执行文件运行,并优先选择其对应的 Red Hat Enterprise Linux 系统。有关随 Red Hat Software Collections 一起发布的 Software Collections 的完整列表,请参阅 表 1.1 “Red Hat Software Collections 3.2 组件”

3.1.2. 使用 Software Collection 作为默认运行 Shell 会话

要在首选使用所选 Software Collection 中启动带有可执行文件的新 shell 会话,在 shell 提示符后输入以下内容:
scl enable software_collection... bash
software_collection 替换为您要使用的以空格分隔的 Software Collections 列表。例如,要启动一个带有 python27rh-postgresql10 Software Collections 的新 shell 会话作为默认值,请输入:
~]$ scl enable python27 rh-postgresql10 bash
在当前会话中启用的 Software Collections 列表存储在 $X_SCLS 环境变量中,例如:
~]$ echo $X_SCLS
python27 rh-postgresql10
有关随 Red Hat Software Collections 一起发布的 Software Collections 的完整列表,请参阅 表 1.1 “Red Hat Software Collections 3.2 组件”

3.1.3. 从 Software Collection 运行系统服务

从 Red Hat Enterprise Linux 6 中的 Software Collection 运行系统服务

包括系统服务的软件集合在 /etc/rc.d/init.d/ 目录中安装相应的初始化脚本。要在当前会话中启动该服务,以 root 用户身份在 shell 提示符后输入以下内容:
service software_collection-service_name start
software_collection 替换为 Software Collection 和 service_name 的名称,作为您要启动的服务的名称。
要将此服务配置为在引导时自动启动,请以 root 用户身份输入以下命令:
chkconfig software_collection-service_name on
例如,要从 rh- postgresql 96 软件集合启动 postgresql 服务,并在运行级别 2、3、4 和 5 中启用它,以 root 用户身份:
~]# service rh-postgresql96-postgresql start
Starting rh-postgresql96-postgresql service:                  [  OK  ]
~]# chkconfig rh-postgresql96-postgresql on
有关如何在 Red Hat Enterprise Linux 6 中管理系统服务的更多信息,请参阅 Red Hat Enterprise Linux 6 部署指南。有关随 Red Hat Software Collections 一起发布的 Software Collections 的完整列表,请参阅 表 1.1 “Red Hat Software Collections 3.2 组件”

从 Red Hat Enterprise Linux 7 中的 Software Collection 运行系统服务

在 Red Hat Enterprise Linux 7 中,初始化脚本已被 systemd 服务单元文件替代,该文件以 .service 文件扩展结尾,并作为初始化脚本提供类似的目的。要在当前会话中启动服务,以 root 用户身份执行以下命令:
systemctl start software_collection-service_name.service
software_collection 替换为 Software Collection 和 service_name 的名称,作为您要启动的服务的名称。
要将此服务配置为在引导时自动启动,请以 root 用户身份输入以下命令:
systemctl enable software_collection-service_name.service
例如,要从 rh- postgresql 10 Software Collection 启动 postgresql 服务并在引导时启用它,以 root 用户身份键入:
~]# systemctl start rh-postgresql10-postgresql.service
~]# systemctl enable rh-postgresql10-postgresql.service
有关如何在 Red Hat Enterprise Linux 7 中管理系统服务的更多信息,请参阅 Red Hat Enterprise Linux 7 系统管理员指南。有关随 Red Hat Software Collections 一起发布的 Software Collections 的完整列表,请参阅 表 1.1 “Red Hat Software Collections 3.2 组件”

3.2. 从 Software Collection 访问 man page

每个 Software Collection 均包含一个常规手册页,用于描述此组件的内容。每个手册页的名称都与组件相同,它位于/opt/rh 目录中。
要读取 Software Collection 的 man page,请输入以下命令:
scl enable software_collection 'man software_collection'
software_collection 替换为特定的 Red Hat Software Collections 组件。例如,要显示 rh-mariadb102 的手册页,请输入:
~]$ scl enable rh-mariadb102 "man rh-mariadb102"

3.3. 部署使用 Red Hat Software Collections 的应用程序

通常,您可以使用以下两种方法之一来部署依赖于生产环境中的 Red Hat Software Collections 组件的应用程序:
  • 手动安装所有必需的 Software Collections 和软件包,然后部署应用程序,或者
  • 为您的应用程序创建一个新的 Software Collection,并将所有必需的 Software Collections 和其他软件包指定为依赖项。
有关如何手动安装单独的 Red Hat Software Collections 组件的详情,请参考 第 2.2 节 “安装 Red Hat Software Collections”。有关如何使用 Red Hat Software Collections 的详情,请参考 第 3.1 节 “使用 Red Hat Software Collections”。有关如何创建自定义 Software Collection 或扩展现有软件集合的详细信息,请阅读 Red Hat Software Collections Packaging Guide

3.4. Red Hat Software Collections 容器镜像

基于 Red Hat Software Collections 的容器镜像包括应用程序、守护进程和数据库。镜像可以在 Red Hat Enterprise Linux 7 服务器和 Red Hat Enterprise Linux Atomic Host 上运行。有关其用法的详情,请参考使用 Red Hat Software Collections 3 容器镜像。有关基于 Red Hat Software Collections 版本 2.4 及更早版本的容器镜像的详情,请参阅使用 Red Hat Software Collections 2 容器镜像
Red Hat Software Collections 3.2 提供以下容器镜像:
  • rhscl/devtoolset-8-toolchain-rhel7
  • rhscl/devtoolset-8-perftools-rhel7
  • rhscl/httpd-24-rhel7
  • rhscl/mysql-80-rhel7
  • rhscl/nginx-114-rhel7
  • rhscl/php-72-rhel7
  • rhscl/varnish-6-rhel7
以下容器镜像基于 Red Hat Software Collections 3.1:
  • rhscl/devtoolset-7-toolchain-rhel7
  • rhscl/devtoolset-7-perftools-rhel7
  • rhscl/mongodb-36-rhel7
  • rhscl/perl-526-rhel7
  • rhscl/php-70-rhel7
  • rhscl/postgresql-10-rhel7
  • rhscl/ruby-25-rhel7
  • rhscl/varnish-5-rhel7
以下容器镜像基于 Red Hat Software Collections 3.0:
  • rhscl/mariadb-102-rhel7
  • rhscl/mongodb-34-rhel7
  • rhscl/nginx-112-rhel7
  • rhscl/nodejs-8-rhel7
  • rhscl/php-71-rhel7
  • rhscl/postgresql-96-rhel7
  • rhscl/python-36-rhel7
以下容器镜像基于 Red Hat Software Collections 2.4:
  • rhscl/devtoolset-6-toolchain-rhel7 (EOL)
  • rhscl/devtoolset-6-perftools-rhel7 (EOL)
  • rhscl/nginx-110-rhel7
  • rhscl/nodejs-6-rhel7
  • rhscl/python-27-rhel7
  • rhscl/ruby-24-rhel7
  • rhscl/ror-50-rhel7
  • rhscl/thermostat-16-agent-rhel7 (EOL)
  • rhscl/thermostat-16-storage-rhel7 (EOL)
以下容器镜像基于 Red Hat Software Collections 2.3:
  • rhscl/mysql-57-rhel7
  • rhscl/perl-524-rhel7
  • rhscl/redis-32-rhel7
  • rhscl/mongodb-32-rhel7
  • rhscl/php-56-rhel7 (EOL)
  • rhscl/python-35-rhel7
  • rhscl/ruby-23-rhel7
以下容器镜像基于 Red Hat Software Collections 2.2:
  • rhscl/devtoolset-4-toolchain-rhel7 (EOL)
  • rhscl/devtoolset-4-perftools-rhel7 (EOL)
  • rhscl/mariadb-101-rhel7
  • rhscl/nginx-18-rhel7 (EOL)
  • rhscl/nodejs-4-rhel7 (EOL)
  • rhscl/postgresql-95-rhel7
  • rhscl/ror-42-rhel7
  • rhscl/thermostat-1-agent-rhel7 (EOL)
  • rhscl/varnish-4-rhel7 (EOL)
以下容器镜像基于 Red Hat Software Collections 2.0:
  • rhscl/mariadb-100-rhel7 (EOL)
  • rhscl/mongodb-26-rhel7 (EOL)
  • rhscl/mysql-56-rhel7 (EOL)
  • rhscl/nginx-16-rhel7 (EOL)
  • rhscl/passenger-40-rhel7 (EOL)
  • rhscl/perl-520-rhel7 (EOL)
  • rhscl/postgresql-94-rhel7 (EOL)
  • rhscl/python-34-rhel7 (EOL)
  • rhscl/ror-41-rhel7 (EOL)
  • rhscl/ruby-22-rhel7 (EOL)
  • rhscl/s2i-base-rhel7
标记为"生命周期结束(EOL) "的镜像不再被支持。