As part of our Cloud Apache Tomcat Series of articles, I have
put together a small tutorial to guide people on how to disable, enable, and stopped workers at run time.
What you need to know?
If you are an apache tomcat administrator or avid user, you will probably find this article useful. Also if you have setup tomcat as a load balancer with apache mod_jk module in the past this journal entry will be helpful.
Basically the main topic here is how to change a worker variables at run time using the mod_jk status manager api.
Let’s see. In our previous post we show an example on how to setup an apache load balancer with three tomcat workers using mod_jk apache module. You can find this in our post here.
The first step is to make sure you have the jkmanager api enabled within apache load balancer. The apache load balancer is responsible on sending request to each tomcat worker, the ultimate goal is to tell the balancer device or devices that we are going to disable, enable or stop a worker. Enabling us to modify that worker in any way even restarting it or shuting down completely.
In order for us to enable the jkmanager module in the apache load balancer we need to have the following lines in our httpd.conf file:
JkMount jkstatus order deny,allow allow from your.ip.add.ress allow from 127.0.0.1 deny from all ... JkMount /jkmanager/* jkstatus ...
The workers.properties file is the place where you tell the load balancer how is configured. The changes on the “workers.properties” file are:
Now that you have setup a worker called jkstatus mounted in httpd.conf file in jkmanager location when you hit via a browser the url http://your.web.server/jkmanager/ you should find a management console for your load balancer and all your workers. Now let’s get to business.
If you want to disable worker one at the load balancer you need to query the following url:
If you want to enable all workers again to start accepting new requests you need to query the following url:
In the mist of implementing this solution for my company, I posted a question in the StackOverflow forum that lead me to the answer. The following link is the answer posted by me to my question (kind of ironic) but this website is super helpful. A very helpful link to build more of the urls to execute actions in the load balancer is the tomcat reference official page.
What to do with this knowledge?
Now that you know how to automatically disable, enable, and stop workers, you are able to create an array of servers ready to use in Amazon EC2, GoGrid, or even in your private cloud. Disable or pause the servers that you don’t need immediately and bring execute the urls to enabled them with wget or any other command line execution web execution program.
If you have questions or you are not clear about something feel free to comment here or send me an email. Thanks for your continues support and happy clouding….