Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tomcat and apache configuration in debian

 
Sunil Nagotra
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am trying to set the connector between Tomcat and Apache for 2 machines :
1) In machine-1 servers Apache and TomcatA are configured
2) In machine-2 server TomcatB is configured

Request flow is as follows :
When request will come from outside environment, it will first pass through apache
and according to the availability of Tomcat Server, it will be redirected to it.
Small diagramatic representation is as below.


----------------> Apache ----------------------> Tomcat A
request |
|
|___________________________> Tomcat B


I used libapache2-mod-jk_1.2.31-1_i386.deb in debian 6 and following are all the steps based on the posts.

following entry i have done into workers.properties

workers.java_home=/opt/jdk1.5.0_22
ps=/
worker.list=TomcatA,TomcatB,loadbalancer
worker.jkstatus.type=status

worker.TomcatA.port=8009
worker.TomcatA.host="Machine 2 IP"
worker.TomcatA.type=ajp13
worker.TomcatA.lbfactor=3
worker.TomcatA.socket_keepalive=1
worker.TomcatA.connect_timeout=10000
worker.TomcatA.recovery_options=7

worker.TomcatB.port=8009
worker.TomcatB.host="Machine 2 IP"
worker.TomcatB.type=ajp13
worker.TomcatB.lbfactor=3
worker.TomcatB.socket_keepalive=1
worker.TomcatB.connect_timeout=10000
worker.TomcatB.recovery_options=7

worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=TomcatA,TomcatB
worker.loadbalancer.sticky_session=1

following entry i have done into httpd.conf file

NameVirtualHost "IP of Machine 1":80
<VirtualHost "IP of Machine 1":80>
ServerAdmin admin@xxx.com
ServerName company.com
DocumentRoot /opt/TomcatA/webapps/cluster/
ErrorLog /opt/TomcatA/logs/error_log
CustomLog /opt/TomcatA/logs/access_log common
JkMount /cluster/*.jsp loadbalancer
</VirtualHost>
I have done all the changes in server.xml in Tomcat-Server of both the machines.
I am facing problem for to maintain session through single Apache and 2-Tomcat servers.
I have restart apache, TomcatA, TomcatB and checked the my jsp given me a session ID,
but when i am down the TomcatA and refresh the browser it display diffrent session ID.
please help me where i am going worng.
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you have here looks like a load-balancing scheme. I don't see where you have session replication implemented. To do that, your Tomcat instances have to talk to each other and be able to pass session data to each other, and that session data of course has to be serializable.
 
Sunil Nagotra
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for replay.
I am using following URL for configure the load balancing and session replication

http://tomcat.apache.org/tomcat-6.0-doc/cluster-howto.html

Can you explain me the process for implementation of session replication in tomcat.

Thanks,
Sunil
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, it's not the easiest thing for me to help with over a bulletin board, but I can try and guide you a little.

First, what form of session persistence are you trying to implement (shared file, shared database, in-memory?)

Second, if you're using two machines for this, does the network they're on support multicasting? Some switch/router admins will disable this on company networks.
 
Sunil Nagotra
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am using in-memory replication.
My Multicasting is enabled.
Still i am geting issue. session is not replicate when i am down server 1.
I am attaching server.xml code and logs which is i got form tomcat.

Logs
**************************************
Jun 5, 2011 2:07:13 AM org.apache.coyote.AbstractProtocolHandler init
INFO: Initializing ProtocolHandler ["http-bio-8088"]
Jun 5, 2011 2:07:13 AM org.apache.coyote.AbstractProtocolHandler init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Jun 5, 2011 2:07:13 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 542 ms
Jun 5, 2011 2:07:13 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jun 5, 2011 2:07:13 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.14
Jun 5, 2011 2:07:13 AM org.apache.catalina.ha.tcp.SimpleTcpCluster startInternal
INFO: Cluster is about to start
Jun 5, 2011 2:07:13 AM org.apache.catalina.tribes.transport.ReceiverBase bind
INFO: Receiver Server Socket bound to:/127.0.1.1:5000
Jun 5, 2011 2:07:13 AM org.apache.catalina.tribes.membership.McastServiceImpl setupSocket
INFO: Setting cluster mcast soTimeout to 500
Jun 5, 2011 2:07:13 AM org.apache.catalina.tribes.membership.McastServiceImpl waitForMembers
INFO: Sleeping for 1000 milliseconds to establish cluster membership, start level:4
Jun 5, 2011 2:07:13 AM org.apache.catalina.ha.tcp.SimpleTcpCluster memberAdded
INFO: Replication member addedrg.apache.catalina.tribes.membership.MemberImpl[tcp://{127, 0, 1, 1}:5000,{127, 0, 1, 1},5000, alive=6497660, securePort=-1, UDP Port=-1, id={-73 -112 -107 93 11 52 67 99 -94 -110 119 113 14 23 -91 60 }, payload={}, command={}, domain={}, ]
Jun 5, 2011 2:07:13 AM org.apache.catalina.tribes.io.BufferPool getBufferPool
INFO: Created a buffer pool with max size:104857600 bytes of typerg.apache.catalina.tribes.io.BufferPool15Impl
Jun 5, 2011 2:07:14 AM org.apache.catalina.tribes.membership.McastServiceImpl waitForMembers
INFO: Done sleeping, membership established, start level:4
Jun 5, 2011 2:07:14 AM org.apache.catalina.tribes.membership.McastServiceImpl waitForMembers
INFO: Sleeping for 1000 milliseconds to establish cluster membership, start level:8
Jun 5, 2011 2:07:15 AM org.apache.catalina.tribes.membership.McastServiceImpl waitForMembers
INFO: Done sleeping, membership established, start level:8
Jun 5, 2011 2:07:15 AM org.apache.catalina.ha.deploy.FarmWarDeployer start
SEVERE: FarmWarDeployer can only work as host cluster subelement!
Jun 5, 2011 2:07:15 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory cluster
Jun 5, 2011 2:07:16 AM org.apache.catalina.realm.JAASRealm setContainer
INFO: Set JAAS app name Catalina
Jun 5, 2011 2:07:16 AM org.apache.catalina.tribes.tipis.AbstractReplicatedMap init
INFO: Initializing AbstractReplicatedMap with context name:localhost#/cluster-map
Jun 5, 2011 2:07:16 AM org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor report
INFO: ThroughputInterceptor Report[
Tx Msg:1 messages
Sent:0.00 MB (total)
Sent:0.00 MB (application)
Time:0.00 seconds
Tx Speed:0.14 MB/sec (total)
TxSpeed:0.14 MB/sec (application)
Error Msg:0
Rx Msg:1 messages
Rx Speed:0.00 MB/sec (since 1st msg)
Received:0.00 MB]

Jun 5, 2011 2:07:16 AM org.apache.coyote.AbstractProtocolHandler start
INFO: Starting ProtocolHandler ["http-bio-8088"]
Jun 5, 2011 2:07:16 AM org.apache.coyote.AbstractProtocolHandler start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Jun 5, 2011 2:07:16 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 2460 ms
******************************************************
Server.xml
************************************
<Connector port="8088" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost" jvmRoute="TomcatA">
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"
channelSendOptions="6">
<Manager className="org.apache.catalina.ha.session.BackupManager"
expireSessionsOnShutdown="false"
notifyListenersOnReplication="true"
mapSendOptions="6"/>
<Manager className="org.apache.catalina.ha.session.DeltaManager"
expireSessionsOnShutdown="false"
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="5000"
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"/>
<Interceptor className="org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor"/>
</Channel>
<Valve className="org.apache.catalina.ha.tcp.ReplicationValve"
filter=".*\.gif;.*\.js;.*\.jpg;.*\.png;.*\.htm;.*\.html;.*\.css;.*\.txt;"/>
<Deployer className="org.apache.catalina.ha.deploy.FarmWarDeployer"
tempDir="/temp/"
deployDir="/temp/"
watchDir="/temp/"
watchEnabled="false"/>
<ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>
</Cluster>
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" resolveHosts="false"/>
</Host>
</Engine>
************************
Thanks,
Sunil
 
Rob Spoor
Sheriff
Pie
Posts: 20550
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to our Tomcat forum.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic