背景:a和b均安装resin, apache ,安装同样的java web应用.如果有图片等文件资源文件请用共享方式(共享磁盘阵列,nfs,samba等)

步骤:进行同步

apache server/resin server(a,b,c三个jvm)

caucho.o对a,b两台服务器上的各3个jvm应用进行负载均衡

步骤一: 修改a服务器的resin.conf

 

步骤二:

I.启动服务器a,b,c:

$resin/bin/httpd.sh -pid a.pid -server a start

$resin/bin/httpd.sh -pid b.pid -server b start

$resin/bin/httpd.sh -pid c.pid -server c start

II.停止服务器a,b,c:

$resin/bin/httpd.sh -pid a.pid stop

$resin/bin/httpd.sh -pid b.pid stop

$resin/bin/httpd.sh -pid c.pid stop

步骤三:修改b服务器的resin.conf

<caucho.com></caucho.com>

<httpd-server></httpd-server>

<srun id="a" host="192.168.1.2&quot; port=" srun-index="1"></srun>

<srun id="b" host="192.168.1.2&quot; port=" srun-index="2"></srun>

<srun id="c" host="192.168.1.2&quot; port=" srun-index="3"></srun>

.....

 

 

II.启动服务器a,b,c:

$resin/bin/httpd.sh -pid a.pid -server a start

$resin/bin/httpd.sh -pid b.pid -server b start

$resin/bin/httpd.sh -pid c.pid -server c start

II.停止服务器a,b,c:

$resin/bin/httpd.sh -pid a.pid stop

$resin/bin/httpd.sh -pid b.pid stop

$resin/bin/httpd.sh -pid c.pid stop

此外,a服务器apache的httpd.conf

LoadModule caucho_module libexec/mod_caucho.so

AddModule mod_caucho.c

<ifmodule mod_caucho.c=""></ifmodule>

CauchoConfigFile /dir/of/resin.conf

CauchoHost 192.168.1.2 6802

CauchoHost 192.168.1.2 6803

CauchoHost 192.168.1.2 6804

<location caucho-status=""></location>

SetHandler caucho-status

 

 

启动a服务器apache

$apache/bin/apachectl start

停止a服务器apache

$apache/bin/apachectl stop

b服务器apache的httpd.conf

LoadModule caucho_module libexec/mod_caucho.so

AddModule mod_caucho.c

<ifmodule mod_caucho.c=""></ifmodule>

CauchoConfigFile /dir/of/resin.conf

CauchoHost 192.168.1.1 6802

CauchoHost 192.168.1.1 6803

CauchoHost 192.168.1.1 6804

<location caucho-status=""></location>

SetHandler caucho-status

 

 

启动a服务器apache

$apache/bin/apachectl start

停止a服务器apache

$apache/bin/apachectl stop

访问http://a/caucho-status或者http://b/caucho-status,可以看到当前各个jvm的运行状况:(下图为笔者在某客户上的部署的运行状态,估计使10.8.254.10的6803的jvm停止的状态)

如果没有硬件负载均衡器或者lvs,可以把apache充当均衡器,即把a,b的apache放置在负载均衡服务器中,但在此种情况下,容易在apache上出现瓶颈.