13.6.4. ISAPI がクライアント要求を複数の Enterprise Application Platform サーバーで分散するよう設定する

概要

この設定により、クライアント要求は指定した Enterprise Application Platform サーバーで分散されます。クライアント要求を、デプロイメントごとに、特定の Enterprise Application Platform サーバーに送信する場合は、「ISAPI リダイレクターがクライアント要求を Enterprise Application Platform に送信するよう設定する」を参照してください。

この設定は IIS サーバーで行われます。また、Enterprise Application Platform がすでに設定されていることを前提とします (「Enterprise Application Platformが外部 HTTPD から要求を受け入れるように設定」を参照)。

手順13.14 タスク

  1. ログ、プロパティーファイル、およびロックファイルを格納するディレクトリーを作成します。

    この手順の残りでは、この目的のためにディレクトリー C:\connectors\ を使用していることを前提とします。異なるディレクトリーを使用する場合は、適切に手順を変更してください。
  2. isapi_redirect.properties ファイルを作成します。

    C:\connectors\isapi_redirect.properties という名前の新しいファイルを作成します。以下の内容をファイルにコピーします。値 JBOSS_NATIVE_HOME を、タスク 「Microsoft IIS が ISAPI リダイレクターを使用するよう設定する」 の実行時に JBoss ネイティブコンポーネントをインストールした実際の場所に置き換えます。
    # Configuration file for the ISAPI Redirector
    # Extension uri definition
    extension_uri=JBOSS_NATIVE_HOME/sbin/isapi_redirect.dll
    
    # Full path to the log file for the ISAPI Redirector
    log_file=c:\connectors\isapi_redirect.log
    
    # Log level (debug, info, warn, error or trace)
    # Use debug only testing phase, for production switch to info
    log_level=debug
    
    # Full path to the workers.properties file
    worker_file=c:\connectors\workers.properties
    
    # Full path to the uriworkermap.properties file
    worker_mount_file=c:\connectors\uriworkermap.properties
    
    #OPTIONAL: Full path to the rewrite.properties file 
    rewrite_rule_file=c:\connectors\rewrite.properties
    
    rewrite.properties ファイルを使用しない場合は、行の先頭に # 文字を記入して最後の行をコメントアウトします。詳細については、ステップ 5 を参照してください。
  3. uriworkermap.properties フィルを作成します。

    uriworkermap.properties ファイルには、デプロイされたアプリケーション URL と、それらへの要求を処理するワーカー間のマッピングが含まれます。以下のサンプルファイルは負荷分散が設定されたファイルの構文を示しています。ワイルドカード (*) 文字はさまざまな URL サブディレクトリーのすべての要求を router という名前のロードバランサーに送信します。ロードバランサーの設定については、ステップ 4 を参照してください。
    uriworkermap.properties ファイルを C:\connectors\ に格納してください。
    # images, css files, path /status and /web-console will be
    # provided by nodes defined in the load-balancer called "router"
    /css/*=router
    /images/*=router
    /status=router
    /web-console|/*=router
    
    # Example of exclusion from mapping, logo.gif won't be displayed  
    !/web-console/images/logo.gif=*
    
    # Requests to /app-01 and /app-02 will be routed to nodes defined
    # in the load-balancer called "router"
    /app-01|/*=router
    /app-02|/*=router
    
    # mapping for management console, nodes in cluster can be enabled or disabled here
    /jkmanager|/*=status
    
  4. workers.properties ファイルを作成します。

    workers.properties ファイルには、ワーカーラベルとサーバーインスタンス間のマッピング定義が含まれます。以下のサンプルファイルはファイルの構文を示しています。ロードバランサーは、ファイルの最後で設定され、ワーカー worker01 および worker02 から構成されます。workers.properties ファイルは Apache mod_jk 設定に使用されるのと同じファイルの構文に従います。workers.propertie ファイルの構文の詳細については、「Apache Mod_jk ワーカーの設定リファレンス」を参照してください。
    このファイルを C:\connectors\ ディレクトリーに格納してください。
    # The advanced router LB worker
    worker.list=router,status
    
    # First EAP server definition, port 8009 is standard port for AJP in EAP
    #
    # lbfactor defines how much the worker will be used. 
    # The higher the number, the more requests are served
    # lbfactor is useful when one machine is more powerful 
    # ping_mode=A – all possible probes will be used to determine that
    # connections are still working
    
    worker.worker01.port=8009
    worker.worker01.host=127.0.0.1
    worker.worker01.type=ajp13
    worker.worker01.ping_mode=A
    worker.worker01.socket_timeout=10
    worker.worker01.lbfactor=3
    
    # Second EAP server definition
    worker.worker02.port=8009
    worker.worker02.host= 127.0.0.100
    worker.worker02.type=ajp13
    worker.worker02.ping_mode=A
    worker.worker02.socket_timeout=10
    worker.worker02.lbfactor=1
    
    # Define the LB worker
    worker.router.type=lb
    worker.router.balance_workers=worker01,worker02
    
    # Define the status worker for jkmanager
    worker.status.type=status
    
  5. rewrite.properties ファイルを作成します。

    rewrite.properties ファイルには、特定のアプリケーションの単純な URL 書き換えルールが含まれます。以下の例で示されているように、書き換えられたパスは名前と値のペアを使用して指定されます。このファイルを C:\connectors\ ディレクトリーに格納してください。
    #Simple example
    # Images are accessible under abc path
    /app-01/abc/=/app-01/images/
    
  6. IIS サーバーを再起動します。

    バージョンに応じて、IIS サーバーを再起動する適切な手順を実行します。
    • IIS 6

      C:\> net stop iisadmin /Y
      C:\> net start w3svc
      
    • IIS 7

      C:\> net stop was /Y
      C:\> net start w3svc
      
結果

IIS サーバーが、workers.properties ファイルに記述された Enterprise Application Platform サーバーにクライアント要求を送信し、サーバー間で負荷を均等に分散するよう設定されます。