Configure Load Balancing in JBoss
Use run.sh -b <ip> to run instances on different IPs but same ports Define it in workers.properties:
worker.jboss2.type=ajp13
worker.jboss2.host=192.168.1.180
worker.jboss2.port=8009
To enrich your career and become a JBoss professional, visit Tekslate, the global online training platform:" JBoss Training". This course will help you achieve excellence in this field.
Define a new load balancing worker:
worker.jboss.type=lb
worker.jboss.balance_workers=jboss1,jboss2
Export the load balancing worker:
worker.list=jboss,jkstatus
The updated <apache-dir>/conf/workers.properties looks something like:
worker.jboss1.type=ajp13
worker.jboss1.host=127.0.0.1
worker.jboss1.port=8009
worker.jboss2.type=ajp13
worker.jboss2.host=192.168.1.180
worker.jboss2.port=8009
worker.jboss.type=lb
worker.jboss.balance_workers=jboss1,jboss2
worker.jkstatus.type=status
worker.list=jboss,jkstatus
Deploy session-test.war to both instances, and update SessionTest.jsp on the second so that its page heading and bgcolor are different (e.g. Server 2, lime)
Change/add in conf/jk.conf:
JkMount /jmx-console jboss
JkMount /jmx-console/* jboss
JkMount /session-test jboss
JkMount /session-test/* jboss
Start both JBoss instances (on local and public IPs) and restart Apache HTTPD Test http://localhost/session-test/ The updated <apache-dir>/conf/jk.conf looks something like:
LoadModule jk_module <path_to_modules>/mod_jk.so
JkWorkersFile <path_to_conf>/workers.properties
JkLogFile <path_to_logs>/jk.log
JkLogLevel info
JkMount /jmx-console jboss
JkMount /jmx-console/* jboss
JkMount /session-test jboss
JkMount /session-test/* jboss
JkMount /jkstatus jkstatus
Observe that we are no longer JkMount-ing jboss1 (or jboss2). We can only use the new load balancer worker called jboss because that is the one exported by worker.list inconf/worker.properties. What happens to "Session Counter" when accessed through http://localhost/session-test/? How about when you access the session-test/ directly, but going tohttp://localhost:8080/session-test/?
For an in-depth understanding on JBoss click on: