简体   繁体   English

如何在AWS EC2实例上扩展Tomcat?

[英]How to scale out Tomcat on AWS EC2 instance?

There are a number of questions on auto scaling. 关于自动缩放有很多问题。 But none of it talks about scaling out the software stack installed on these servers. 但是没有一个谈论扩展这些服务器上安装的软件堆栈。 AWS Auto Scaling only scales out the resources. AWS Auto Scaling仅扩展资源。 Not the software on it. 不是它上面的软件。 In my case I am looking forward to scale out the Tomcat Server (and Apache HTTPD Server) installed on the first instance to be part of the new instance that AWS Scaling Service creates. 就我而言,我期待将第一个实例上安装的Tomcat服务器(和Apache HTTPD服务器)扩展为AWS Scaling Service创建的新实例的一部分。

I followed the regular process to establish scaling for my application on Amazon Web Services EC2 instances. 我按照常规流程在Amazon Web Services EC2实例上为我的应用程序建立扩展。

  1. Created a Snapshot from the existing instance with the exact configurations of the running instance - Success 使用正在运行的实例的精确配置从现有实例创建快照 - 成功
  2. Created an AMI from the above snapshot - Success 从上面的快照创建AMI - 成功
  3. Created an auto scaling group and launch configuration - Success 创建了自动缩放组并启动配置 - 成功
  4. Scaling Policy is to create a new instance upon CPU >= 65% for 2 times. 扩展策略是在CPU> = 65%时创建一个新实例2次。 - Success - 成功

The above procedure only creates a new instance but it does not copy the Software Stack present on the image. 上述过程仅创建一个新实例,但不会复制图像上的软件堆栈。

How do I accomplish auto scaling in such a way that when AWS auto scaling happens, Tomcat server part of the AMI is also copied and started up in the new scaled out instance. 如何以这样的方式完成自动缩放:当AWS自动缩放发生时,AMI的Tomcat服务器部分也会被复制并在新的扩展实例中启动。

Do I definitely have to use Puppet/Chef or any such tools to achieve this? 我必须使用Puppet / Chef或任何此类工具来实现这一目标吗? Or is there an option in AWS using Command Line? 或者AWS中是否有使用命令行的选项?

Please note that Elastic Load Balancer automatically adds the new instance on to it as per the launch configurations but it shows 'Out of Service' since there is no Apache server installed on the new scaled up instance. 请注意,Elastic Load Balancer会根据启动配置自动添加新实例,但由于新扩展实例上没有安装Apache服务器,因此显示“停止服务”。

You create AMIs directly from EC2 instances, not from snapshots. 您可以直接从EC2实例创建AMI,而不是从快照创建AMI。 Snapshots are for EBS volumes. 快照适用于EBS卷。 Check that you created your AMI correctly from a running EC2 instance on which you have Apache/Tomcat installed and running (and configured to autostart on reboot). 检查您是否正在运行已安装并运行Apache / Tomcat的运行EC2实例(并配置为在重新启动时自动启动)正确创建了AMI。

No, you do not have to use Puppet/Chef or any other CM tool. 不,您不必使用Puppet / Chef或任何其他CM工具。 You can do what you want in a couple of ways: 你可以通过以下几种方式做你想做的事:

  1. The simplest way is to create an AMI from your running EC2 instance and then configure your Auto Scaling Group to launch new instances from that AMI based on some metric. 最简单的方法是从正在运行的EC2实例创建AMI,然后将Auto Scaling组配置为根据某个指标从该AMI启动新实例。
  2. Use a base AMI without Apache/Tomcat or your software and then bootstrap new instances at launch time to download and configure everything needed. 使用不带Apache / Tomcat的基础AMI或您的软件,然后在启动时引导新实例以下载和配置所需的一切。

The disadvantage of #1 is that your AMIs will get out of date quickly. #1的缺点是您的AMI会很快过时。 The disadvantage of #2 is that your instances will taken longer to come into service. #2的缺点是您的实例需要更长时间才能投入使用。 I would recommend a combination of #1 and #2, specifically that you capture a new AMI every few months and that becomes your base AMI for launching and you update the instance at launch time via userdata init script. 我建议使用#1和#2的组合,特别是每隔几个月捕获一个新的AMI,这将成为您启动的基础AMI,并在启动时通过userdata init脚本更新实例。

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

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