O primeiro local em que você deve dar uma olhada é catalina.out
, ele informará o que pode estar errado.
Se você não conseguir trabalhar com multicast, tente associação estática (acho que será mais simples) .
Abaixo está minha configuração:
Coloque o nó <Cluster
dentro do elemento <Host
:
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat1">
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster">
<Channel className="org.apache.catalina.tribes.group.GroupChannel">
<Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
address="192.168.5.149"
port="4000"
selectorTimeout="100"
maxThreads="6"/>
<Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>
<Interceptor className="org.apache.catalina.tribes.group.interceptors.StaticMembershipInterceptor">
<Member className="org.apache.catalina.tribes.membership.StaticMember"
port="4001"
securePort="-1"
host="192.168.5.199"
domain="staging-cluster"
uniqueId="{0,1,2,3,4,5,6,7,8,9}"/>
</Interceptor>
</Channel>
<Deployer className="org.apache.catalina.ha.deploy.FarmWarDeployer"
tempDir="/usr/share/tomcat6/tempdir/"
deployDir="/usr/share/tomcat6/webapps/"
watchDir="/usr/share/tomcat6/watchdir/"
watchEnabled="true"/>
</Cluster>
</Host>
</Engine>
- O atributo
address
no elemento<Receiver
é o IP do nó 1 endereço. (no seu caso é .101) - O
port
está atendendo a mensagens de replicação no nó 1 (4000-4100) - O
Member's port
em<Interceptor
está escutando mensagens de cluster no nó 2 - O
Member's host
é o endereço IP do nó 2 (.102)
server.xml
no nó 2:
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster">
<Channel className="org.apache.catalina.tribes.group.GroupChannel">
<Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
address="192.168.5.199"
port="4001"
selectorTimeout="100"
maxThreads="6"/>
<Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>
<Interceptor className="org.apache.catalina.tribes.group.interceptors.StaticMembershipInterceptor">
<Member className="org.apache.catalina.tribes.membership.StaticMember"
port="4000"
securePort="-1"
host="192.168.5.149"
domain="staging-cluster"
uniqueId="{0,1,2,3,4,5,6,7,8,9}"/>
</Interceptor>
</Channel>
<Deployer className="org.apache.catalina.ha.deploy.FarmWarDeployer"
tempDir="/usr/share/tomcat6/tempdir/"
deployDir="/usr/share/tomcat6/webapps/"
watchDir="/usr/share/tomcat6/watchdir/"
watchEnabled="false"/>
</Cluster>
Certifique-se de que o Tomcat possa gravar na pasta tempDir
e watchDir
:
chmod g+w tempDir watchDir
chgrp tomcat tempDir watchDir
Se você não fizer isso, receberá o erro abaixo:
Aug 13, 2011 10:28:33 PM org.apache.catalina.ha.deploy.FarmWarDeployer messageReceived
SEVERE: Unable to read farm deploy file message.
java.io.IOException: Permission denied
Lembre-se de adicionar <distributable/>
em webapps/ROOT/WEB-INF/web.xml
:
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
...
<display-name>Welcome to Tomcat</display-name>
<description>
Welcome to Tomcat
</description>
<distributable/>
</web-app>
Sempre que você copiar um arquivo .war
para a pasta watchdir
no nó 1, verá algo como o seguinte em catalina.out
:
Aug 14, 2011 1:40:58 AM org.apache.catalina.ha.deploy.WarWatcher check
INFO: check cluster wars at /usr/share/tomcat6/watchdir
Aug 14, 2011 1:40:59 AM org.apache.catalina.ha.deploy.FarmWarDeployer fileModified
INFO: Installing webapp[/cas] from /usr/share/tomcat6/webapps/cas.war
Aug 14, 2011 1:40:59 AM org.apache.catalina.ha.deploy.FarmWarDeployer remove
INFO: Cluster wide remove of web app /cas
Aug 14, 2011 1:40:59 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive cas.war
e no nó 2:
Aug 14, 2011 1:40:59 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive cas.war
Boa sorte!