RHEL5下的Apache2.0+Tomcat5.5的集群配置(2)

B、安装189的Tomcat和Apache
1、同A
2、同A
3、同A
Apache安装:(大概需要30分钟(虚拟机情况))
# bzip2 -d  httpd.tar.bz2
---上面解压完之后执行下面的命令。
# tar -xvf httpd.tar
解完之后会出现多一个文件夹 httpd
#sh configure --prefix=/usr/local/apache --enable-module=so
#make
#make install
安装apache至/usr/local/apache 并配置apache支持dso方式
配置过程
a.下载mod_jk.so 文件放到apache下的modules下(或者自己编译)
地址: 请选择正确的操作系统和Apache的版本。
b.在apache的conf下建立文件workers.properties
(待测试自己编译mod_jk.so)Fedora.cc
首先下载tomcat-connectors-1.2.26-src.tar.gz包到本地,我的目录是/usr/zgl/install,然后解压到本地,生成目录tomcat-connectors-1.2.26-src,cd tomcat-connectors-1.2.26-src/native,然后:
  # ./configure --with-apxs=/usr/zgl/httpd/bin/apxs
  /usr/zgl/httpd是apache目录。
  # make && make install
  过程中不出错就ok啦,当然保险起见,到apache的modules目录下看看mod_jk.so存在与否,最好在看看生成时间,如果没有问题,编译过程就结束了。

添加内容:
#
# workers.properties
#
# list the workers by name
worker.list=tomcatlb, status
# localhost server 1
# ------------------------
worker.tomcat188.port=8009
worker.tomcat188.host=192.168.6.188
worker.tomcat188.type=ajp13
worker.tomcat188.lbfactor=1
worker.tomcat188.connection_pool_timeout=750
worker.tomcat188.socket_keepalive=0
worker.tomcat188.socket_timeout=300000
worker.tomcat188.connect_timeout=10000
worker.tomcat188.reply_timeout=330000
# localhost server 3
# ------------------------
worker.tomcat189.port=8009
worker.tomcat189.host=192.168.6.189
worker.tomcat189.type=ajp13
worker.tomcat189.lbfactor=1
worker.tomcat189.connection_pool_timeout=750
worker.tomcat189.socket_keepalive=0
worker.tomcat189.socket_timeout=300000
worker.tomcat189.connect_timeout=10000
worker.tomcat189.reply_timeout=330000
worker.tomcatlb.type=lb
worker.retries=3
worker.tomcatlb.balanced_workers=tomcat188,tomcat189
worker.tomcatlb.sticky_session=1
worker.status.type=status

c.在conf下添加一个mod_jk.conf文件
LoadModule jk_module modules/mod_jk.so
#configure mod_jk
JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel debug

d.在conf下增加一个虚拟机配置文件vhosts.conf (这个不是必须的,可以将JkMount 的写其他的配置文件中)
<VirtualHost *:80>
ServerAdmin maodain@maodain.com
DocumentRoot /usr/local/apache/htdocs
ServerName maodain.org
ErrorLog logs/maodain.org-error_log
CustomLog logs/maodain-access_log common
DirectoryIndex index.htm index.html
JkMount /webapp-abc/langSelect.action?lang=zh tomcatlb
JkMount /*.jsp tomcatlb
JkMount /*.action tomcatlb
JkMount /*j_spring_security_check tomcatlb
JkMount /webapp/dwr/* tomcatlb
JkMount /*j_spring_security_logout tomcatlb
</VirtualHost>

e.修改conf下的httpd.conf文件加上
Include conf/vhosts.conf
Include conf/mod_jk.conf
至此集群搭建完毕,重启tomcat和apache。
这里,再提供一个链接,可以监控和配置负载均衡的各种信息

test.jsp放在tomcat的webapp/root/目录下:
<html>
<body bgcolor="red">
<center>
<%= request.getSession().getId() %>
<h1>Tomcat 1</h1>
</body>
</html>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wyxzws.html