maven在一行中部署到tomcat集群(多个) [英] maven deploy to tomcat cluster (multiple) in one line

查看:196
本文介绍了maven在一行中部署到tomcat集群(多个)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在尝试将maven部署到构成我们集群的多个服务器,只需一行。

We're trying to have maven deploy to many multiple servers that form our cluster in just one line.

此解决方案的工作原理很好,除了我们需要运行它重复(每个服务器安装1次),我们的目标是在我们的集成服务器(jenkins)建立一个成功的工件后进行。此时,拥有矩阵功能并不真正是一个选项。如果我们只需要部署,那么为什么每个服务器重新构建项目? (加上这样做的时间)

This solution works just fine except that we need to run it repeatedly (1 time per server installation) and our goal is to do it after our integration server (jenkins) buils a successful artifact. And having a matrix feature is not really an option at this time. Why build again the project per server if we just need to deploy it? (plus the time spend doing this)

我们一直在尝试使用maven配置文件(每个服务器一个,并尝试一次激活它们,或者一个大的配置文件服务器上),但没有运气的那个选项,tomcat-maven插件不这样工作。

We've been experimenting using maven profiles (one per server and trying to activated them all at once, or one big profile with all server on it) but no luck with that option, the tomcat-maven-plugin does not work that way.

Jenkins似乎有一个基于货物的部署插件,但一次只处理一个服务器

Jenkins seems to have a deploy plugin that's based on cargo, but only handles one server at a time

有办法完成这个吗?使用maven-tomcat-plugin?还是詹金斯/哈德森插件?

Is there a way to accomplish this? Either using maven-tomcat-plugin? Or Jenkins/Hudson plugin?

您有哪些其他想法有关如何在成功构建后如何将战争部署到群集? (我试图避免一个shell脚本,只是因为可移植性问题)

Any other ideas from you experts about how to deploy the war to the cluster after a successful build? (I'm trying to avoid a shell script, just becuase of portability issues)

推荐答案

如果你需要它只发生在一行,我建议执行一个CMD,Ant,bash等脚本作为一行,使该脚本执行多个操作。

If you need it to happen with only one line, I suggest executing a CMD, Ant, bash, etc. script as the "one-line" and make that script do more than one thing.

例如如果您使用 Ant ...
您的一行可能是这样的: ant DeployToCluster 。您的build.xml文件可能包含目标 DeployToCluster ,其中可能包含许多步骤。想想它就像重构一个有很多事情的代码方法。调用您的方法的代码将成为一个单行程序。

For instance, if you used Ant... Your one line could be something like this: ant DeployToCluster. And your build.xml file could have the target DeployToCluster which may include many steps. Think of it like refactoring out a method of code which does many things. The code which invokes your method becomes a one-liner.

您不可能找到一个单独的命令来执行以下操作,除非它只是执行一个现有的其他人写的脚本可以做你想要的。

You won't likely find a single command to do what you are after, unless it is just executing an existing script which someone else has written that does what you want.

无论哪种方式,一次可以将代码部署到单个服务器通常是个好主意。这样,您可以随时保持应用程序/服务的正常运行,因为您只能一次影响一个节点,而其他节点可以继续运行。它还具有如下优点:如果出现了可怕的错误,您可以不重新启用集群中的一个节点,并诊断一个服务器的问题,而不是将整个集群部署到不正确的部署。以下部署策略步骤如下:

Either way, it is usually a good idea to be able to deploy code to individual servers at a time. This lets you keep your app/service up at all times because you are only affecting one node at a time while the others can continue running. It also has the advantage that if something goes horribly wrong, you can just not re-enable the one node in the cluster and diagnose the one server's problem, as opposed to taking out your entire cluster with a bad deploy. The deploy strategy steps our script follows is:


  1. 禁止监视单个节点

  2. 拉那个节点集群

  3. 部署新的代码

  4. 验证节点正常运行新代码

  5. 放置节点返回集群

  6. 重新启用该节点的监控

  7. 对每个其他节点重复步骤

  1. Disable monitoring of single node
  2. Pull that node out of cluster
  3. Deploy new code to it
  4. Verify node is operating properly with new code
  5. Put node back into cluster
  6. Re-enable monitoring for that node
  7. Repeat steps for every other node

如果任何步骤出现问题,我们总是为用户提供一个工作环境。

If anything goes wrong at any step, we always have a working environment for our users.

这篇关于maven在一行中部署到tomcat集群(多个)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆