Glassfish と mod_jk を使用して負荷分散とセッション レプリケーションを提供する環境を構成しています。
私のworker.propertiesは次のとおりです:
worker.list=i1,i2,loadbalancer
# default properties for workers
worker.template.type=ajp13
worker.template.port=28080
worker.template.lbfactor=1
worker.template.socket_timeout=300
# properties for node1
worker.i1.reference=worker.template
worker.i1.host=10.0.0.93
#worker.worker1.host=node1
# properties for worker2
worker.i2.reference=worker.template
worker.i2.host=10.0.0.38
#worker.worker2.host=node2
# properties for loadbalancer
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=i1,i2
worker.loadbalancer.sticky_session=true
私が行った手順は次のとおりです。サーバーから(SSH経由で)一元的に管理されるn1とn2の2つのノードを作成しました。
create-node-ssh --sshuser ubuntu --sshkeyfile /home/ubuntu/acme-auction.pem --nodehost 10.0.0.93 --installdir /home/ubuntu/glassfish3 n1
create-node-ssh --sshuser ubuntu --sshkeyfile /home/ubuntu/acme-auction.pem --nodehost 10.0.0.38 --installdir /home/ubuntu/glassfish3 n2
クラスター c1 を作成しました。
create-cluster --properties 'GMS_DISCOVERY_URI_LIST=generate:GMS_LISTENER_PORT=9090' c1
2 つのインスタンスを作成しました。
create-instance --cluster c1 --node n1 i1
create-instance --cluster c1 --node n2 i2
開始インスタンス i1 開始インスタンス i2
http-listener と network-listener を作成しました
create-http-listener --listenerport 28080 --listeneraddress 0.0.0.0 --defaultvs server jk-connector
create-network-listener --protocol http-listener-1 --listenerport 28080 --jkenabled true --target c1-config jk-connector
次に、routes JVM オプションを作成しました。
create-jvm-options --target c1 "-DjvmRoute=\${AJP_INSTANCE_NAME}"
...そして jvmRoute による sysyem プロパティ:
create-system-properties --target i1 AJP_INSTANCE_NAME=i1
create-system-properties --target i2 AJP_INSTANCE_NAME=i2
server_ip/app_name にアクセスして自分のアプリケーションを使用できると思っていました。
Cookie を見ると、次のことがわかります。
- JSESSIONIDVERSION、形式: value:number_of_operation
- JSESSIONID、形式: value.i1
- JREPLICA、形式: i2
(または i2 と i1 を交換した場合も同様)。これにより、レプリケーションが正しく設定されていると仮定できますが、i1 を停止すると、空白のページが表示され、Cookie に変更はありません (JSESSIONID は、「.i2」の最後の部分「.i1」を変更して、要求が i2 にルーティングされます。間違っていますか?)。ありがとう、アンドレア