{"id":1134,"date":"2012-08-27T15:15:55","date_gmt":"2012-08-27T07:15:55","guid":{"rendered":"http:\/\/rmohan.com\/?p=1134"},"modified":"2012-08-27T15:15:55","modified_gmt":"2012-08-27T07:15:55","slug":"jboss-load-balanced-cluster","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=1134","title":{"rendered":"JBoss load-balanced cluster"},"content":{"rendered":"<h3>\u00a0<\/h3>\n<div>\u00a0<\/div>\n<p>I spent a little bit of time getting a JBoss cluster running on my development machine and then configuring a Apache 2.2.17 server to load balance between the 2 node cluster. Here is how I did it.<\/p>\n<p> I had to enable the following modules on Apache:<\/p>\n<div>\n<pre>LoadModule proxy_module modules\/mod_proxy.so\r\nLoadModule proxy_ajp_module modules\/mod_proxy_ajp.so\r\nLoadModule proxy_balancer_module modules\/mod_proxy_balancer.so\r\nLoadModule rewrite_module modules\/mod_rewrite.so\r\nLoadModule ssl_module modules\/mod_ssl.so\r\nLoadModule status_module modules\/mod_status.so<\/pre>\n<\/div>\n<p> Then, I had to setup the rules for the balancing Apache proxy at the end of the conf\/httpd.conf file:<\/p>\n<div>\n<pre>ProxyReceiveBufferSize 4096\r\n&lt;proxy balancer:\/\/ajpcluster&gt;\r\n  BalancerMember ajp:\/\/test.local.host:8109\r\n  BalancerMember ajp:\/\/test.local.host:8209\r\n&lt;\/proxy&gt;\r\n&lt;location \/jconsole&gt;\r\n  ProxyPass balancer:\/\/ajpcluster\/jconsole stickysession=JSESSIONID|jsessionid nofailover=On\r\n  ProxyPassReverse balancer:\/\/ajpcluster\/jconsole\r\n&lt;\/location&gt;\r\nRewriteEngine On\r\nRewriteCond %{HTTPS} off\r\nRewriteRule (.*) https:\/\/%{HTTP_HOST}%{REQUEST_URI}\r\nRedirect \/ \/jconsole\r\nRedirectMatch ^\/(?i)admin   \/jconsole\r\nRedirectMatch ^\/(?i)status   \/jconsole<\/pre>\n<\/div>\n<p> Then, I needed to enable the conf\/mod-jk.conf file, update the http.conf to reflect this, and add this VirtualHost:<\/p>\n<div>\n<pre>&lt;virtualHost localhost&gt;\r\n  ServerName localhost\r\n  JkMount \/jconsole loadbalancer\r\n  JkMount \/jconsole\/* loadbalancer\r\n&lt;\/virtualHost&gt;<\/pre>\n<\/div>\n<p> Then, I needed a conf\/uriworkermap.properties file:<\/p>\n<div>\n<pre># Simple worker configuration file\r\n# Mount the Servlet context to the ajp13 worker\r\n#    Example\r\n#    Mapping the URI \/myapp1 and everything under \/myapp1\/:\r\n#    \/myapp1|\/*=myworker-a\r\n\/jconsole|\/*=loadbalancer\r\n\/jkstatus|\/*=jkstat<\/pre>\n<\/div>\n<p> Then, I needed a conf\/workers.properties for mod-jk:<\/p>\n<div>\n<pre># Define list of workers that will be used\r\n# The configuration directives are valid\r\n# for the mod_jk version 1.2.18 and later\r\nworker.list=loadbalancer,jkstat\r\n# Define Node1\r\nworker.ports1.port=8109\r\nworker.ports1.host=127.0.0.1\r\nworker.ports1.type=ajp13\r\nworker.ports1.lbfactor=1\r\nworker.ports1.prepost_timeout=10000\r\nworker.ports1.connect_timeout=10000\r\nworker.ports1.ping_mode=A\r\nworker.ports1.connection_pool_size=10\r\n# Define Node2\r\nworker.ports2.port=8209\r\nworker.ports2.host=127.0.0.1\r\nworker.ports2.type=ajp13\r\nworker.ports2.lbfactor=1\r\nworker.ports2.prepost_timeout=10000\r\nworker.ports2.connect_timeout=10000\r\nworker.ports2.ping_mode=A\r\nworker.ports1.connection_pool_size=10\r\n# Load-balancing behaviour\r\nworker.loadbalancer.type=lb\r\nworker.loadbalancer.balance_workers=ports1,ports2\r\n# Status worker for managing load balancer\r\nworker.jkstat.type=status<\/pre>\n<\/div>\n<p> And, that is basically it. You can download my portable , self extracting zip file, of my Tomcat and JBoss cluster running on &#8220;localhost&#8221;. Just unzip and read the readme file enclosed. It works as-is , by navigating to the app called &#8220;http:\/\/test.local.host&#8221; after you have it running.<\/p>\n","protected":false},"excerpt":{"rendered":"\n<p>I spent a little bit of time getting a JBoss cluster running on my development machine and then configuring a Apache 2.2.17 server to load balance between the 2 node cluster. Here is how I did it.<\/p>\n<p> I had to enable the following modules on Apache:<\/p>\n<p> LoadModule proxy_module modules\/mod_proxy.so LoadModule proxy_ajp_module modules\/mod_proxy_ajp.so LoadModule [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/1134"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1134"}],"version-history":[{"count":2,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/1134\/revisions"}],"predecessor-version":[{"id":1136,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/1134\/revisions\/1136"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1134"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1134"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1134"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}