Search This Blog

Wednesday, 31 August 2016

Thursday, 30 October 2014

Apache Web server configuration for Tomcat



Apache Configuration…..

Download Apache Stable Version.
http://httpd.apache.org/download.cgi

Install typical...

Edit Httpd.conf file and append below lines in bottom of the file.

LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/workers.properties
# Where to put jk logs
JkLogFile     logs/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel    emerg
# Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
# JkOptions indicate to send SSL KEY SIZE,
JkOptions     +ForwardKeySize +ForwardURICompat -ForwardDirectories
# JkRequestLogFormat set the request format
JkRequestLogFormat     "%w %V %T %p %q %r %v %U"
JkMount /* balancer
JkMount /status stat

Create “workers.properties” under Conf directory and add below lines.

worker.list=balancer,stat

worker.tomcat1.type=ajp13
worker.tomcat1.host=127.0.0.1
worker.tomcat1.port=8010
worker.tomcat1.lbfactor=10

worker.tomcat2.type=ajp13
worker.tomcat2.host=127.0.0.1
worker.tomcat2.port=8011
worker.tomcat2.lbfactor=10

worker.tomcat3.type=ajp13
worker.tomcat3.host=127.0.0.1
worker.tomcat3.port=8012
worker.tomcat3.lbfactor=10

worker.balancer.type=lb
worker.balancer.balance_workers=tomcat1,tomcat2,tomcat3
worker.stat.type=status

Download Tomcat Mod_Jk connector from below link and past it into apache Module directory.

http://apache.osuosl.org/tomcat/tomcat-connectors/jk/binaries/windows/

Restart Apache….

Tomcat

Tomcat Cluster Configuration….

Download tomcat from below link.

Create directory for tomcat cluster instances called “T_Cluster”.
Under directory “T_Cluster” create three directories for three tomcat instances and extract downloaded tomcat into each instance directory.

Edit Server.xml file for instance configuration make below changes in file.

1.       Change Default shutdown Port.  
<Server port="8007" shutdown="SHUTDOWN">

2.       Change Default AJP Port.
<Connector port="8011" protocol="AJP/1.3" redirectPort="8443" />

3.       Add JvmRoute name.
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat2">

4.       Cluster Configuration make sure you add below lines below cluster configuration will be same for other instances.
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster" channelSendOptions="8">
                <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"/>

                               
<Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">
                                                <Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/>
                                </Sender>
                                               
                                <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
                                                                                address="auto"
                                                                                port="4001"
                                                                                autoBind="100"
                                                                                selectorTimeout="5000"
                                                                                maxThreads="6"/>
                                                                               
                                <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"/>
               
                <ClusterListener className="org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener"/>
               
                <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>
               
</Cluster>
Cluster Configuration End’s here.

Make above changes in other two instances.
In the deployed application add “<distributable/>” Tag in web.xml file for session replication.

Now open CMD and start tomcat.
C:\>cd T_Cluster\Node-1\bin
C:\T_Cluster\Node-1\bin>startup.bat

Start all three tomcat instances.

Restart Apache server…

Testing…

Access apache server URL with configured port.
Check tomcat individual URL’s.