Configuring Tomcat Workers for Load Balancing
A Tomcat worker is a Tomcat instance that runs behind a web server such as Apache. The web server forwards the servlet requests to the worker and the worker executes the servlets or any other content on behalf of the web server.
In a clustered OneData environment, you must configure one Tomcat worker as a load balancer worker and configure multiple Tomcat workers to distribute the requests between them. The load balancer is a worker that does not directly communicate with Tomcat. Instead, it manages several real workers, called members or sub workers of the load balancer. You can configure the workers for the Tomcat web server plug-in by defining them in the workers.properties file. For more information about the workers.properties file, see the Apache documentation.
This topic describes how to configure two workers and a load balancer worker. You can configure as many workers as required in your cluster environment.
To configure workers for load balancing
1. In the load balancer machine, open a text editor.
2. Copy and paste the following configuration details to create a workers.properties file.
# Define 1 real worker using ajp13
worker.list=balancer
worker.balancer.type=lb
worker.balancer.balance_workers=worker1,worker2
worker.balancer.method=B
# Set properties for worker1 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=host_IP
worker.worker1.port=AJP_port|
worker.worker1.lbfactor=1
# Set properties for worker2 (ajp13)
worker.worker2.type=ajp13
worker.worker2.host=host_IP
worker.worker2.port=AJP_port
worker.worker2.lbfactor=1
3. Change the values for Host IP and AJP Port in the above configuration based on the clustering environment you want to set up.
Host IP is the IP address of the cluster node in which the OneData instance is installed. AJP Port is the port the load balancer uses to communicate with a OneData instance.
Important: You must use the same worker names in all the configurations. balancer, worker1 and worker2 are the worker names that you can choose.
4. Save the file as workers.properties in the folder where the httpd.conf file is located. Typically, this is in the folder apache_server_root\conf.
5. Go to apache_server_root\conf, and open the httpd.conf file.
6. Make the following changes in the httpd.conf file:
a. Uncomment the following lines:
LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.soLoadModule slotmem_shm_module modules/mod_slotmem_shm.so LoadModule proxy_module modules/mod_proxy.soLoadModule proxy_ajp_module modules/mod_proxy_ajp.soLoadModule proxy_balancer_module modules/mod_proxy_balancer.so
b. Append the following configuration details:
Proxy balancer://OneData_cluster stickysession=JSESSIONIDBalancerMember ajp://Apache http server IP:AJP-Port1 min=10 max=100 route=node1 loadfactor=1 BalancerMember ajp://Apache http server IP:AJP-Port2 min=20 max=200 route=node2 loadfactor=1/ProxyProxyPass /OneData_balancer://OneData_cluster/OneDataLocation /balancer-managerSetHandler balancer-manager/Location
7. At the command prompt, type httpd.exe to start Apache in a DOS box.
8. Type httpd.exe -k install to install Apache as a service.