tomcat设置没有什么可说的,关键是linux下的组播设置不熟悉好一番折腾,为免以后再走弯路所以笔记一下。
========如何开启tomcat cluster==============================================================================================
1、打开tomcat/conf/servr.xml
在<Engine name=...>节点下添加
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"
channelSendOptions="6">
<Manager className="org.apache.catalina.ha.session.BackupManager"
expireSessionsOnShutdown="false"
notifyListenersOnReplication="true"
mapSendOptions="6"/>
<!--
<Manager className="org.apache.catalina.ha.session.DeltaManager"
expireSessionsOnShutdown="false"
notifyListenersOnReplication="true"/>
-->
<Channel className="org.apache.catalina.tribes.group.GroupChannel">
<Membership className="org.apache.catalina.tribes.membership.McastService"
address="228.0.0.4"<!--组播地址-->
port="45564"<!--组播端口;通过address+port可以确定集群范围(可以借此细分集群)-->
frequency="500"
dropTime="3000"/>
<Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
address="192.168.1.49"<!--本地物理地址,尽量不要设置成127.0.0.1;-->
port="5000"<!--本地端口;如果在一个服务器上跑多个tomcat,记得此port值要有所区别-->
selectorTimeout="100"
maxThreads="6"/>
<Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">
<Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/>
</Sender>
<Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>
<Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/>
<Interceptor className="org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor"/>
</Channel>
<Valve className="org.apache.catalina.ha.tcp.ReplicationValve"
filter=".*\.gif|.*\.js|.*\.jpeg|.*\.jpg|.*\.png|.*\.htm|.*\.html|.*\.css|.*\.txt"/>
<Deployer className="org.apache.catalina.ha.deploy.FarmWarDeployer"
tempDir="/tmp/war-temp/"
deployDir="/tmp/war-deploy/"
watchDir="/tmp/war-listen/"
watchEnabled="false"/>
<ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>
</Cluster>
servier.xml中已有默认的<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>,它定义了一个默认的cluster,取消注释即可发挥作用。
关于tomcat cluster的详细设置可以参考tomcat文档:docs/cluster-howto.html
2、打开要复制应用的web.xml(WEB_INF/web.xml):
添加<distributable/>节点;
3、ok,enjoy it!
=============================================================================================================================
========关于服务器组播的支持=================================================================================================
由于cluster使用broadcast通信,所以要保证支持服务器支持多播。具体的操作方式如下:
1、确定是否支持组播:
a、ubuntu10.04下内核默认开启组播,可以用“ifconfig eht1”检查,如果存在“MULTICAST MTU:1500”字样即无需重新编译内核;否则需要重新编译kernel;
b、window下默认支持组播,无需附加设置;
2、针对使用的网络设备手动添加路由规则:
route add -net 224.0.0.0 netmask 240.0.0.0 dev eth1
route add -net 224.0.0.0 netmask 240.0.0.0 dev lo
不要忘记local,我就是在这里浪费时间了。
=============================================================================================================================
===================================================
如何测试广播是否运行:
下载:http://cvs.apache.org/~fhanik/tomcat-replication.jar (提供下载
)
测试一下广播
java -cp tomcat-replication.jar MCaster 224.0.0.1 45564 Terminal1
java -cp tomcat-replication.jar MCaster 224.0.0.1 45564 Terminal2
如果不报错则能正常广播
===================================================
=============================================================================================================================
测试环境: window7+tomcat7.0.26+jdk1.6
ubuntu10.04+tomcat7.0.26+jdk1.6
=============================================================================================================================
分享到:
相关推荐
#dpkg -i language-pack-zh-hans_1%3a10.04+20100421_all.deb language-pack-zh-hans-base_1%3a10.04+20100421_all.deb language-pack-gnome-zh-hans-base_1%3a10.04+20100421_all.deb language-pack-gnome-zh-hans_...
Ubuntu10.04 2440 嵌入式
官方的chrome 只支持12.04以上的版本,由于所需的库不同 ubuntu 10.04 只能用之前的版本
家里的老笔记本装了诸多新版Ubuntu均不稳定,最终还是装回了10.04,结果安装最新版的方式得到的最新版本已经不能兼容10.04了。于是上网找了Chrome稳定版本的历史版本,然后本地下载各种版本尝试安装,得到了最新可...
绝对原创,本人亲自真机测试,分别两套方案 win7+Ubuntu10.04+CentOS5.4 win7+Ubuntu10.04+Fedora13 完美引导多系统
VM7安装Ubuntu 10.04系统 VM7安装Ubuntu 10.04系统
Ubuntu 10.04完全版入门教程 包含Ubuntu安装,配置过程,以及shell编程等内容。 分两部分: Ubuntu 10.04完全版first part Ubuntu 10.04完全版second part
ubuntu10.04 安装 opencv2.2.0
最近开始学习Linux操作系统,遇到了很多问题,走了不少弯路。 Linux的却比windows强大很多,但像我这样刚入门的,用起来却不那么顺手。就拿上网来说吧,我在网上查了...此方法只适用于Ubuntu10.04,低版本我没试过。
介绍最新版本Ubuntu10.04的安装,配置,shell编程等内容,快速入门提高的资料。 分两卷: Ubuntu10.04入门教程01 Ubuntu10.04入门教程02
4月29日最新发布的Ubuntu10.04正式版,是有一个LTS长期支持的版本。
安装Ubuntu10.04全过程(图解)
NULL 博文链接:https://ethanwooblog.iteye.com/blog/1340252
这是10。04LTS的离线汉化包,专给没办法连网的同志用的,希望能帮助到你们。。。。
ubuntu10.04安装配置指南.docx
主要介绍了关于嵌入式开发的环境配置 开发环境是Ubuntu 10.04LTS
android2.2源码编译-Ubuntu10.04 (X86) + android2.2 + JDK1.6android2.2源码编译-Ubuntu10.04 (X86) + android2.2 + JDK1.6android2.2源码编译-Ubuntu10.04 (X86) + android2.2 + JDK1.6
在Vmware虚拟机下安装ubuntu10.04的详细图文文档。