2XX.247.29.160
L4 Switch
┌────────┴────────┐
2XX.247.29.150 2XX.247.29.153
www1.kxx.ac.kr www2.kxx.ac.kr
* 로드밸런싱을 위한 별도의 port를 열지는 않았다.
1. 공통 설정
# vi /usr/local/apache2/conf/httpd.conf
----------------------------------------------------------------------------------------------
include conf/mod_jk.conf <- 젤 밑에 추가
# vi /usr/local/apache2/conf/mod_jk.conf
----------------------------------------------------------------------------------------------
LoadModule jk_module modules/mod_jk.so
<IfModule mod_jk.c>
JkWorkersFile conf/workers.properties
JkShmFile logs/mod_jk.shm
JkLogFile logs/mod_jk.log
JkLogLevel info
JkRequestLogFormat "%w %V %T"
JkRequestLogFormat "[%a %b %d %H:%M:%S %Y]"
jkMount /*.jsp loadbalancer
jkMount /*.do loadbalancer
jkMount /servlet/* loadbalancer
</IfModule>
# vi /usr/local/apache2/conf/workers.properties
----------------------------------------------------------------------------------------------
workers.tomcat_home=/usr/local/tomcat
workers.java_home=/usr/local/java/jdk
ps=/
worker.list=tomcat0,tomca1,loadbalancer
worker.tomcat0.port=11009
worker.tomcat0.host=localhost
worker.tomcat0.type=ajp13
worker.tomcat0.lbfactor=100
worker.tomcat1.port=12009
worker.tomcat1.host=localhost
worker.tomcat1.type=ajp13
worker.tomcat1.lbfactor=100
worker.loadbalancer.type=lb
worker.loadbalancer.balanced_workers=tomcat0,tomcat1
worker.inprocess.type=jni
worker.inprocess.class_path=${workers.tomcat_home}${ps}lib${ps}tomcat.jar
worker.inprocess.cmd_line=start
worker.inprocess.stdout=${workers.tomcat_home}${ps}logs${ps}inprocess.stdout
worker.inprocess.stderr=${workers.tomcat_home}${ps}logs${ps}inprocess.stderr
# vi /usr/local/tomcat/conf/server.xml
<!-- Note: A "Server" is not itself a "Container", so you may not
define subcomponents such as "Valves" at this level.
Documentation at /docs/config/server.html
-->
<Server port="8005" shutdown="SHUTDOWN">
<!--APR library loader. Documentation at /docs/apr.html -->
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
<Listener className="org.apache.catalina.core.JasperListener" />
<!-- JMX Support for the Tomcat server. Documentation at /docs/non-existent.html -->
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<!-- Global JNDI resources
Documentation at /docs/jndi-resources-howto.html
-->
<GlobalNamingResources>
<!-- Editable user database that can also be used by
UserDatabaseRealm to authenticate users
-->
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>
<!-- A "Service" is a collection of one or more "Connectors" that share
a single "Container" Note: A "Service" is not itself a "Container",
so you may not define subcomponents such as "Valves" at this level.
Documentation at /docs/config/service.html
-->
<Service name="Catalina0">
<Connector port="11080" protocol="HTTP/1.1"
maxThreads="150" connectionTimeout="20000"
redirectPort="8443" />
<Connector port="11009" protocol="AJP/1.3" redirectPort="8443"
maxThreads="250" connectionTimeout="60" />
<Engine name="Catalina0" defaultHost="localhost" jvmRoute="tomcat0">
<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"/>
<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>
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
<Host name="newweb.kxx.ac.kr" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context path="" docBase="/data/webuser/www" privileged="true" debug="0"/>
<Alias>newweb.kxx.ac.kr</Alias>
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
</Host>
<Host name="cms.kxx.ac.kr" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context path="" docBase="/data/k2web" reloadable="true" privileged="true" debug="0">
<Resource
auth="Container"
description="DB Connection"
name="jdbc/JWizardDB"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.driver.OracleDriver"
password="********"
maxIdle="5"
maxWait="-1"
username="k2web"
url="jdbc:oracle:thin:@2XX.247.29.156:1521:KXXORADB"
maxActive="20"
removeAbandoned="true"
removeAbandonedTimeout="60"
logAbandoned="true" />
</Context>
<Alias>cms.kxx.ac.kr</Alias>
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
</Host>
</Engine>
</Service>
<Service name="Catalina1">
<Connector port="12080" protocol="HTTP/1.1"
maxThreads="150" connectionTimeout="20000"
redirectPort="8443" />
<Connector port="12009" protocol="AJP/1.3" redirectPort="8443"
maxThreads="250" connectionTimeout="60" />
<Engine name="Catalina1" defaultHost="localhost" jvmRoute="tomcat1">
<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"/>
<Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
address="auto"
port="4001"
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>
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
<Host name="newweb.kxx.ac.kr" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context path="" docBase="/data/webuser/www" privileged="true" debug="0"/>
<Alias>newweb.kxx.ac.kr</Alias>
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
</Host>
<Host name="cms.kxx.ac.kr" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context path="" docBase="/data/k2web" privileged="true" debug="0" reloadable="true">
<Resource
auth="Container"
description="DB Connection"
name="jdbc/JWizardDB"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.driver.OracleDriver"
password="********"
maxIdle="5"
maxWait="-1"
username="k2web"
url="jdbc:oracle:thin:@2XX.247.29.156:1521:KXXORADB"
maxActive="20"
removeAbandoned="true"
removeAbandonedTimeout="60"
logAbandoned="true" />
</Context>
<Alias>cms.kxx.ac.kr</Alias>
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
</Host>
</Engine>
</Service>
</Server>
2. 설정이 다른것
#vi /usr/local/apache2/conf/extra/httpd-vhosts.conf
2XX.247.29.150
----------------------------------------------------------------------------------------------
<VirtualHost *:80>
ServerAdmin admin@kxx.ac.kr
DocumentRoot /data/webuser/www
ServerName 2XX.247.29.150
ServerAlias newweb.kxx.ac.kr
CustomLog logs/kxx.ac.kr-access_log common
jkMount /*.jsp loadbalancer
jkMount /*.do loadbalancer
jkMount /servlet/* loadbalancer
</VirtualHost>
<VirtualHost *:80>
ServerAdmin admin@kxx.ac.kr
DocumentRoot /data/k2web
ServerName 2XX.247.29.150
ServerAlias cms.kxx.ac.kr
CustomLog logs/kxx.ac.kr-access_log common
jkMount /*.jsp loadbalancer
jkMount /*.do loadbalancer
jkMount /servlet/* loadbalancer
</VirtualHost>
2XX.247.29.153
----------------------------------------------------------------------------------------------
<VirtualHost *:80>
ServerAdmin admin@kxx.ac.kr
DocumentRoot /data/webuser/www
ServerName 2XX.247.29.153
ServerAlias newweb.kxx.ac.kr
CustomLog logs/kxx.ac.kr-access_log common
jkMount /*.jsp loadbalancer
jkMount /*.do loadbalancer
jkMount /servlet/* loadbalancer
</VirtualHost>
<VirtualHost *:80>
ServerAdmin admin@kxx.ac.kr
DocumentRoot /data/k2web
ServerName 2XX.247.29.153
ServerAlias cms.kxx.ac.kr
CustomLog logs/kxx.ac.kr-access_log common
jkMount /*.jsp loadbalancer
jkMount /*.do loadbalancer
jkMount /servlet/* loadbalancer
</VirtualHost>
3. 각 가상 호스트 마다....WEB-INF 밑에 web.xml 수정
<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<display-name>newweb.kxx.ac.kr</display-name>
<description>
newweb.kxx.ac.kr HomePage.....
</description>
..................
<distributable/> <- 추가
</web-app>