Apache2 + Tomcat 5 + JK2 : 2004-11-04 Release Ver. 1.0.0.1 Email : ykkim@cabsoftware.com Apache JK2 ( )., JK2 Apache2 JK2. 3 - JK2, Tomcat -.. 3, Stress ( ),., localhost ip., 2. 2,. Windows XP., Window XP Apache2 + Tomcat5 + JK2. Windows XP Apache_2.0.52-win32-x86-no_ssl.msi (http://ftp.apache-kr.org/httpd/binaries/win32/apache_2.0.52-win32-x86-no_ssl.msi) Jakarta-tomcat-5.0.28.zip (http://ftp.apache-kr.org/jakarta/tomcat-5/v5.0.28/bin/jakarta-tomcat-5.0.28.zip) Jakarta-tomcat-connectors-jk2.0.4-win32-apache2.0.49.zip (http://ftp.apache-kr.org/jakarta/tomcat-connectors/jk2/binaries/win32/jakarta-tomcat-connectors-jk2.0.4-win32- apache2.0.49.zip) Jdk-1_5_0-windows-i586-iftw.exe or j2sdk-1_4_1_02-windows-i586.exe (http://java.sun.com/downloads/index.html) mysql-4.1.7-win.zip Mysql-connector-java-3.0.15-ga.zip (http://dev.mysql.com/downloads/) 1/27
5. JVM. SUN J2SE5.0, JSP 1.4 J2SE5.0. J2SE5.0. J2SE5.0, Window XP JAVA_HOME. 1. 2/27
2. JAVA_HOME J2SE5.0 J2SE1.4, JAVA_HOME Jakarta-tomcat-5.0.28.zip. 2,. 1. C:Apache Group. 2. C:Apache Group, tomcat1. 3. C:Apache Group 3/27
4. tomcat1 3. C:Apache Group, tomcat2. 5. 4/27
6. tomcat2 2. tomcat1 tomcat2. 2. : 1. tomcat1 bin. 2. service.bat. 44,45 SERVICE_NAME PR_DISPLAYNAME. tomcat1. set SERVICE_NAME=Tomcat5 set PR_DISPLAYNAME=Apache Tomcat set SERVICE_NAME=Tomcat51 set PR_DISPLAYNAME=Tomcat1., SERVICE_NAME, PR_DISPLAYNAME. SERVICE_NAME. 5/27
7. tomcat1 service.bat 8. tomcat1 SERVICE_NAME PR_DISPLAYNAME 6/27
3. tomcat1 service.bat tomcat2 service.bat. Tomcat2 SERVICE_NAME PR_DISPLAYNAME Tomcat52 Tomcat2. 9. tomcat2 service.bat 4. 2,3 service.bat. cmd.exe., C:Apache Grouptomcat1bin service.bat install. 7/27
10. 1 5. (->->), Tomcat1. 6. Tomcat1 C:Apache Grouptomcat1bintomcat5w.exe. JVM / /. GUI tomcat1 tomcat51 tomcat5w.exe. tomcat5w.exe //ES//Tomcat51, //ES//, Tomcat51 SERVICE_NAME. tomcat5w.exe Windows service HOW-TO. 8/27
11. tomcat51 tomcat5w.exe 12. tomcat5w.exe, Tomcat1 9/27
13. tomcat5w.exe JVM 7. Tomcat1. Tomcat2. 4,5,6 Tomcat2. 13. Tomcat2 10/27
14. Tomcat52 tomcat5w.exe 15. tomcat5w.exe Tomcat52 8. (->->), Tomcat2. 11/27
16. Tomcat1, Tomcat2 2., JK2 Apache2. TCP, TCP. server.xml, Apache2 JK2 workers2.properties 2. 2.3 server.xml {Tomcat }confserver.xml. 2, Apache2 2., TCP. tomcat1. 1. C:Apache Grouptomcat1confserver.xml. 2. 13 <Server port="8005" shutdown="shutdown" debug="0"> <Server port="11005" shutdown="shutdown" debug="0">. 12/27
3. HTTP Coyote HTTP/1.1 Connector disable. HTTP Apache JK2. List 1. Coyote HTTP/1.1 Connector List 2. Coyote HTTP/1.1 Connector 4. Coyote/JK2 AJP 1.3 Connector port 8009 11009. List 3. Coyote/JK2 AJP 1.3 Connector port 5. JK/JK2 jvmroute,. JK/JK2 Catalina, jvmroute tomcat1. jvmroute JK2 workers2.properties. List 4. List 5. JK/JK2 enable 6. Cluster Cluster enable. Clustering Clustering/Session Replication HOW-TO (http://jakarta.apache.org/tomcat/tomcat-5.0-doc/cluster-howto.html)... setattribute removeattribute. 13/27
17. 18. Cluster enable 14/27
7. tomcat1 server.xml, tomcat2 server.xml. Tomcat2 tomcat1, port jvmroute tomcat2. 8. 13 <Server port="8005" shutdown="shutdown" debug="0"> <Server port="12005" shutdown="shutdown" debug="0">., port. 2. 9. Coyote HTTP/1.1 Connector, Coyote/JK2 AJP 1.3 Connector port 12009. 19. tomcat2 Coyote/JK2 AJP 1.3 Connector 10. JK/JK2 jvmroute,. JK/JK2 Catalina, jvmroute tomcat2. jvmroute JK2 workers2.properties. 15/27
20. JK/JK2 enable 11. tomcat1 Clustering ( 6) tomcat2 Clustering. tcplistenport 4002 tomcat1 4001..,, web.xml <distributable/>. 16/27
21. Cluster, tcplistenport 4002 2 Apache2 JK2.. /,. Apache2 JK2, (L4 L7 ) ( LoadDirector). HTTP JSP/ 2, sticky session. 17/27
22., 22 multicast. EJB JNDI JBoss J2EE. 2.3,. Apache2 JK2. Apache AJP1.3 Connector, HTTP., (HTML, JPG, GIF, SWF, XML) Apache, JSP/., JK2. Apache_2.0.52-win32-x86-no_ssl.msi.. Apache2 C:Apache GroupApache2. 18/27
, IIS, Apache2 80, IIS,. IIS Apache2, Apache2, conf/httpd.conf Listen 80 Listen 8080. 23. Apache Apache2 JK2. JK2. 24. JK2 conf Apache2 (mod_jk2.conf.sample, workers2.properties.sample). Modules Apache2 (mod_jk2.so). mod_jk2 index.html JK2. Apache2, JK2 Apache2. 1. JK2 modules/mod_jk2.so {Apache2 }modules 19/27
. 25. mod_jk2.so Apache2 modules 2. JK2 conf mod_jk2.conf.sample workers2.properties.sample {Apache2 }conf, mod_jk2.conf workers2.properties. 26. Apache2 conf JK2 20/27
3. httpd.conf mod_jk2. Httpd.conf. LoadModule jk2_module modules/mod_jk2.so 27. Apache2 mod_jk2 4. workers2.properties,. [shm] info=scoreboard. Requried for reconfiguration and status with multiprocess servers. file=anonymous # Defines a load balancer named lb. Use even if you only have one machine. [lb:lb] noerrorheader=1 stickysession=1 recovery=60 # Example socket channel, override port and host. [channel.socket:127.0.0.1:11009] port=11009 host=127.0.0.1 graceful=0 tomcatid=tomcat1 group=lb 21/27
[channel.socket:127.0.0.1:12009] port=12009 host=127.0.0.1 graceful=0 tomcatid=tomcat2 group=lb # define the worker1 [ajp13:127.0.0.1:11009] tomcatid=tomcat1 max_connections=120 channel=channel.socket:127.0.0.1:11009 group=lb # define the worker2 [ajp13:127.0.0.1:12009] tomcatid=tomcat2 max_connections=120 channel=channel.socket:127.0.0.1:12009 group=lb # Map the Tomcat examples webapp to the Web server uri space [uri:/*.jsp] group=lb [uri:/servlet/*] group=lb [status:] info=status worker, displays runtime information [uri:/jkstatus/*] info=the Tomcat /jkstatus handler group=status: List 6. 2 workers2.properties workers2.properties, lb stickysession 1(true)., noerrorheader recovery. 22/27
JK2 JK2 Components., List 6 2 channel.socket 2 worker(ajp13), 2.3 server.xml 2 JvmRoute., List6 workers2.properties channel.socket worker IP. List6 JK2 workers2.properties. shm JK2 Components, workers2.properties. 1. shm file anonymouse size anonymous... slots 256. usememory 0. mpm. Apache2 JK2. (Sticky Session ). jsp 2. default.jsp", tomcat1 tomcat2. <html> <body bgcolor="red"> <center> <%= request.getsession().getid() %> <h1> Tomcat1 </h1> </body> </html> List 7. tomcat1 default.jsp 23/27
<html> <body bgcolor="blude"> <center> <%= request.getsession().getid() %> <h1> Tomcat2 </h1> </body> </html> List 8. tomcat2 default.jsp List7 List8 default.jsp., Tomcat1, Tomcat2 Apache2., http://localhost:8080/default.jsp. Sticky Session, tomcat1 ( ), tomcat1., http://localhost:8080/default.jsp tomcat2 ( ).., http://localhost:8080/jkstatus Apache2+JK2. (select, response update) update insert.net.,. 3.,.. ACT(.NET Application Center Test ) HTTP Apache2+JK2+2 tomcat 5, HTTP,,,. 24/27
28. 1 tomcat ( ) - 115 tomcat fail 29. 2 tomcat Apache2 ( ) - 200 25/27
30. 1 tomcat ( ) 31. 2 tomcat Apache2 ( ) 26/27
32. 1 tomcat ( HTTP ) 33. 2 tomcat Apache2 ( HTTP ) Apache2+Tomcat 27/27