Red Hat Training

A Red Hat training course is available for Red Hat JBoss Enterprise Application Platform

17.7.3. Apache HTTP Server への mod_jk モジュールのインストール (ZIP)

前提条件

  • このタスクを実行するには、サポートされる環境にインストールされた Apache HTTP Server を使用するか、JBoss Enterprise Web Server からインストールした Apache HTTP Server を使用する必要があります。JBoss Enterprise Web Server は JBoss EAP 6 ディストリビューションの一部であることに注意してください。
  • Red Hat Enterprise Linux ネイティブ Apache HTTP Server をインストールする必要がある場合は、『 『Red Hat Enterprise Linux デプロイメントガイド』』 の説明を使用します。
  • HP-UX ネイティブ Apache HTTP Server をインストールする必要がある https://h20392.www2.hp.com/portal/swdepot/displayInstallInfo.do?productNumber=HPUXWSATW232 場合は、にある 『HP-UX Web Server Suite Installation Guide』 の手順を使用します。
  • JBoss Enterprise Web Server をインストールする必要がある場合は、『JBoss Enterprise Web Server『インストールガイド』を参照してください』。
  • Apache HTTP Server を使用している場合は、ご使用のプラットフォーム用の JBoss EAP 6 ネイティブコンポーネントパッケージを Red Hat カスタマーポータルから https://access.redhat.com からダウンロードします。このパッケージには、mod_jk および mod_cluster 事前にコンパイルされたバイナリーの両方が含まれます。JBoss Enterprise Web Server を使用している場合は、すでに mod_jk のバイナリーが含まれています。
  • Red Hat Enterprise Linux (RHEL) 5 と Apache HTTP サーバー (httpd 2.2.3) を使用している場合は、mod_jk モジュールをロードする前に mod_perl モジュールをロードしてください。
  • 管理 (root) 権限を使用してログインする必要があります。
  • HTTPD 変数規則を表示するには、を参照してください。 「HTTPD 変数規則」

手順17.16 mod_jk モジュールのインストール

  1. mod_jk モジュールを設定します。

    1. HTTPD_HOME/conf.d/mod-jk.conf という新しいファイルを作成し、以下を追加します。
      JkMount ディレクティブ
      JkMount ディレクティブは、Apache HTTP Server が mod_jk モジュールに転送する必要がある URL を指定します。ディレクティブの設定に基づいて、mod_jk は受信した URL を正しいワーカーに送信します。
      静的コンテンツを直接提供し、Java アプリケーションのロードバランサーのみを使用するには、URL パスは /application/* である必要があります。mod_jk をロードバランサーとして使用するには、値 /* を使用してすべての URL を mod_jk に転送します。
      # Load mod_jk module
      # Specify the filename of the mod_jk lib
      LoadModule jk_module modules/mod_jk.so
      
      # Where to find workers.properties
      JkWorkersFile conf/workers.properties
      
      # Where to put jk logs
      JkLogFile logs/mod_jk.log
      
      # Set the jk log level [debug/error/info]
      JkLogLevel info 
      
      # Select the log format
      JkLogStampFormat  "[%a %b %d %H:%M:%S %Y]"
      
      # JkOptions indicates to send SSK KEY SIZE
      JkOptions +ForwardKeySize -ForwardDirectories
      
      # JkRequestLogFormat
      JkRequestLogFormat "%w %V %T"
      
      # Mount your applications
      # The default setting only sends Java application data to mod_jk.
      # Use the commented-out line to send all URLs through mod_jk.
      # JkMount /* loadbalancer
      JkMount /application/* loadbalancer
      
      # Add shared memory.
      # This directive is present with 1.2.10 and
      # later versions of mod_jk, and is needed for
      # for load balancing to work properly
      JkShmFile logs/jk.shm 
      
      # Add jkstatus for managing runtime data
      <Location /jkstatus/>
      JkMount status
      Order deny,allow
      Deny from all
      Allow from 127.0.0.1
      </Location>
      
      値を確認し、セットアップに適切であることを確認します。問題がなければ、ファイルを保存します。
    2. JKMountFile ディレクティブの指定

      mod-jk.conf の JKMount ディレクティブの他に、mod_jk に転送される複数の URL パターンを含むファイルを指定できます。
      1. 以下を HTTPD_HOME/conf/mod-jk.conf ファイルに追加します。
        # You can use external file for mount points.
        # It will be checked for updates each 60 seconds.
        # The format of the file is: /url=worker
        # /examples/*=loadbalancer
        JkMountFile conf/uriworkermap.properties
        
      2. 各 URL パターンが一致する行を指定して HTTPD_CONF/uriworkermap.properties という名前の新しいファイルを作成します。以下の例は、ファイルの構文例を示しています。
        # Simple worker configuration file
        /*=loadbalancer
        
    3. httpd のモジュールディレクトリーへの mod_jk.so ファイルのコピー

      注記
      これは、Apache HTTP サーバーに modules/ ディレクトリーに mod_jk.so がない場合にのみ必要です。JBoss EAP 6 のダウンロードとして含まれている Apache HTTP サーバーを使用している場合は、この手順を省略できます。
      Native Web Server Connectors Zip パッケージを展開します。オペレーティングシステムが 32 ビットまたは 64 ビットであるかによって、EAP_HOME/modules/ system/layers/base/native/lib/httpd/modules/ ディレクトリーまたはEAP_HOME/modules/layers/base/native/lib64/httpd/modules/ ディレクトリーのいずれかで mod_jk.so ファイルを見つけます。
      ファイルを HTTPD_MODULES/ ディレクトリーにコピーします。
  2. mod_jk ワーカーノードを設定します。

    1. HTTPD_CONF/workers.properties という新しいファイルを作成します。以下の例を開始点として使用し、必要に応じてファイルを変更します。
      # Define list of workers that will be used
      # for mapping requests
      worker.list=loadbalancer,status
      
      # Define Node1
      # modify the host as your host IP or DNS name.
      worker.node1.port=8009
      worker.node1.host=node1.mydomain.com
      worker.node1.type=ajp13
      worker.node1.ping_mode=A
      worker.node1.lbfactor=1 
      
      # Define Node2
      # modify the host as your host IP or DNS name.
      worker.node2.port=8009
      worker.node2.host=node2.mydomain.com
      worker.node2.type=ajp13
      worker.node2.ping_mode=A
      worker.node2.lbfactor=1
      
      # Load-balancing behavior
      worker.loadbalancer.type=lb
      worker.loadbalancer.balance_workers=node1,node2
      worker.loadbalancer.sticky_session=1
      
      # Status worker for managing load balancer
      worker.status.type=status
      
      workers.properties ファイルの構文および高度な設定オプションの詳細は、「Apache mod_jk ワーカーの設定リファレンス」 を参照してください。
  3. Web サーバーを再起動します。

    Web サーバーの再起動方法は、Red Hat Enterprise Linux の Apache HTTP サーバーを使用するか、JBoss Enterprise Web Server に含まれる Apache HTTP Server を使用しているかによって異なります。以下の方法のいずれかを選択します。
    • Red Hat Enterprise Linux の Apache HTTP Server

      以下のコマンドを実行します。
      [root@host]# service httpd restart
    • JBoss Enterprise Web Server の Apache HTTP Server

      JBoss Enterprise Web Server は、Red Hat Enterprise Linux と Microsoft Windows Server の両方で実行されます。Web サーバーの再起動方法はそれぞれ異なります。
      • RPM からインストールされた Red Hat Enterprise Linux

        Red Hat Enterprise Linux では、JBoss Enterprise Web Server は Web サーバーをサービスとしてインストールします。Web サーバーを再起動するには、以下の 2 つのコマンドを実行します。
        [root@host ~]# service httpd stop
        [root@host ~]# service httpd start
        
      • Zip からインストールされた Red Hat Enterprise Linux

        Zip アーカイブから JBoss Enterprise Web Server Apache HTTP Server をインストールしている場合は、apachectl コマンドを使用して Web サーバーを再起動します。mingw _HOME を、JBoss Enterprise Web Server Apache HTTP Server を展開したディレクトリーに置き換えます。
        [root@host ~]# EWS_HOME/httpd/sbin/apachectl restart
        
      • Microsoft Windows Server

        コマンドプロンプトで以下のコマンドを管理権限で実行します。
        net stop Apache2.2
        net start Apache2.2
        
      • Solaris

        コマンドプロンプトで以下のコマンドを管理権限で実行します。mingw _HOME を、JBoss Enterprise Web Server Apache HTTP Server を展開したディレクトリーに置き換えます。
        [root@host ~] EWS_HOME/httpd/sbin/apachectl restart
        

結果

Apache HTTP サーバーが mod_jk ロードバランサーを使用するよう設定されました。JBoss EAP 6 が mod_jk を認識するよう設定するには、「外部 Web サーバーからの要求を許可するよう JBoss EAP 6 を設定」 を参照してください。