工行原图
更改后的图:
注:
用户访问工行服务器,访问的为apahce的接口,apache做负载将用户分配到不同的tomcat中,当其中一个tomcat出现故障,apache只会使用另一个tomcat,不会影响业务,故障的tomcat修复后会自动加入工作队列。
项目应用接口:
服务 |
功能 |
端口 |
Apache |
负载 |
80 |
Tomcat |
应用管理服务 |
8009 |
Tomcat1 |
应用管理服务 |
8019 |
项目部署:
一、 部署tomcat(此处为公司的脚本制作的,tomcat安装,请大家参考其他文档)
1、进入/mnt/backup/rytong目录,解压base包。
# tar -zxvf module-tms-0.3-dtar.gz
进入解压目录,给执行权限
# chmod +x setup.ryt
执行脚本
系统会自动部署tomcat环境
部署目录为:
/var/www/apps/java/
2、发布代码略
3、修改端口号,
1)tomcat1
# vi conf/server.xml
connectionTimeout="20000"
redirectPort="8443" />
························································
··························································
2)tomcat2
··························································
connectionTimeout="20000"
redirectPort="8443" />
························································
二、 安装apache
# yum install http*
Apahce负载需要mod_jk模块,rpm安装的http服务是没有的,需要手动安装。
Mod_jk下载地址:http://tomcat.apache.org/download-connectors.cgi
tomcat-connectors-1.2.35-src.tar.gz
# tar -zxvf tomcat-connectors-1.2.35-src.tar.gz
安装mode_jk需要安装autoconf,libtool,
# ./buildconf.sh执行脚本,脚本在native目录内
显示结果为:
buildconf: checking installation...
buildconf: autoconf version 2.59 (ok)
buildconf: libtool version 1.5.22 (ok)
buildconf: libtoolize --automake --copy
buildconf: aclocal
buildconf: autoheader
buildconf: automake -a --foreign --copy
buildconf: autoconf
编译前配置
# ./configure --with-apxs=/usr/sbin/apxs
编译:
#make、
将模块放入到apache模块目录下
# cp apache-2.0/mod_jk.so /etc/httpd/modules/
在apache的conf目录下建立workers.properties
# vi workers.properties
内容如下:
worker.list=BALANCER
worker.tomcat_1.host=localhost
worker.tomcat_1.port=8009
worker.tomcat_1.type=ajp13
worker.tomcat_1.lbfactor=1
worker.tomcat_2.host=localhost
worker.tomcat_2.port=8019
worker.tomcat_2.type=ajp13
worker.tomcat_2.lbfactor=1
worker.BALANCER.type=lb
worker.BALANCER.balance_workers=tomcat_1,tomcat_2
修改apache的httpd.conf
LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/workers.properties
JkMount /servlet/* BALANCER
JkMount /*.* BALANCER
三、 Tomcat优化
添加主目录
workDir="/var/www/apps/java/tomcat2/webapps/icbcmovie" />
connectionTimeout="20000"
redirectPort="8443" maxThreads="1000" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" compression="on" compressionMinSize="2048" acceptCount="500" URIEncoding="UTF-8"/>
catalina.sh 中需要增加内存
JAVA_OPTS="-Xms512m -Xmx1024m -XX:PermSize=128m -XX:MaxPermSize=512m"
四、 测试略