{"id":458,"date":"2012-06-26T10:31:53","date_gmt":"2012-06-26T02:31:53","guid":{"rendered":"http:\/\/rmohan.com\/?p=458"},"modified":"2012-06-26T10:37:57","modified_gmt":"2012-06-26T02:37:57","slug":"clustering-tomcat-server","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=458","title":{"rendered":"Clustering Tomcat Server"},"content":{"rendered":"<p><strong>Clustering Tomcat Server<\/strong><br \/>\nA cluster of two Tomcat is a more Tomcats that are hosted in the same Java application. The main function of cluster Tomcat is to perform replication of open sessions in each cluster of Tomcat, so Tomcat each contain their sessions and their attributes, as well as the attributes of the other sessions and Tomcats. Each Tomcat cluster is called a node.<\/p>\n<p>With the Tomcat cluster can achieve high availability, so that if a cluster node fails, the requests coming to this node are forwarded to another active node. All this without the user noticing, because your session is active on other cluster nodes.<\/p>\n<p>The figure below shows the architecture of the cluster of Tomcat:<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/rmohan.com\/wp-content\/uploads\/2012\/06\/tomcatCluster.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-461\" title=\"tomcatCluster\" src=\"http:\/\/rmohan.com\/wp-content\/uploads\/2012\/06\/tomcatCluster.png\" alt=\"\" width=\"459\" height=\"143\" srcset=\"https:\/\/mohan.sg\/wp-content\/uploads\/2012\/06\/tomcatCluster.png 459w, https:\/\/mohan.sg\/wp-content\/uploads\/2012\/06\/tomcatCluster-300x93.png 300w, https:\/\/mohan.sg\/wp-content\/uploads\/2012\/06\/tomcatCluster-150x46.png 150w, https:\/\/mohan.sg\/wp-content\/uploads\/2012\/06\/tomcatCluster-400x124.png 400w\" sizes=\"(max-width: 459px) 100vw, 459px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Tomcat cluster configuration<\/strong><br \/>\nI will take into consideration that you have two instances of Tomcat, Apache and Java installed on your server. Below is a description of the environment that will be used in this small project, it is worth remembering that it is only a test project:<\/p>\n<p>Two instances of virtual machines in VirtualBox;<br \/>\nEach VM with 512MB RAM and 8GB HD;<br \/>\nEach VM operating system with CentOS 5.7 (Final).<\/p>\n<p>Note: This configuration can be performed on any Linux server.<\/p>\n<p>requirements:<\/p>\n<p>To perform the replication sessions between nodes in the cluster a few points should be checked:<\/p>\n<p>All session attributes must implement java.io.Serializable;<br \/>\nHaving the application web.xml &lt;distributable\/&gt; the attribute or set a property in the context of the application configuration file server.xml;<br \/>\nConfigure the load balancer with sticky session option active, to keep the same user requests a system going to the same cluster node, except when this node fails.<\/p>\n<p>Starting the configuration:<\/p>\n<p>The configuration of the Tomcats to the cluster is made from editing the server.xml file, located in the conf (&lt;product the tomcat&gt; \/ conf \/ server.xml) for each Tomcat.<\/p>\n<p>What should be done is uncomment the whole tag and add cluster configuration adapting the parameters to the hosting environment. Just below the cluster configuration:<\/p>\n<p>&nbsp;<\/p>\n<div>\n<div><code>&lt;<\/code><code>Cluster<\/code> <code>className<\/code><code>=<\/code><code>\"org.apache.catalina.ha.tcp.SimpleTcpCluster\"<\/code><\/div>\n<div><code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code>channelSendOptions<\/code><code>=<\/code><code>\"8\"<\/code><code>&gt;<\/code><\/div>\n<div><code>\u00a0<\/code><\/div>\n<div><code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code>&lt;<\/code><code>Manager<\/code> <code>className<\/code><code>=<\/code><code>\"org.apache.catalina.ha.session.DeltaManager\"<\/code><\/div>\n<div><code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code>expireSessionsOnShutdown<\/code><code>=<\/code><code>\"false\"<\/code><\/div>\n<div><code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code>notifyListenersOnReplication<\/code><code>=<\/code><code>\"true\"<\/code><code>\/&gt;<\/code><\/div>\n<div><code>\u00a0<\/code><\/div>\n<div><code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code>&lt;<\/code><code>Channel<\/code> <code>className<\/code><code>=<\/code><code>\"org.apache.catalina.tribes.group.GroupChannel\"<\/code><code>&gt;<\/code><\/div>\n<div><code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code>&lt;<\/code><code>Membership<\/code> <code>className<\/code><code>=<\/code><code>\"org.apache.catalina.tribes.membership.McastService\"<\/code><\/div>\n<div><code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code>address<\/code><code>=<\/code><code>\"228.0.0.4\"<\/code><\/div>\n<div><code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code>port<\/code><code>=<\/code><code>\"45564\"<\/code><\/div>\n<div><code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code>frequency<\/code><code>=<\/code><code>\"500\"<\/code><\/div>\n<div><code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code>dropTime<\/code><code>=<\/code><code>\"3000\"<\/code><code>\/&gt;<\/code><\/div>\n<div><code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code>&lt;<\/code><code>Receiver<\/code> <code>className<\/code><code>=<\/code><code>\"org.apache.catalina.tribes.transport.nio.NioReceiver\"<\/code><\/div>\n<div><code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code>address<\/code><code>=<\/code><code>\"auto\"<\/code><\/div>\n<div><code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code>port<\/code><code>=<\/code><code>\"4000\"<\/code><\/div>\n<div><code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code>autoBind<\/code><code>=<\/code><code>\"100\"<\/code><\/div>\n<div><code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code>selectorTimeout<\/code><code>=<\/code><code>\"5000\"<\/code><\/div>\n<div><code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code>maxThreads<\/code><code>=<\/code><code>\"6\"<\/code><code>\/&gt;<\/code><\/div>\n<div><code>\u00a0<\/code><\/div>\n<div><code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code>&lt;<\/code><code>Sender<\/code> <code>className<\/code><code>=<\/code><code>\"org.apache.catalina.tribes.transport.ReplicationTransmitter\"<\/code><code>&gt;<\/code><\/div>\n<div><code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code>&lt;<\/code><code>Transport<\/code> <code>className<\/code><code>=<\/code><code>\"org.apache.catalina.tribes.transport.nio.PooledParallelSender\"<\/code><code>\/&gt;<\/code><\/div>\n<div><code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code>&lt;\/<\/code><code>Sender<\/code><code>&gt;<\/code><\/div>\n<div><code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code>&lt;<\/code><code>Interceptor<\/code> <code>className<\/code><code>=<\/code><code>\"org.apache.catalina.tribes.group.interceptors.TcpFailureDetector\"<\/code><code>\/&gt;<\/code><\/div>\n<div><code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code>&lt;<\/code><code>Interceptor<\/code> <code>className<\/code><code>=<\/code><code>\"org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor\"<\/code><code>\/&gt;<\/code><\/div>\n<div><code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code>&lt;\/<\/code><code>Channel<\/code><code>&gt;<\/code><\/div>\n<div><code>\u00a0<\/code><\/div>\n<div><code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code>&lt;<\/code><code>Valve<\/code> <code>className<\/code><code>=<\/code><code>\"org.apache.catalina.ha.tcp.ReplicationValve\"<\/code><\/div>\n<div><code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code>filter<\/code><code>=<\/code><code>\"\"<\/code><code>\/&gt;<\/code><\/div>\n<div><code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code>&lt;<\/code><code>Valve<\/code> <code>className<\/code><code>=<\/code><code>\"org.apache.catalina.ha.session.JvmRouteBinderValve\"<\/code><code>\/&gt;<\/code><\/div>\n<div><code>\u00a0<\/code><\/div>\n<div><code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code>&lt;<\/code><code>Deployer<\/code> <code>className<\/code><code>=<\/code><code>\"org.apache.catalina.ha.deploy.FarmWarDeployer\"<\/code><\/div>\n<div><code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code>tempDir<\/code><code>=<\/code><code>\"\/tmp\/war-temp\/\"<\/code><\/div>\n<div><code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code>deployDir<\/code><code>=<\/code><code>\"\/tmp\/war-deploy\/\"<\/code><\/div>\n<div><code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code>watchDir<\/code><code>=<\/code><code>\"\/tmp\/war-listen\/\"<\/code><\/div>\n<div><code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code>watchEnabled<\/code><code>=<\/code><code>\"false\"<\/code><code>\/&gt;<\/code><\/div>\n<div><code>\u00a0<\/code><\/div>\n<div><code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code>&lt;<\/code><code>ClusterListener<\/code> <code>className<\/code><code>=<\/code><code>\"org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener\"<\/code><code>\/&gt;<\/code><\/div>\n<div><code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code>&lt;<\/code><code>ClusterListener<\/code> <code>className<\/code><code>=<\/code><code>\"org.apache.catalina.ha.session.ClusterSessionListener\"<\/code><code>\/&gt;<\/code><\/div>\n<div><code>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code>&lt;\/<\/code><code>Cluster<\/code><code>&gt;\u00a0\u00a0 <\/code><\/div>\n<\/div>\n<p>&nbsp;<\/p>\n<p>In each Tomcat cluster have the same tag with a small difference in the configuration:<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/rmohan.com\/wp-content\/uploads\/2012\/06\/thumb_membershipreceiver.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-463\" title=\"thumb_membershipreceiver\" src=\"http:\/\/rmohan.com\/wp-content\/uploads\/2012\/06\/thumb_membershipreceiver.png\" alt=\"\" width=\"500\" height=\"86\" srcset=\"https:\/\/mohan.sg\/wp-content\/uploads\/2012\/06\/thumb_membershipreceiver.png 500w, https:\/\/mohan.sg\/wp-content\/uploads\/2012\/06\/thumb_membershipreceiver-300x51.png 300w, https:\/\/mohan.sg\/wp-content\/uploads\/2012\/06\/thumb_membershipreceiver-150x25.png 150w, https:\/\/mohan.sg\/wp-content\/uploads\/2012\/06\/thumb_membershipreceiver-400x68.png 400w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>we have to identify each node in the same file &#8220;server.xml&#8221;. In Tomcat The Tomcat and B will need to make some changes to the nodes can communicate:<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/rmohan.com\/wp-content\/uploads\/2012\/06\/thumb_tomcatAB.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-464\" title=\"thumb_tomcatAB\" src=\"http:\/\/rmohan.com\/wp-content\/uploads\/2012\/06\/thumb_tomcatAB.png\" alt=\"\" width=\"500\" height=\"268\" srcset=\"https:\/\/mohan.sg\/wp-content\/uploads\/2012\/06\/thumb_tomcatAB.png 500w, https:\/\/mohan.sg\/wp-content\/uploads\/2012\/06\/thumb_tomcatAB-300x160.png 300w, https:\/\/mohan.sg\/wp-content\/uploads\/2012\/06\/thumb_tomcatAB-150x80.png 150w, https:\/\/mohan.sg\/wp-content\/uploads\/2012\/06\/thumb_tomcatAB-400x214.png 400w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<div id=\"gt-res-content\">\n<div dir=\"ltr\">Note: Changes are highlighted in bold, but these changes are an example of configuration, not necessarily have to use these same values, can be done with other values.After making these settings, simply start the Tomcats that they begin to replicate its sessions, or begin working on the cluster.To start the Tomcats just enter the directory bin \/ in each Tomcat and run the following command:<\/p>\n<\/div>\n<\/div>\n<div dir=\"ltr\"><strong> sh startup.sh<\/strong><\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\"><strong> Load Balancing<\/strong><\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\">he service is able to forward requests to multiple servers within a cluster, so that each cluster node is not overloaded, thus ensuring the use level of all computing resources within the cluster.In this project, the Apache will be responsible for balancing the load between two Tomcats. Apache will receive the requests coming from the customer and by the amount of requests sent to each Tomcat, it will be transferred to each of them.The figure below shows the architecture of Tomcat cluster with load balancing:<\/p>\n<\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\"><a href=\"http:\/\/rmohan.com\/wp-content\/uploads\/2012\/06\/ClusterBalanceamentoCarga.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-465\" title=\"ClusterBalanceamentoCarga\" src=\"http:\/\/rmohan.com\/wp-content\/uploads\/2012\/06\/ClusterBalanceamentoCarga.png\" alt=\"\" width=\"257\" height=\"272\" srcset=\"https:\/\/mohan.sg\/wp-content\/uploads\/2012\/06\/ClusterBalanceamentoCarga.png 257w, https:\/\/mohan.sg\/wp-content\/uploads\/2012\/06\/ClusterBalanceamentoCarga-141x150.png 141w\" sizes=\"(max-width: 257px) 100vw, 257px\" \/><\/a><\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\">Configuring the Load Balancer<br \/>\nAs was said in previous posts, responsible for load balancing Apache. To do this using Apache mod_proxy and mod_proxy_balancer. With mod_proxy Apache works as a proxy FTP, HTTP and SSL. Mod_proxy_balancer already provides a service load balancing for HTTP, FTP and ajp13. The mod_proxy_balancer depends on the use of mod_proxy.Currently there are two methods of load balancing:For quantities of requests, where each cluster node will receive a request at a time so that none of us get overwhelmed.<br \/>\nFor traffic, where a dedicated balancer cluster node to which the request for travel on much information while the other requests will be sent to other servers.<\/p>\n<p>The scenario will be where the cluster configuration will be described below:<\/p>\n<p>Server IP = 192.168.56.101<br \/>\nApplication to be used in this example is a system to ask for lunch which was developed at the company I work. The system is jBroca.<\/p>\n<p>The configuration of the load balancer will be made in the configuration file of the Apache &#8220;httpd.conf&#8221;. In CentOS Apache configuration file is located inside the \/ etc \/ httpd \/ conf \/.<\/p>\n<p>Insert this at the end of httpd.conf:<\/p>\n<\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\">\n<div>&lt;VirtualHost 192.168.56.101:80&gt;<br \/>\nServerName 192.168.56.101<br \/>\nProxyRequests Off&lt;Proxy 192.168.56:80&gt;<br \/>\nOrder deny,allow<br \/>\nAllow from all<br \/>\n&lt;\/Proxy&gt;ProxyPass \/teste balancer:\/\/balancer lbmethod=byrequests stickysession=JSESSIONID nofailover=off<br \/>\nProxyPassReverse \/teste http:\/\/192.168.56.101:8080\/jbroca<br \/>\nProxyPassReverse \/teste http:\/\/192.168.56.101:8081\/jbroca<\/p>\n<p>&lt;Proxy balancer:\/\/balancer&gt;<\/p>\n<p>BalancerMember http:\/\/192.168.56.101:8080\/jbroca route=node01 loadfactor=1<br \/>\nBalancerMember http:\/\/192.168.56.101:8081\/jbroca route=node02 loadfactor=1<\/p>\n<p>&lt;\/Proxy&gt;<\/p>\n<p>&lt;Location \/balancer-manager&gt;<\/p>\n<p>setHandler balancer-manager<br \/>\nOrder Deny,Allow<br \/>\nDeny from all<br \/>\nAllow from 192.168.56.101<\/p>\n<p>&lt;\/Location&gt;<\/p>\n<p>&lt;\/VirtualHost&gt;<\/p>\n<\/div>\n<\/div>\n<div><\/div>\n<div>In this section we setup a virtualhost which will be responsible for receipt of requests for the url 192.168.56.101\/jbroca. Below is a description of each item in this configuration:ServerName: determines the name of the virtual host, in this case 192.168.56.101\/jbroca.<br \/>\nProxyRequest off: Determines that Apache will not be used as a proxy server or a reverse proxy.<br \/>\nProxyPass \/ test balancer :\/ \/ balancer lbmethod = byrequests stickysession nofailover = JSESSIONID = off: any request for use in the context \/ test will use the load balancer balancer to meet demand.<br \/>\nlbmethod = byrequests: is where you define the type of load balancing, in which case load balancing is per request.<br \/>\nstickysession = JSESSIONID: defines that Apache will direct requests for the same section to the same server.<br \/>\nnofailover = off: defines that all servers within the cluster will be able to overcome the failure of a server cluster that become inactive, the Apache server this will divert requests to another server.The following options are settings used to correct the responses from the servers in the cluster that are balanced, based on the request coming from the client:<\/p>\n<p>ProxyPassReverse \/ jbroca http:\/\/192.168.56.101:8080\/jbroca<br \/>\nProxyPassReverse \/ jbroca http:\/\/192.168.56.101:8081\/jbroca<\/p>\n<p>Now is where we declare to the load balancer cluster members and their respective characteristics:<\/p>\n<p>&lt;Proxy Balancer:\/\/balancer&gt;<br \/>\nBalancerMember http:\/\/192.168.56.101:8080\/jbroca route = node01 loadfactor = 1<br \/>\nBalancerMember http:\/\/192.168.56.101:8081\/jbroca route = node02 loadfactor = 1<br \/>\n&lt;\/ Proxy&gt;<\/p>\n<p>The last option enables the load balancer management for browsers 192.168.56.101 domain. To view the balancer-manager in the browser just type:<\/p>\n<p>http:\/\/192.168.56.101\/balancer-manager<\/p>\n<p>&lt;Location \/balancer-manager&gt;<br \/>\nSetHandler balancer-manager<br \/>\nOrder Deny, Allow<br \/>\nDeny from all<br \/>\nAllow from 192.168.56.101<br \/>\n&lt;\/ Location&gt;<\/p>\n<p>With this, the Apache is configured to perform load balancing, routing requests to both servers within the cluster.<\/p>\n<p>To test whether all configuration is correct, start the Tomcats and start the Apache server starts correctly, your cluster is working and just access the browser to check if the balancer is working properly. In the example above go to:<\/p>\n<p>http:\/\/192.168.56.101\/jbroca<\/p>\n<p>Access to different browsers and make sure the balancer is actually directing the requests to each server. In this example that was used, the address bar shows that the requests are balanced:<\/p>\n<p>http:\/\/192.168.56.101\/jbroca\/autenticarUsuario.do; jsessionid = 9225E01A70F0A90B2283244B2CF554D3.node01<br \/>\nhttp:\/\/192.168.56.101\/jbroca\/autenticarUsuario.do; jsessionid = 4B2BF75B6B2F99EAB791D512E52AC626.node02<\/p>\n<p>The return address shows requests divided in two Tomcats cluster. The balancer-manager also shows that the requests are balanced.<\/p>\n<p>We end here, hope you all have managed to understand what I had to pass. The application will not be available to be used only in the company I work, then the application you develop and test applications running on the cluster.<\/p>\n<p>Thank you all.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Clustering Tomcat Server A cluster of two Tomcat is a more Tomcats that are hosted in the same Java application. The main function of cluster Tomcat is to perform replication of open sessions in each cluster of Tomcat, so Tomcat each contain their sessions and their attributes, as well as the attributes of the other [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/458"}],"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=458"}],"version-history":[{"count":4,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/458\/revisions"}],"predecessor-version":[{"id":462,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/458\/revisions\/462"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=458"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=458"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=458"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}