Create tomcat clustering

Tomcat clustering can be used for serving request routed through Apache HTTP Server.

Tomcat cluser setup can be created on single or different machine and accessed from Apache Http Server using JK connector.

Following text need to be copied in server.xml file in config folder of Tomcat.

<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"
channelSendOptions="8">

<Manager className="org.apache.catalina.ha.session.DeltaManager"
expireSessionsOnShutdown="true"
notifyListenersOnReplication="true"/>

<Channel className="org.apache.catalina.tribes.group.GroupChannel">
<Membership className="org.apache.catalina.tribes.membership.McastService"
address="228.0.0.4"
port="45564"
frequency="500"
dropTime="3000"/>
<Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
address="auto"
port="4000"
autoBind="100"
selectorTimeout="5000"
maxThreads="6"/>

<Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">
<Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/>
</Sender>
<Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>
<Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/>
</Channel>

<Valve className="org.apache.catalina.ha.tcp.ReplicationValve"
filter=""/>
<Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve"/>

<Deployer className="org.apache.catalina.ha.deploy.FarmWarDeployer"
tempDir="/tmp/war-temp/"
deployDir="/tmp/war-deploy/"
watchDir="/tmp/war-listen/"
watchEnabled="false"/>

<ClusterListener className="org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener"/>
<ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>
</Cluster>

Connecting MySQL from OpenEJB

You can use OpenEJB war to get the functionality of EJB into Tomcat.
Place the following text in openejb.xml file in config folder of Tomcat. For this setting to work your user table should have minimum one row present for root user.


JdbcDriver com.mysql.jdbc.Driver
JdbcUrl jdbc:mysql://192.168.0.101:3306/DataBaseName
UserName root
Password password
InitialSize 10
ConnectionProperties connectTimeout=10000;socketTimeout=10000;
MaxActive 1800
MaxIdle 500
MinIdle 10
MaxWait 10000
ValidationQuery select * from User where UserId='root';
TestWhileIdle true
TimeBetweenEvictionRunsMillis 10000
JtaManaged true

Followers

Education and Training Blogs - BlogCatalog Blog Directory
 

Copyright 2009 JavaBundle.

Blog by - Vishal Pal Chaudhary (Senior Engineering Manager, Catura Systems Inc.) and Gaurav Yadav

mail us at : vishal@newswali.com