9

my question is basically two questions, but since they are closely related I thought that it makes sense to ask them en-bloque.

Case:
I am running a webapplication, which is distributed over multiple AWS EC2 instances behind a AWS Elastic Load Balancer

Intended goals:
a) When deploying new app code (php) it should be automatically distributed to all EC2 instances.
b) When new EC2 instances are added, they should automatically "bootstrap" with the latest appcode

My thoughts so far:
ad a)
phing (http://phing.info) is probably the answer for this part. i would probably add multiple targets for each EC2 instance and when running a deploy it would deploy to all machines. probably unfortunately not in parallel. but that might be even beneficial when scripting it in a way where the EC2 instance is "paused" in the load balancer, upgraded, "unpaused" again and on to the next instance.

ad b)
not sure how i would achieve that. in a conventional "hardware based setup" i probably had a "app code" volume on a network storage device and when adding a new server i'd simply attach that volume. when deploying new appcode i had just one deploy operation to this volume. so i need some "central storage" from where the newly bootstrapped machine/instance downloads it's appcode. i thought about git, but after all git is not a deploy tool and probably shouldn't be forced to be used as one.

I'd be happy to see your setups for such tasks and hear your hints and ideas for such a situation.

Thanks,

Joshua

4

4 回答 4

3

这可以使用 phing 来完成。但是,我不确定您为什么希望新实例自动检索应用程序代码?你经常得到额外的实例吗?为了a)将代码部署到多个实例,它仍然需要知道它们吗?

此设置需要主部署服务器并使用推送策略。主服务器需要 phing、任何所需的 phing 包以及 EC2 实例的可选 ssh 密钥。

a) 的建议

(这只是所需的 phing 任务的概述)

  • 检索实例列表(配置文件或提供的参数)
  • 将应用程序代码从存储库导出到主服务器(例如 SubVersion)
  • tar 应用程序代码
  • scptarball 到所有 EC2 实例(到部署文件夹)
  • rshEC2 实例上解压 tarball
  • 通过rshEC2 实例上的更新符号链接,网络服务器文件夹指向新的部署文件夹
  • 清除网络服务器上的所有缓存

在您发布新版本后,可以调用上述内容。

b) 的建议 可以通过每隔几个小时运行一次 phing 脚本来实现,让它登录到 EC2 实例并检查应用程序代码。如果找不到,它将部署最新的最终版本。当然,这需要正确设置 EC2 实例的网络服务器、配置文件等(但是,这也可以通过远程 shell 通过 phing 来实现)。

我以前使用过类似的设置,但没有尝试过使用 EC2 之类的服务。

于 2011-02-16T12:58:03.400 回答
0

我相信 phing 是一个很好的工具。Capistrano 也可能有所帮助。

我在一个非常相似的环境中部署我的应用程序。到目前为止,我一直在使用简单的 bash 脚本,但我可能会转向基于 phing 的解决方案,主要是因为开发 shell 脚本所涉及的困难(你必须知道一种不太灵活的新语法,而不是提到跨平台)和并行处理的可用性,这是存在于 phing 中的。

于 2012-06-23T22:13:44.850 回答
0

a) 看看Capistrano,因为你没有使用 Ruby(和 RoR),所以使用railsless-deploy插件。Capistrano 可以部署到多个服务器。

b) 在这方面没有任何经验,但如果没有 Capistrano 的插件/gem 几乎可以为您做到这一点,我不会感到惊讶。

于 2011-02-15T15:07:47.357 回答
0

Phing 是管理部署任务的绝佳工具,几乎涵盖了 (a) 的大部分内容。

我们使用OpsCode Chef进行基础架构管理。它有一个 deploy_revision 目标,同时支持 SVN 和 Git 存储库,用于应用程序代码部署,knife(主要的 Chef 命令行工具)有一个 EC2 插件,允许您使用一个命令启动一个新的 EC2具有您在 Chef 中定义的任何角色和环境的实例,并部署您的应用程序代码。

为了在 ELB 后面使用多个 EC2 实例来管理此问题,我们使用 Python boto库编写了非常简单的脚本来连接到 ELB,获取附加到该 ELB 的所有实例的列表,并从ELB,在该实例上运行 Chef 更新(部署新的应用程序代码和任何机器配置更改),将实例重新附加到 ELB 并移动到下一个实例。

于 2012-10-12T06:29:27.593 回答