この手順を実行する前に、データサービスパッケージをインストールしておく必要があります。
Sun Cluster HA for Apache Tomcat パッケージをインストールしなかった場合は、「Sun Cluster HA for Apache Tomcat パッケージのインストール」に進みます。
Apache Tomcat のファイルシステムをフェイルオーバーファイルシステムとしてマウントすることが前提です。
Apache Tomcat をホスティングするクラスタノードの 1 つで、スーパーユーザーになります。
# scrgadm -a -t SUNW.gds |
SUNW.HAStoragePlus というリソースタイプを登録します。
# scrgadm -a -t SUNW.HAStoragePlus |
フェイルオーバーリソースグループを作成します。
# scrgadm -a -g Apache-Tomcat-failover-resource-group |
Apache Tomcat ディスク記憶装置に対応するリソースを作成します。
# scrgadm -a -j Apache-Tomcat-has-resource \ > -g Apache-Tomcat-failover-resource-group \ > -t SUNW.HAStoragePlus \ > -x FilesystemMountPoints=Apache Tomcat- instance-mount-points |
Apache Tomcat の論理ホスト名に対応するリソースを作成します。
# scrgadm -a -L -j Apache-Tomcat-lh-resource \ > -g Apache-Tomcat-failover-resource-group \ > -l Apache-Tomcat-logical-hostname |
Apache Tomcat ディスク記憶装置と論理ホスト名のリソースが組み込まれたフェイルオーバーリソースグループを有効にします。
# scswitch -Z -g Apache-Tomcat-failover-resource-group |
Sun Cluster HA for Apache Tomcat で必要となるパラメータファイルを用意します。
# cd /opt/SUNWsctomcat/bin # cp pfile desired place |
ファイル内のコメントに従って、パラメータファイル pfile を編集します。次に例を示します。
#!/usr/bin/ksh # Set the Apache Tomcat specific environment variables which the start, # stop and check functions will use # # EnvScript Script to set runtime environment for tomcat # User Apache Tomcat user name # Basepath Absolute pathname to Tomcat Home directory i.e. 4.x CATALINA_HOME # or TOMCAT_HOME for 3.x # Host Hostname to test Apache Tomcat # Port Port where Apache Tomcat is configured # TestCmd Apache Tomcat test command # Startwait Sleeping $Startwait seconds after completion of the # start command (日本語) #!/usr/bin/ksh # 起動、停止、およびチェックの各機能が使用する # Apache Tomcat 固有の環境変数を設定する # # EnvScript Tomcat の実行時環境を設定するスクリプト # User Apache Tomcat ユーザー名 # Basepath Tomcat のホームディレクトリの絶対パス。つまり、4.x CATALINA_HOME # またはTOMCAT_HOME for 3.x # Host Apache Tomcat をテストするホストの名前 # Port Apache Tomcat が構成されるポート # TestCmd Apache Tomcat のテストコマンド # Startwait 起動コマンドが完了したあと$Startwait 秒の間休眠状態 # になる EnvScript= User= Basepath= Host= Port=8080 TestCmd="get /index.jsp" ReturnString="CATALINA" Startwait=20 |
次に、Apache Tomcat 4.1.24 の場合の例を示します。
EnvScript=/global/mnt1/tomtest/env.ksh User=tomtest Basepath=/global/mnt1/tomtest/jakarta-tomcat-4.1.24 Host=tomcat-lh Port=8080 TestCmd="get /index.jsp" ReturnString="CATALINA" Startwait=20
これは、デフォルトの起動ページ index.jsp を使用し、スタンドアロンの Web サーバーとして構成された Apache Tomcat 4.1.24 の例です。この起動ページには、文字列 CATALINA が含まれます。
Apache Tomcat データサービスをホスティングできる各ノードでこれらのパラメータファイルを使用できるようにする必要があります。フェイルオーバー構成の場合は、共有記憶装置に保存します。各ノード上の Apache Tomcat インスタンスごとに、異なるパラメータファイルを使用することはできません。
手順 8 を、必要なすべての Apache Tomcat インスタンスで繰り返します。
必要な Apache Tomcat コンポーネントを作成して登録します。
# cd /opt/SUNWsctomcat/util # cp sctomcat_config desired place # cp sctomcat_register desired place |
ファイル内のコメントに従って、sctomcat_config ファイルを編集します。次に例を示します。
# これらのパラメータは、(key=value) フォームでカスタマイズできます。 # # Copyright 2003 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # This file will be sourced in by sctomcat_register and the parameters # listed below will be used. # # These parameters can be customized in (key=value) form # # RS - name of the resource for the application # RG - name of the resource group containing RS # PORT - name of the port number # LH - name of the LogicalHostname SC resource # SCALABLE - true or false for a scalable or failover resource # NETWORK - false or true, false for multiple master configurations without # shared address, in this case SCALABLE will be ignored # # PFILE - absolute pathname to the parameter file for the Tomcat resource # HAS_RS - name of the HAStoragePlus SC resource # (it can be a , separated list for the dependencies) (日本語) # このファイルは、sctomcat_register によってソースに取り込まれます。 # パラメータは以下のものが使用されます。 # # これらのパラメータは、(key=value) フォームを使用してカスタマイズできます。 # # RS - アプリケーションのリソースの名前 # RG - RS を含むリソースグループの名前 # PORT - ポート番号の名前 # LH - LogicalHostname SC リソースの名前 # SCALABLE - スケーラブルリソースかフェイルオーバーリソースかを true または false で指定 # NETWORK - false or true, false for multiple master configurations without # shared address, in this case SCALABLE will be ignored # # PFILE - Tomcat リソースのパラメータファイルの絶対パス名 # HAS_RS - HAStoragePlus SC リソースの名前 # (依存関係にもとづいて個別のリストにもできる) # RS= RG= PORT=8080 LH= SCALABLE=false NETWORK=true PFILE= HAS_RS= |
次に、Apache Tomcat の場合の例を示します。
RS=tomcat-res RG=tomcat-rg PORT=8080 LH=tomcat-lh SCALABLE=false PFILE=/global/mnt1/pfile NETWORK=true HAS_RS=tomcat-hastplus-res |
sctomcat_config の編集後、リソースを登録します。
# ./sctomcat_register |
必要な Apache Tomcat インスタンスごとに、手順 7、8、および 9 を繰り返します。
Apache Tomcat リソースを有効にします。
手順 10 で作成した Apache Tomcat リソースごとにこの手順を繰り返します。
# scstat |
# scswitch -e -j Apache-Tomcat-resource |