Amazon EC2 上的 Java EE 应用程序部署

发布于 2024-10-14 23:00:55 字数 776 浏览 1 评论 0原文

我们有一个 Java EE 应用程序(EAR 文件部署在 JBoss、MySQL、MongoDB),我们希望将其部署在 Amazon EC2 实例上。我有几个关于部署最佳实践的问题。

  1. 最常用的 Linux AMI 是什么,我们可以依靠它来进行稳健的部署(有Linux 变体很多,我不确定常用的是哪种 AMI,是 Fedora、CentOS、Red Hat、SUSE ...)
  2. 我们如何处理生产升级(EAR 文件修改或架构升级)。是否有任何工具可用于处理此安装或回滚这些更改。
  3. 数据库有哪些数据备份能力?
  4. 我是否应该依赖 Amazon RDS 来获得 MySQL 支持?
  5. 我应该如何处理对 MongoDB 的支持?

这是我第一次托管网络应用程序,并且希望获得一些有关如何管理生产实例的意见。

We have a Java EE application (EAR file deployed on JBoss, MySQL, MongoDB) which we would like to deploy on an Amazon EC2 instance. I have several questions regarding deployment best practices.

  1. What is the most commonly used Linux AMI which we can rely on for a robust deployment (There are so many Linux variants, and I am not sure which AMI is commonly used, is it Fedora, CentOS, Red Hat, SUSE ...)
  2. How do we handle production upgrades (EAR file modifications or schema upgrades). Are there any tools which are available to handle this installation or rollback of these changes.
  3. What kind of data backup capability is available for the database?
  4. Should I rely on Amazon RDS for MySQL support?
  5. How should I handle support for MongoDB?

This is the first time, I am hosting an web-app and would appreciate some inputs on how to manage the production instance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

摘星┃星的人 2024-10-21 23:00:55
  1. 我同意 Mark Robinson 的回答:使用您最熟悉的 Unix 变体。选择一个具有良好云支持的产品可能是值得的。我的网站使用 Ubuntu。
  2. 我有一个通用映像,它是我所做的每个版本部署的基础。我有 www.mysite.com 指向一个弹性 IP,这样我就可以决定它转到哪个实例。通用映像包含我需要安装的所有软件(Postgres/Postgis/Tomcat/等),但数据库和 Web 服务器数据文件夹以及符号链接到弹性块存储 (EBS) 实例。

    当需要进行部署时,我会启动一个新实例,冻结生产环境中的 EBS 卷并为其创建快照,然后创建新卷。我将新实例指向新卷,然后将我需要的任何内容安装到该实例上。一旦我成功地对所有内容进行了冒烟测试,我就可以将弹性 IP 切换到指向新实例,一切都会继续进行。

    我会注意到,我目前的优势是只有我可以修改数据库;没有用户可以。这很快就会成为一个问题。

  3. 如果您在 EBS 卷之上使用 XFS 文件系统,那么您可以告诉 XFS 冻结文件系统(因此不会发生更新),然后调用 EC2 api 对卷进行快照,然后解冻文件系统。结果是快速拍摄快照并将其发送到 S3。我有一个夜间脚本可以执行此操作。

  4. 如果 RDS 看起来适合您的需求,那么就使用它。 Amazon 正在快速构建大量可靠的工具,这将缓解您的可扩展性问题(如果您有任何问题)。

  5. 对不起,我不知道。

  1. I agree with Mark Robinson's answer: Use whichever Unix variant you're most comfortable with. It may pay to pick one with decent cloud support. For my site I use Ubuntu.
  2. I have a common image which is the base of every version deploy I do. I have www.mysite.com pointing to an Elastic IP so I can decide which instance it goes to. The common image has all the software I need installed (Postgres/Postgis/Tomcat/etc) but the database and web server data folders and symlinked to Elastic Block Store (EBS) instances.

    When it comes time to do a deploy I start a new instance up, freeze and snapshot the EBS volumes on production and make new volumes. I point my new instance at the new volumes and then install whatever I need to onto that. Once I've smoke tested everything successfully I can switch the Elastic IP to point to the new instance and everything keeps on going.

    I'll note that I currently have the advantage where only I can modify the database; no users can. This will become a problem shortly.

  3. If you use the XFS filesystem on top of the EBS volume then you can tell XFS to freeze the file system (so no updates happen) then call the EC2 api to snapshot the volume then unfreeze the file system. The result is that the snapshot is taken quickly and sent to S3. I have a nightly script which does this.

  4. If RDS looks like it will suit your needs then use it. Amazon is building lots of solid tools quickly and this will ease your scalability issues if you have any.

  5. I'm sorry, I have no idea.

风吹雨成花 2024-10-21 23:00:55

好问题!

1) 我建议您使用您最喜欢的任何 Linux 版本。如果你有人真正热衷于 CentOS,那就跟着他吧。选择 AMI 后,即可使用它并通过配置您想要的方式对其进行自定义。然后将该 AMI 保存为您的基本布局。它将使推出新机器变得更加容易,并且在 EC2 出现故障时可以挽救您的生命。

2) 使用 EC2 进行升级非常酷。不要升级实时系统,而是使用预配置的 AMI,更新它并将该 AMI 保存为 myAMI-1.1(或其他)。这样,您几乎可以立即切换到新系统,并回滚到以前的版本,以防出现问题。您还可以将数据库实例备份到 S3。价格便宜,约为每月 0.10 美元/GB。

3)这取决于您存储数据库的位置。如果您将其存储在 EC2 实例上,您就会遇到麻烦。 EC2 实例没有持久性存储。所以如果你的机器崩溃了,你就会失去一切。我不熟悉 Amazon DB 系统,但您也应该研究一下 Elastic Block Store。它基本上是一个可以写入的实际硬盘。当您想要升级架构时,请将完整数据库转储到 S3,然后升级实际架构。如果出现问题,您可以从 S3 中提取以前的版本。

4)& 5)我从未使用过这些,所以我无法帮助你。

Good question!

1) I would recommend going with whatever Linux variant you are most comfortable with. If you have someone who is really keen on CentOS, go with that. Once you have selected your AMI, take it and customize it by configuring how you want it. Then save that AMI as you base-layout. It will make rolling out new machines much easier and save your bacon if EC2 goes down.

2) Upgrades with EC2 can be tres cool. Instead of upgrading a live system, take your pre-configured AMI, update that and save that AMI as myAMI-1.1 (or whatever). That way, you can flip over to the new system almost instantly AND roll back to a previous version in case something breaks. You can also back-up DB instances to S3. It's cheap at about $0.10/GB/Month.

3) It depends where you are storing your DB. If you are storing it on your EC2 instance you are in trouble. The EC2 instances have no persistence storage. So if your machine crashes, you lose everything. I'm not familiar with Amazon DB system but you should also look into Elastic Block Store. It's basically an actual hard-drive you can write to. When you want to upgrade your schema, do a full DB dump to S3 and then do an upgrade of your actual schema. If something goes wrong, you can pull the previous version out of S3.

4) & 5) I have never used those so I can't help you.

差↓一点笑了 2024-10-21 23:00:55
最常用的 Linux AMI 是什么,我们可以依靠它来实现稳健的部署(Linux 变体如此之多,我不确定常用的是哪个 AMI,是 Fedora、CentOS、Red Hat) 、苏塞...)
我们如何处理生产升级(EAR 文件修改或架构升级)。是否有任何工具可用于处理此安装或回滚这些更改。
数据库有哪些数据备份能力?
我应该依赖 Amazon RDS 来获得 MySQL 支持吗?
我应该如何处理对 MongoDB 的支持?
  1. 任何 Linux AMI 都可以完成这项工作,您只需要一个 JRE。 (假设不需要开发工作)。如果您需要监视 JVM 行为,请安装 JConsole。
  2. 最简单、轻松的方法是通过 SSH 进入本地主目录,传输更新的类文件/EAR 文件(取决于应用的更改数量)并复制并替换到 Tomcat 部署目录中,重新启动 apache。 (确保在上传到生产环境之前在本地进行了测试)。
  3. 取决于您使用的数据库,如果您使用 MySQL,那么只需执行写入您的主目录的计划备份,以便您时不时可以通过 SSH 连接并下载副本以进行备份。
  4. 我不会考虑回复 Amazon RDS for MySQL 支持,原因有两个:MySQL 足够小且易于管理,而且我希望完全控制数据库,当您可以自己做 FOC 时为什么要支付更多费用?
  5. MongoDB 的使用应该与您的应用程序的目的以及您从中获得的好处保持一致。我建议您使用 MongoDB 进行静态数据检索,例如州、国家、地区等……其中 MySQL 仅用于事务数据。
What is the most commonly used Linux AMI which we can rely on for a robust deployment (There are so many Linux variants, and I am not sure which AMI is commonly used, is it Fedora, CentOS, Red Hat, SUSE ...)
How do we handle production upgrades (EAR file modifications or schema upgrades). Are there any tools which are available to handle this installation or rollback of these changes.
What kind of data backup capability is available for the database?
Should I rely on Amazon RDS for MySQL support?
How should I handle support for MongoDB?
  1. Any Linux AMI will do the job, what you need is a JRE only. (assuming development work not required). If you need to monitor the JVM behavior then get JConsole installed.
  2. Easiest and painless way is to SSH into the local home directory, transfer the updated class file/EAR file (depends the number of changes applied) and copy and replace into the Tomcat deployment directory, restart apache. (make sure you tested locally before upload to production).
  3. Depends on which database you are using, if you are using MySQL then just do scheduled backup that writes to your home directory so that from time to time you could SSH in and download a copy for backup purpose.
  4. I would not consider reply on Amazon RDS for MySQL support due to 2 reasons: MySQL is small enough and manageable, and also I would want to have total complete control of the database and why pay for more when you can do it yourself FOC?
  5. The usage of MongoDB should be align with the purpose of your application and benefits you gain from that. I would recommend you use MongoDB for static data retrieval like state, country, area etc... where MySQL to be use for transaction data only.
总以为 2024-10-21 23:00:55

如果您可以接受在 TomEE 而不是 JBoss 上部署 Java EE 应用程序,那么 Boxfuse 可以满足您的需求。

对于您的 Java EE 应用程序,您实际上只需要执行(TomEE 使用 war 文件而不是 Ear 文件):

boxfuse run my-tomee-app-1.0.war -env=prod

这将

  1. 创建包含 TomEE 的 AMI,并且您的应用程序准备好启动
  2. 创建弹性 IP 或 ELB
  3. 创建一个定义了正确端口的安全组
  4. 创建自动扩展组
  5. 启动您的实例

任何后续更新都将作为零停机蓝/绿部署完成。

更多信息:https://boxfuse.com/blog/javaee-aws

If you can live with deploying your Java EE application on TomEE instead of JBoss, Boxfuse does what you want.

For you Java EE application you literally only have to execute (TomEE uses war files instead of ear files):

boxfuse run my-tomee-app-1.0.war -env=prod

This will

  1. Create AMI containing TomEE and your application ready to boot
  2. Create an Elastic IP or ELB
  3. Create a security group with the correct ports defined
  4. Create an auto-scaling group
  5. Launch your instance(s)

Any subsequent update will be done as a zero downtime blue/green deployment.

More info: https://boxfuse.com/blog/javaee-aws

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文