Here is a simple straight forward install instruction for the glassfish loadbalancer plugin on linux apache. Notice that this plugin is only available for glassfish 2.x and works only with 32bit apache. All the steps must be run as the root user.
Install the required packages, and enable them:
yum install httpd.i386 mod_ssl.i386 -y chkconfig httpd on
Download and unzip the glassfish plugin:
cd ~ mkdir glassfish cd glassfish wget http://dlc.sun.com.edgesuite.net/javaee5/external/Linux/aslb/jars/aslb-9.1.1-b17.jar unzip aslb-9.1.1-b17.jar unzip SUNWaslb.zip unzip SUNWaspx.zip
Create the appropriate directories:
mkdir /etc/httpd/modules/resource mkdir /etc/httpd/modules/errorpages mkdir /etc/httpd/sec_db_files
Next, put all the unzip files on the right location:
cp ~/glassfish/lib/webserver-plugin/linux/apache2.2/LBPlugin*.res /etc/httpd/modules/resource -f cp ~/glassfish/lib/webserver-plugin/linux/apache2.2/mod_loadbalancer.so /etc/httpd/modules cp ~/glassfish/lib/webserver-plugin/linux/apache2.2/errorpages/* /etc/httpd/modules/errorpages/ cp ~/glassfish/lib/dtds/sun-loadbalancer* /etc/httpd/conf/ cp ~/glassfish/lib/install/templates/loadbalancer.xml.example /etc/httpd/conf cp ~/glassfish/lib/webserver-plugin/linux/apache2.2/*.db /etc/httpd/sec_db_files/ cp ~/glassfish/lib/lib* /usr/lib
Enable the plugin:
cat >> /etc/httpd/conf/httpd.conf << EOF ##BEGIN EE LB Plugin Parameters LoadModule apachelbplugin_module modules/mod_loadbalancer.soconfig-file "/etc/httpd/conf/loadbalancer.xml" locale en DocumentRoot "/var/www/html" ServerName [SERVERNAME]
Next, configure the loadbalancer:
vi /etc/httpd/conf/loadbalancer.xml
Remember to add an entry for every context root of your application in the loadbalancer.xml, other wise this part of the application will not be available through the loadbalancer.
Enable and configure apache as a worker:
vi /etc/httpd/conf/httpd.conf
Set the following parameters:
StartServers 1 MaxClients 32 MinSpareThreads 5 MaxSpareThreads 10 ThreadsPerChild 32 MaxRequestsPerChild 0
Enable worker processes:
vi /etc/sysconfig/httpd
HTTPD=/usr/sbin/httpd.worker
Pro’s: this way of balancing your J2EE application, the loadbalancer is aware that he is balancing a java application. Mod_proxy is not.
Con’s: Pretty maintenance intensive, every context root must be added to the configuration.