第3章 使用法
この章では、Red Hat Software Collections 3.2 を再構築して使用し、Red Hat Software Collections を使用するアプリケーションをデプロイするために必要な手順を説明します。
3.1. Red Hat Software Collections の使用
3.1.1. Software Collection からの実行可能ファイルの実行
特定の Software Collection から実行ファイルを実行するには、シェルプロンプトで以下のコマンドを入力します。
scl enable software_collection... 'command...'
または、以下のコマンドを使用します。
scl enable software_collection... -- command...
software_collection を、使用する Software Collections のスペース区切りの一覧に置き換え、command を、実行するコマンドに置き換えます。たとえば、perl526 Software Collection から Perl インタープリターで
hello.pl
という名前が付けられたファイルに保存されている Perl プログラムを実行するには、以下を入力します。
~]$ scl enable rh-perl526 'perl hello.pl'
Hello, World!
この scl ユーティリティーを使用してコマンドを実行すると、同等の Red Hat Enterprise Linux システムの代わりに、選択した Software Collection から実行可能なものを使用して実行できます。Red Hat Software Collections で配布される Software Collections の完全リストは、表1.1「Red Hat Software Collections 3.2 コンポーネント」を参照してください。
3.1.2. デフォルトで Software Collection を使用したシェルセッションの実行
Red Hat Enterprise Linux の同等のものよりも選択した Software Collection の実行可能ファイルで新しいシェルセッションを開始するには、シェルプロンプトで次のように入力します。
scl enable software_collection... bash
software_collection を、使用する Software Collections のスペース区切りリストに置き換えます。たとえば、デフォルトとして python27 および rh-postgresql10 Software Collections で新しいシェルセッションを開始するには、以下を入力します。
~]$ 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 からシステムサービスの実行
システムサービスを含む Software Collections は、対応する init スクリプトを
/etc/rc.d/init.d/
ディレクトリーにインストールします。現行のセッションでそのようなサービスを起動するには、シェルプロンプトで root
として以下を入力します。
service software_collection-service_name start
software_collection を、Software Collection および service_name を、開始するサービスの名前に置き換えます。
システムの起動時にこのサービスが自動的に開始するように設定するには、
root
で以下のコマンドを入力します。
chkconfig software_collection-service_name on
たとえば、rh-postgresql96 Software Collection から
postgresql
サービスを起動し、ランレベル 2、3、4、および 5 で root で有効にするには、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 では、init スクリプトが
systemd
サービスのユニットファイルに置き換えられました。このファイルは、.service
ファイル拡張子で終わり、init スクリプトとして同様の目的で使用されています。現行セッションでサービスを起動するには、root
で以下のコマンドを実行します。
systemctl start software_collection-service_name.service
software_collection を、Software Collection および service_name を、開始するサービスの名前に置き換えます。
システムの起動時にこのサービスが自動的に開始するように設定するには、
root
で以下のコマンドを入力します。
systemctl enable software_collection-service_name.service
たとえば、rh-postgresql10 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 System Administrator's Guide を参照してください。Red Hat Software Collections で配布される Software Collections の完全リストは、表1.1「Red Hat Software Collections 3.2 コンポーネント」を参照してください。