APACHE+TOMCAT+MOD_JK Build load Balancing system.
0.os system with centos6.8 x64 2.6.32-642.el6.x86_64
1. First install the JDK environment this time using jdk-8u111-linux-x64.gz
The JDK and JRE installation directory is different, otherwise the Lib directory does not have Dt.jar and Tools.jar
To configure the environment variables as follows
Vi/etc/profile
#add Zwy 2017-08-29
Export java_home=/home/zhang/java/jdk1.8.0_111
Export JRE_HOME=/HOME/ZHANG/JAVA/JDK1.8.0_111/JRE
Export path= $JAVA _home/bin: $PATH
Export classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar
Export Ld_library_path=/usr/local/apr/lib
Source/etc/profile
Java-version If you can show the version number, the JDK is installed.
2. Install Tomcat. This time Tomcat uses 7.0.95 x64 bit
2-1 Note To modify the file under/usr/local/tomcat/conf server.xml
Shutdown 8005 *****connect http port 8080 *****connect AJP Port 8009 These three ports each process is different, or port occupancy issues occur.
2-2 Modify Jvmroute to TOMCAT1 instance name and turn on load balancing
<connector port= "11009" protocol= "ajp/1.3" redirectport= "8443"/>
<engine name= "Catalina" defaulthost= "localhost"
Jvmroute= "TOMCAT1" > Modify the Jvmroute here
<cluster classname= "Org.apache.catalina.ha.tcp.SimpleTcpCluster"/> Remove the previous comment
*************************************************************************
Unpackwars= "true" autodeploy= "true" >
<!--Singlesignon valve, share authentication between Web applications
Documentation at:/docs/config/valve.html--
<!--
<valve classname= "Org.apache.catalina.authenticator.SingleSignOn"/>
-
<!--Access log processes all example.
Documentation at:/docs/config/valve.html
Note:the pattern used is equivalent to using pattern= "common"-
<valve classname= "Org.apache.catalina.valves.AccessLogValve" directory= "Logs"
prefix= "Localhost_access_log" suffix= ". txt"
pattern= "%h%l%u%t "%r" %s%b "/>
Add this sentence to modify the default directory for the site
<context path= "" docbase= "/usr/local/tomcat/webapps/zwy/" debug= "0"/>
</Host>
2-3 According to the situation, add a index.html content with content of 1 under Tomcat1/webapps/zwy. Convenient for back testing
Add a content of index.html content of 2 under Tomcat2/webapps/zwy, as appropriate.
2-4 catalina.sh Add catalina_home at the end of the file
catalina_home=/usr/local/apache-tomcat-7.0.59/
Start./usr/local/tomcat/bin/startup.sh
Stop./usr/local/tomcat/bin/shutdown.sh
2-5 respectively test http://localhost:8080 display content of 1 http://localhost:8180 display content is 2
3. Install the apache2.2.34
3-1 Installing GCC
3-2 Apr
3-3 Installing Apr-util
3-4 Installing Pcre
3-4 compile./configure--prefix=/usr/local/apache--with-apr=/usr/local/apr--with-apr-util=/usr/local/apr-util-- With-pcre=/usr/bin/pcre-config--enable-so--enable-proxy--enable-proxy_http=shared--enable-module=so-- Enable-mods-shared=all--enable-proxy-ajp=shared--enable-proxy-balancer--disable-deflate
Do clean installation is not necessary.
Make
Make install
3-5 Downloads mod_jk.so Note that the version must be correct, otherwise prompt cannot load/usr/local/apache/modules/mod_jk.so elf error. Correct version: mod_jk-1.2.31-httpd-2.2.x.so
3-6 Rename the downloaded mod_jk-1.2.31-httpd-2.2.x.so to mod_jk.so and place it in the Apache modules directory, with permissions to 777
3-7 Modify httpd.conf at the end of the file add the following
Include conf/mod_jk.conf
3-8 Create a new mod_jk.conf under the Apache Conf directory
The contents are as follows:
#Load Module
LoadModule Jk_module modules/mod_jk.so
#指定 workers.properties file path
Jkworkersfile conf/workers.properties
#指定哪些请求交给tomcat处理, "Controller" is the name of the load-allocating controllers specified in the Workers.propertise
Jkmount/* Controller
3-9 Create a new workers.properties in the Apache Conf directory with the following contents
[Email protected] conf]# more workers.properties
Worker.list=controller,tomcat1,tomcat2
######### #tomcat1 ######
worker.tomcat1.port=8009
worker.tomcat1.host=127.0.0.1
Worker.tomcat1.type=ajp13
Worker.tomcat1.lbfactor=1
######### #tomcat2 ######
worker.tomcat2.port=8109
worker.tomcat2.host=127.0.0.1
Worker.tomcat2.type=ajp13
Worker.tomcat2.lbfactor=1
#######################
Worker.controller.type=lb
Worker.controller.balanced_workers=tomcat1,tomcat2
Worker.controller.sticky_session=false
Worker.controller.sticky_session_force=1
3-10./USR/LOCAL/APACHE/BIN/APACHECTL-T Check Syntax
3-11. http://localhost If show it works instructions Apache installation is OK.
3-12. Modify the default home page file in httpd.conf.
<ifmodule dir_module>
DirectoryIndex apache.html
</IfModule>
3-13:/usr/local/apache/bin/apachectl-k start Apache
3-14. http://localhost refreshes several times, with the contents alternating between 1 and 2.
Apache+tomcat Build Load Balancing System