...
To keep the example simple I have not added load balancer support yet. If you want load do load balancing a simple configuration would look like this,
Code Block | ||
---|---|---|
| ||
# Define workers using ajp13
worker.list=loadbalancer
# Set properties for worker
worker.tomcat_a_worker.type=ajp13
worker.tomcat_a_worker.host=localhost
worker.tomcat_a_worker.port=9009
worker.tomcat_a_worker.lbfactor=1
# Set properties for worker
worker.tomcat_b_worker.type=ajp13
worker.tomcat_b_worker.host=localhost
worker.tomcat_b_worker.port=8109
worker.tomcat_b_worker.lbfactor=1
# Set up load balancer using ajp13 workers
work.loadbalancer.type=lb
work.loadbalancer.balance_workers=tomcat_a_worker,tomcat_b_worker |
The load balancing uses weighted round-robin with sticky sessions. The lower the lbfactor number the less weight and as such the less work done by the worker. In our example, since both tomcat a and b have a factor of 1 the load balance is split about 50/50.
Tin's Adjustments
What you have so far should work. However, if you want to match what I use in production I also made the following adjustments.
Look for this block and comment out.
Code Block |
---|
# Tin: This directory does not exist.
#
# workers.tomcat_home=/usr/share/tomcat5 |
Look for this block and comment out.
Code Block |
---|
# Tin: This directory does not exist.
#
# workers.java_home=/usr/lib/jvm/java-gcj |
Note |
---|
If someone can let me know why we would want to have these properties let me know. |
Configure Map Points in Apache
This last step will be different depending on if you are using virtual hosts or not.
To start, we wiill use the default which is no virtual hosting and take advantage of the default examples application that comes with tomcat.
First verify that you can hit the examples application by directly hitting our tomcat a server running on port 8080.
If you have been following my instructions to setup Ubuntu you probably have the firewall setup so do not forget to open up port 8080 temporarily for this test. http://www.krypton.com:8080/examples/
In our examples we will be using virtual hosts. Once you get virtual hosts working, add this entry to your virtual host file.
Code Block | ||
---|---|---|
| ||
JkMount /examples tomcat_a_worker
JkMount /examples/* tomcat_a_worker |
If you are not using virtual hosts you can add the following to /etc/apache2/sites-enabled/000-default,
Code Block | ||
---|---|---|
| ||
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
JkMount /examples/* tomcat_a_worker
JkMount /examples tomcat_a_worker
</VirtualHost> |
If you wanted to use the load balancer you would change tomcatA to loadbalancer.
Restart Apache
Finally you must restart Apache for the changes to take effect.
Warning |
---|
Content is still being copied over. |
...
I often have to do this on Solaris or alternative operating systems so the manual process of installing mod_jk is good to have handy.