2013/09/12

tomcat apache loadblancer worker

エラーが出った。。
The attribute 'worker.loadbalancer.balanced_workers' is deprecated - please check the documentation for the correct replacement.
=>loadbalancerはworkerであり、更に代表なworkerである



mod-jk.conf:
--------
#URLマッピング
JkMount /* loadbalancer
----------



workers.properties
--------
worker.list=tomcat1,tomcat2,loadbalancer

#tomcat1ワーカー
worker.tomcat1.port=18009
worker.tomcat1.host=localhost
worker.tomcat1.type=ajp13
worker.tomcat1.lbfactor=1

#tomcat2ワーカー
worker.tomcat2.port=28009
worker.tomcat2.host=localhost
worker.tomcat2.type=ajp13
worker.tomcat2.lbfactor=1

# Load-balancingワーカー
worker.loadbalancer.type=lb
worker.loadbalancer.balanced_workers=tomcat1,tomcat2
worker.loadbalancer.sticky_session=1


!!!
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=node1,node2
worker.loadbalancer.sticky_session=True
#worker.loadbalancer.sticky_session_force=True

We’re defining a worker named loadbalancer with it’s type set to lb (obviously short for loadbalancer) and assign node1 and node2 to handle the load.

Sticky sessions are an important feature if you rely on jSessionIDs and are not using any session-replication layer. If sticky_session is True a request always gets routed back to the node which assigned this jSessionID. If that host should get disconnected, crash or become unreachable otherwise the request will be forwarded to another host in our cluster (although not too successfully as the session-id is invalid in it’s context).
You can prevent this from happening by setting sticky_session_force to True. In this case if the host handling the requested session-id fails, Apache will generate an internal server error 500.

Now we’ve told mod_jk about our setup. If you are using sticky sessions, you’ll need to tell Tomcat to append its node-id to the session id. This needs to be the same as worker.name.jvm_route, which by default is the worker’s name (in our case node1 and node2).



tomcatのserver.xml:
 <!-- You should set jvmRoute to support load-balancing via AJP ie :-->
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat1">
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat2">