I have a requirement of setting up Apache Tomcat on Amazon EC2 instance.
I have heard that EC2 is ephemeral and anything we put in may not survive restarts. So if I add a Tomcat in EC2 and restart the instance will it be deleted or removed.
What are the ways to overcome this issue ?
Sorry I am a newbie in AWS.
If what you need is just Tomcat then you can use pre-configured Amazon Beanstalk Tomcat container which does exactly that.
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.
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.
You can take snapshots of your EC2 instances while they are running. Snapshots allow you to create AMI's from your current machine state, which will contain everything in your ephemeral storage. When you launch a new instance based on that AMI, it will contain everything as it was in the snapshot.
An Amazon Machine Image (AMI) provides the information required to launch an instance.
Take note that there is a big difference between stop and terminate. 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. 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.
All AMIs are categorized as either backed by Amazon EBS or backed by instance store. 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. 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. For more information, see Amazon EC2 Root Device Volume.
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:
Temporary backup
Re-format the original instance storage and use part of it for SWAP
RAID 10 with 6 disks (4 EBS and 2 Ephemeral disks) to improve overall performance and provide HA
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/
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
You only need storage to keep your information, EBS or S3. EC2 instances are virtual machines and will not lose your information if restarts with storage.
Get all information you need at https://aws.amazon.com/es/ec2/
Related
0
Hey I have a question regarding AWS EC2 instance store.
I understand that EC2 instance store volume cannot be unmounted from an instance once we create it, according to this document
"You can't detach an instance store volume from one instance and attach it to a different instance."
Link : https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html
Does that mean, the ec2 instance volume is fixed to only 1 instance when we create it? is there no way to unmount that instance store volume?
If it is not fixed can we attach the instance store to an instance in a different AZ?
Not sure im understanding this correctly, hoping to get some answers on this.!
I tried looking at all the public docs available in AWS and open source data along with YT videos, but do not seem to find a clear explanation on this>!
In the AWS datacenter, there are racks of EC2 servers. Each of these servers is called a host.
The host contains CPU, RAM, disk drives, networking, and perhaps GPUs. The host is divided into instances, each with a subset of that CPU, RAM, disk, etc.
Here's some information from Amazon EC2 Instance Types - Amazon Web Services:
It is showing that the Host contains 128 vCPUs, 1024GiB RAM, 8 x 3750 GB storage. This is shown in the metal instance size, which means the 'whole host'.
AWS then divides this Host into multiple instances. For example, if the Host is configured to provide i4i.4xlarge instances, it can provision 8 of these instances, each with 16 vCPUs, 128GiB RAM, 3750GB storage.
The SSD disks used for storage are inside the host computer itself, as opposed to Amazon EBS Volumes that are network-attached storage (like a SAN). This is why it is not possible to detach/attach an Instance Store volume -- it's because it is only connected to the one host computer and is not network-accessible. When you stop one of these instances, the contents of the disk is (effectively) erased because it needs to be used by the next instance that is launched on that host computer. So, Instance Store only persists as long as an instance is Running. (It survives Reboots, but not a Stop/Start.)
Amazon EBS Volumes can be detached/attached to other instances because they are network-attached. However, they can only connect to instances in the same Availability Zone (Data Center) because they would be too slow operating between AZs/Data Centers.
To compare these storage options with your own computer at home:
Instance Store is like the disk inside your computer
EBS Volumes are like the H: drive on your computer, which connects to a network file server
(You could think of EBS volumes being like USB drives that you connect to your computer, but they are much more flexible. For example, they can change size and speed because they are not tied to a specific piece of hardware.)
I have upgraded my instance from EC2 T2.Medium to T2.Large. However, I do not see any change in the available disk space. How do I get more space? I am using Ubuntu 16.04. Do I need to execute any Linux shell commands?
Amazon Elastic Block Store (EBS) is network-attached disk storage that is (normally) used as Boot Disks and Storage Disks. The size of the disk volume is independent from the Instance Type. In fact, disks can be detached from one instance and attached to another one, so they are also independent of the EC2 instance itself.
There is another storage type called Amazon EC2 Instance Store that is directly attached to the host computer and does vary by Instance Type. However, the T2 family of EC2 instances does not have Instance Store.
Bottom line: If you want to resize a disk, do it directly to the EBS disk itself.
See: Modifying the Size, IOPS, or Type of an EBS Volume on Linux - Amazon Elastic Compute Cloud
I am deploying Wordpress site using LAMP AMI on EBS-backed EC2. Wordpress database will be stored in EBS.
Amazon keeps on updating base configuration of EC2 for better performance & security.
If I have to upgrade my EC2 then my EBS will get deleted.
How can I ensure that my EC2 gets updated without affecting my EBS?
EBS Snapshot is not of any help as new EC2 already has a EBS attached.
Do I have to always migrate my Wordpress site using backup & do this upgradtion?
Amazon EC2 instances use EBS volumes as their disk volumes. They are populated from an Amazon Machine Image (AMI) when the instance is launched.
When AWS releases updated AMIs, any new instance launched from the AMI will contain the updated disk content. However, existing EC2 instances will not be changed (since they have a copy of the AMI at the time that the instance was launched).
You can also change the Instance Type of an EC2 instance, which gives it different hardware (CPU, Memory). This can be done by stopping the instance, changing the type and starting it again. This will not affect the contents of EBS volumes.
If you wish to keep your instance "current", simply run sudo yum update (Linux) or run the Windows Update utility to update your operating system and associated utilities rather than launching a whole new instance.
I am looking to migrate an application from one vpc to another. Currently, the application's ec2 instances utilize a nfs which I created from another ec2 instance and ebs volumes. These application related instances (web and app) as well as the nfs instance reside in one VPC (Let's call it VPC "A").
My question is how would I go about transferring the ebs data from the existing nfs in VPC "A" into an efs in VPC "B"? Additionally, the rate of data transfer is not relevant, so the file system's performance mode is just defined as general purpose. Thanks!
Not sure if this answer was technically possible at the time the above answer was given, but a much easier way to achieve a solution providing that the asker did not to run both applications concurrently (ie. duplicate the data instead of just switch the VPC it was available from).
My company was switching to a new VPC, so I merely wanted to make the data available in the new VPC. Rather than copy it to EBS, unmount, remount, copy to EFS, I switched the mount points as described here:
http://docs.aws.amazon.com/efs/latest/ug/manage-fs-access-change-vpc.html
IMO this is much simpler if you don't need to actually duplicate the data.
For backing up the data, AWS has a workflow outlined:
http://docs.aws.amazon.com/efs/latest/ug/efs-backup.html
It sounds like your requirement is to transfer the contents of an Amazon EBS volume in one VPC to a different VPC. It is unclear whether your NFS server is hosted from EC2+EBS, or whether it is running from Amazon EFS. I'll assume it is EC2+EBS.
A few different options for you (pick one!):
Create an AMI: Create an AMI of the Amazon EC2 instance running the server. Then launch a new instance in VPC B using that AMI.
Move the disk: Turn off the EC2 instance. Detach the EBS volume, the attach it to a different instance running in VPC B. Configure as necessary.
Use an EBS Snapshot: Snapshot the EBS volume that holds the data, create a new EBS volume from the snapshot (in the desired AZ), attach the EBS volume to the EC2 instance in VPC B.
However, if your server is running on Amazon Elastic File System (EFS), then you would need to copy the data to an EBS volume, detach the volume and attach it to an instance in the VPC B, then copy the data from the EBS volume to a new EFS share in VPC B.
I was thinking about switching from AWS Elastic Block Storage to AWS Elastic Filesystem (mainly for the easy scalability, also shareable storage seems nice).
At the moment I have one debian EC2 instance with one EBS volume. What's the easiest way to transfer my data from EBS to EFS?
The fastest way to achieve this is mount that EFS file system to your EC2 instance with EBS and then transfer the data from your EBS to EFS.
Follow this guide for mounting the EFS to your EC2 instance. https://docs.aws.amazon.com/efs/latest/ug/mounting-fs.html
EFS is good for sharing data between multiple EC2 instances, but you would still want to use EBS for the root drive (boot volume) of your instance.
You cannot boot from an EFS volume.
You mention that you have "one debian EC2 instance with one EBS volume". However, it is generally best to keep data separate from the boot volume (eg in a database, an S3 bucket or in EFS). This allows the instance to be recreated from an AMI in case of problems, without losing data.
If you wish to move/copy data to an EFS volume, just use normal filesystem commands (eg cp -r).
I think you can also use AWS DataSync to copy data from existing folder to EFS mounted folder.
(1) You need to set up an NFS service using the instance that you have your EBS attached to.
cf. https://linuxhint.com/install-and-configure-nfs-server-ubuntu-22-04/ for example and step-by-steps.
You can test that your NFS server works by using another instance, and mounting it there using /etc/fstab .. (I think the link above shows you how to do that).
You will need the IP address of your NFS server (for me, this is 10.0.33.5)
(2) You will need to deploy a DataSync Agent - this is a new instance. It need lots of ram (so, expensive) - eg m1.xlarge - especially if your EBS is big and has many thousands of files. look here for that https://docs.aws.amazon.com/datasync/latest/userguide/deploy-agents.html#ec2-deploy-agent
You now have an DataSync Agent Instance (which should be on the same subnet and AZ as your NFS instance) showing on your EC2. You will need it's private IP number.. (for me, this is 10.0.33.111)
(3) You need to create an AWS Endpoint. (in VPC) You are going to add one with AWS Services - search for and choose 'datasync', and add that to the subnets that your NFS Server and Agent are on. Once that is created, you will need the IP address of the subnet / AZ that you are using. (For me this is 10.0.33.222)
(4) You will need to get your Agent Activation Key. ssh into an instance (like your nfs server) on the same subnet and then to get your key, using the url below with your region (mine is eu-west-1 ) and the two IP numbers you have recorded.. Do not use MY ones!!
curl "http://10.0.33.111/?gatewayType=SYNC&activationRegion=eu-west-1&privateLinkEndpoint=10.0.33.222&endpointType=PRIVATE_LINK&no_redirect"
If all is well you will get a long Activation Key string like XXXX-XXXX-XXXX-XXXX
(5) Now you need to add all this into your DataSync Agents list (it's an Amazon EC2 Hypervisor, using a VPC endpoint using "AWS PrivateLink". The endpoint should show automatically) and paste in your ID Activation Key from step 4 above. You should now see an active Agent in your Agents list (in DataSync).
(6) Now you can create a Location that uses that agent. Select NFS, and your Agent, Now put the ip address of your nfs server (from step 1, eg 10.0.33.5) and the mount path (the same as what you used in your /etc/exports file on the instance where you have attached your EBS eg /mnt/mydrive
(7) NOW you can create a DataSync task from your NFS to your EFS..