简体   繁体   English

AWS EC2实例中的Tomcat

[英]Tomcat in AWS EC2 instance

I have a requirement of setting up Apache Tomcat on Amazon EC2 instance. 我需要在Amazon EC2实例上设置Apache Tomcat。

I have heard that EC2 is ephemeral and anything we put in may not survive restarts. 我听说EC2是短暂的,我们放入的任何内容都可能无法重启。 So if I add a Tomcat in EC2 and restart the instance will it be deleted or removed. 因此,如果我在EC2中添加了Tomcat并重新启动实例,它将被删除或删除。

What are the ways to overcome this issue ? 有什么方法可以克服这个问题?

Sorry I am a newbie in AWS. 抱歉,我是AWS的新手。

If what you need is just Tomcat then you can use pre-configured Amazon Beanstalk Tomcat container which does exactly that. 如果仅需要Tomcat,则可以使用预先配置好的Amazon Beanstalk Tomcat容器。

However if you need to build custom EC2 you can install tomcat on EBS linked to EC2, or even better use Amazon EFS to share between multiple EC2. 但是,如果您需要构建自定义EC2,则可以在链接到EC2的EBS上安装tomcat,甚至更好地使用Amazon EFS在多个EC2之间共享。

Ephemeral disk is temporary storage that it is added to your instance and sized according to instance type. 临时磁盘是临时存储,已添加到您的实例并根据实例类型调整大小。 The larger the instance, the more temporary storage. 实例越大,临时存储越多。

For some instances like c1.medium and m1.small they use instance storage automatically as SWAP as they have a limited amount of memory, while many others are automatically formatted and mounted at /mnt . 对于某些实例,例如c1.mediumm1.small ,由于它们的内存量有限,它们会自动将实例存储用作SWAP,而其他许多实例会自动格式化并安装在/mnt

You can take snapshots of your EC2 instances while they are running. 您可以在EC2实例运行时对其进行快照。 Snapshots allow you to create AMI's from your current machine state, which will contain everything in your ephemeral storage. 通过快照,您可以从当前计算机状态创建AMI,其中将包含临时存储中的所有内容。 When you launch a new instance based on that AMI, it will contain everything as it was in the snapshot. 当您基于该AMI启动新实例时,它将包含快照中的所有内容。

An Amazon Machine Image (AMI) provides the information required to launch an instance. Amazon Machine Image (AMI)提供启动实例所需的信息。


Take note that there is a big difference between stop and terminate . 请注意, stopterminate之间有很大的区别。 If you stop an instance that is backed by EBS, the information on the root volume will still be in the same state when you start the machine again. 如果stop由EBS支持的实例,则在再次start计算机时,根卷上的信息仍将处于相同状态。 If you terminate the machine without taking a snapshot, even if it is backed by EBS, the storage inside the ephemeral disk will be lost forever. 如果您在没有快照的情况下terminate了计算机,即使它由EBS支持,临时磁盘中的存储也将永远丢失。

All AMIs are categorized as either backed by Amazon EBS or backed by instance store. 所有AMI均分类为由Amazon EBS支持或由实例存储支持。 The former means that the root device for an instance launched from the AMI is an Amazon EBS volume created from an Amazon EBS snapshot. 前者意味着从AMI启动的实例的根设备是从Amazon EBS快照创建的Amazon EBS卷。 The latter means that the root device for an instance launched from the AMI is an instance store volume created from a template stored in Amazon S3. 后者意味着从AMI启动的实例的根设备是根据存储在Amazon S3中的模板创建的实例存储卷。 For more information, see Amazon EC2 Root Device Volume . 有关更多信息,请参阅Amazon EC2根设备卷


The above answers should provide a good idea about what you can and cannot do with ephemeral disks, but I advise all (myself included) to learn more about ephemeral disks and their primary use cases. 上面的答案应该提供一个关于临时磁盘可以做什么和不能做什么的好主意,但是我建议所有人(包括我自己)进一步了解临时磁盘及其主要用例。

Here are some good use cases for ephemeral storage that I know of: 我知道以下是临时存储的一些好用例:

  1. Temporary backup 临时备份
  2. Re-format the original instance storage and use part of it for SWAP 重新格式化原始实例存储并将其一部分用于SWAP
  3. RAID 10 with 6 disks (4 EBS and 2 Ephemeral disks) to improve overall performance and provide HA 具有6个磁盘(4个EBS和2个临时磁盘)的RAID 10可提高整体性能并提供HA
  4. Application cache, logs, any other random data 应用程序缓存,日志,任何其他随机数据

You are save as long as you not store it on ephemeral partition which is a part of your instance check this to have more info 只要不将其存储在实例分区的临时分区中,您就可以保存,请检查此内容以获取更多信息

http://www.heitorlessa.com/working-with-amazon-aws-ec2-ephemeral-disks/ http://www.heitorlessa.com/working-with-amazon-aws-ec2-ephemeral-disks/

basically you need to mount elastic drive to your instance and install Tomcat and all your software there, ephemeral storage is for swap or caching 基本上,您需要将弹性驱动器安装到实例并在其中安装Tomcat及其所有软件,临时存储用于交换或缓存

You only need storage to keep your information, EBS or S3. 您只需要存储即可保存您的信息,即EBS或S3。 EC2 instances are virtual machines and will not lose your information if restarts with storage. EC2实例是虚拟机,如果使用存储重新启动,则不会丢失您的信息。 Get all information you need at https://aws.amazon.com/es/ec2/ https://aws.amazon.com/es/ec2/上获取所需的所有信息。

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

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