简体   繁体   English

使用FarmWarDeployer部署WebApp tomcat 7集群

[英]Deploy webapps tomcat 7 cluster with FarmWarDeployer

I build a tomcat cluster with 2 nodes. 我用2个节点构建了一个tomcat集群。 I configured the cluster deployer FarmWarDeployer to watch a directory for war file. 我将群集部署程序FarmWarDeployer配置为监视目录中的war文件。 All works fine if the 2 nodes are started: deploying a war on watch dir in the node1 will send war file to node2. 如果启动了2个节点,则一切工作正常:在node1的watch dir上部署war会将war文件发送到node2。 But if the copy of the war file in the watch directory is done while node2 is down, the node2 doesn't receive the new war file. 但是,如果在node2处于关闭状态时完成了war目录中war文件的复制,则node2将不会收到新的war文件。

Is there any configuration to let the nodes check new war filese and receive it when it starts? 是否有任何配置可以让节点检查新的战争文件并在启动时接收?

I don't believe that this is possible. 我不认为这是可能的。 As I understand it, the FarmWarDeployer listens for cluster messages which are sent when a new WAR file is found or when a WAR needs to be undeployed. 据我了解,FarmWarDeployer会侦听在找到新的WAR文件或需要取消部署WAR时发送的群集消息。 If one of the nodes in your cluster is down, it's going to miss those messages. 如果群集中的某个节点发生故障,它将丢失这些消息。

I suppose that you could run touch <your-war-file> after the downed node was restarted and trigger another deploy. 我想您可以在重新启动崩溃的节点后运行touch <your-war-file>并触发另一个部署。 Alternatively since you have a small cluster, you could just manually copy the WAR file to the downed node before you restart it. 另外,由于您的集群很小,您可以在重新启动WAR文件之前将其手动复制到已关闭的节点上。 Then that node will be up-to-date when it restarts. 然后,该节点在重启时将是最新的。

Outside of that, I'd suggest looking at a different way of deploying your WAR file. 除此之外,我建议您考虑以其他方式部署WAR文件。 Some quick suggestions that work for small clusters: 一些适用于小型集群的快速建议:

  1. Copy the WAR file to shared storage (ie mounted to both nodes). 将WAR文件复制到共享存储(即安装到两个节点)。 Add a cron job or small background task to each node that monitors the shared storage mount and when a new file is found, deploy it (ie copy to webapps directory). 向监视共享存储安装的每个节点添加cron作业或小型后台任务,并在找到新文件时进行部署(即,复制到webapps目录中)。 Don't deploy directly from the shared storage, that's asking for trouble. 不要直接从共享存储中进行部署,这会带来麻烦。

  2. Use scp or a similar tool to copy the WAR file to your nodes. 使用scp或类似工具将WAR文件复制到您的节点。 Use a similar cron job or background task to take the uploaded file and deploy it. 使用类似的cron作业或后台任务来获取上载的文件并进行部署。

For larger installations, you could look at using a deployment tool like Puppet, Chef, Ansible or another similar technology. 对于较大的安装,您可以考虑使用诸如Puppet,Chef,Ansible或其他类似技术的部署工具。 Really you could use these for a smaller installation to, it just might be overkill 的确,您可以将它们用于较小的安装,这可能是过大的了

Im using the below config, rem to nest inside .. (your cluster has to work first, i use unicast clustering). 我使用下面的配置,雷姆嵌套在..(您的群集必须首先工作,我使用单播群集)。

<Deployer className="org.apache.catalina.ha.deploy.FarmWarDeployer" tempDir="/var/tmp/war-tmp/" deployDir="/usr/local/tomcat8053/webapps/" watchDir="/var/tmp/war-watch/" watchEnabled="true" processDeployFrequency="1" />

repeat the config for every other nodes in the cluster, but set the watchEnabled="false" then refresh, even if is to re-copy, the war files in the watchDir . 对集群中的所有其他节点重复配置,但是设置watchEnabled =“ false”然后刷新,即使要重新复制watchDir中的war文件。 Give the host node some time, it will deploy and then deploy to the other nodes. 给主机节点一些时间,它将部署,然后部署到其他节点。 for prod, may need to set processDeployFrequency="2" to watch less often. 对于产品,可能需要将processDeployFrequency =“ 2”设置为较少观看。

hope this helps someone. 希望这对某人有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM