Konfigurasi Cluster Tomcat

Apache Tomcat

Clustered Tomcat Configuration

Misal jumlah instance tomcat: 4
Akan ditambahkan:
– Load balancing
– Cluster

Istilah:
1. Tomcat1, Tomcat2, Tomcat3, Tomcat 4 disebut tomcat worker
2. Cluster1, Cluster2 disebut cluster
3. Load balancer disebut balancer

DNS Round Robin
|
Load Balancer
/                      \
Cluster1             Cluster2
/            \              /             \
Tomcat1     Tomcat2  Tomcat3     Tomcat4

*******
GENERAL
*******

Yang perlu dimodifikasi:
1. server.xml di folder <tomcat_home>/conf
2. web.xml di folder <tomcat_home>/conf
3. startup.bat di folder <tomcat_home>/bin
4. catalina.bat di folder <tomcat_home>/bin
5. workers.properties di folder <tomcat_home>/conf di mesin tomcat balancing

******
DETAIL
******

1. server.xml
di folder <tomcat_home>/conf
—————————–

Di masing-masing tomcat worker, pada bagian
<Server port=”8003″
atur port (bila dalam satu mesin)

Di masing-masing tomcat worker, pada bagian
<Connector port=”8209″ enableLookups=”false” redirectPort=”8443″ protocol=”AJP/1.3″ />
atur port (bila dalam satu mesin)

Di masing-masing tomcat worker, pada bagian
<Engine name=”Catalina” defaultHost=”localhost” jvmRoute=”tomcat3″>
sesuaikan jvmRoute sesuai workers.properties untuk masing-masing mesin

Di masing-masing tomcat worker dan cluster, di bawah level
<Host name=”localhost”>
tambahkan
<Cluster className=”org.apache.catalina.cluster.tcp.SimpleTcpCluster”/>

2. web.xml
di folder <tomcat_home>/conf
—————————–

Di masing-masing tomcat worker, di dalam tag
<web-app></web-app>
tambahkan
<distributable />

3. startup.bat
di folder <tomcat_home>/bin, di tomcat worker
—————————–

dibawah line 10
set CURRENT_DIR=%cd%

tambahkan baris dibawah:
set CATALINA_OPTS=-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8998 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false
set CATALINA_HOME=D:\project\appl\tomcat_2
set JAVA_HOME=C:\bea\jdk150
set JRE_HOME=C:\bea\jdk150\jre
set PATH=C:\bea\jdk150\bin;%PATH%

keterangan baris:
-Dcom.sun.management.jmxremote.port=8998 (dalam satu mesin dibedakan portnya)
CATALINA_HOME=D:\project\appl\tomcat_2 (disesuaikan)
JAVA_HOME=C:\bea\jdk150 (disesuaikan)

4. catalina.bat
di folder <tomcat_home>/bin, di tomcat worker
—————————–

line 159
set _EXECJAVA=start “Tomcat” %_RUNJAVA%
menjadi
set _EXECJAVA=start “Tomcat 1” %_RUNJAVA%

5. workers.properties
di folder <tomcat_home>/conf, di cluster
——————————————————

isi dari file tsb sbb:

ps=\

worker.list=loadbalancer

worker.tomcat1.type=ajp13
worker.tomcat1.port=8109
worker.tomcat1.host=localhost
worker.tomcat1.lbfactor=1
worker.tomcat1.socket_timeout=5
worker.tomcat1.recycle_timeout=10

worker.tomcat2.type=ajp13
worker.tomcat2.port=8209
worker.tomcat2.host=localhost
worker.tomcat2.lbfactor=1
worker.tomcat2.socket_timeout=5
worker.tomcat2.recycle_timeout=10

worker.tomcat3.type=ajp13
worker.tomcat3.port=8309
worker.tomcat3.host=130.201.5.19
worker.tomcat3.lbfactor=1
worker.tomcat3.socket_timeout=5
worker.tomcat3.recycle_timeout=10

worker.tomcat4.type=ajp13
worker.tomcat4.port=8409
worker.tomcat4.host=localhost
worker.tomcat4.lbfactor=1
worker.tomcat4.socket_timeout=5
worker.tomcat4.recycle_timeout=10

worker.loadbalancer.type=lb
worker.loadbalancer.balanced_workers=tomcat1,tomcat2,tomcat3,tomcat4

worker.loadbalancer.sticky_session=true

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s