I created a 'functional' simple standalone web-server on an ec2 instance backed by a 20GB EBS Volume. This volume is the root drive for the Linux server and hosts MySql, Apache and Tomcat.
Now, I shut this 1st instance down (didn't kill the EBS Volume) and want to use this Volume to get another web-server up (on a new EC2 instance). Even if I attach this volume as 2nd volume in the new EC2 instance, I don't get the webserver running, for obvious reasons.
Is there a way of making this volume as the primary disk volume so that I can start the webserver and other processes as is without having to set them up again?
Thanks.
You can create a snapshot of the instance and launch a new instance from the snapshot.
Related
I am trying to change a bastion host EC2 that is currently stood up with terraform and has the root volume set to EBS storage. I want to have the root volume be ephemeral so that every time the bastion host is reset/restarted the root storage is cleaned out. I still want to maintain the EBS volume. After reading the current AMI json mapping, the EBS volume is mapped to '/dev/sda1'. Can I simply map this volume to '/dev/sdh'? My thinking is that /dev/sda1 will then default to ephemeral and that sda1 is the root volume from the information I gather AWS documentation. I could be missing something but I don't see anything about setting the root volume to ephemeral and having a separate EBS volume.
Instance store as the root volume is only available for specific instance family only.
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/RootDeviceStorage.html
To select the root volume as instance store you can follow the below aws provided steps:
I am having a scenario where EC2 mount two EBS Volumes and one of them is root. My ELB is setup to size=1 instance actively running. I want to have second EBS volume snapshot to be attached to new EC2 spin-off using AMI. How to do it using CloudWatch Event and Lambda?
EC2 API for volume mount do not specify windows mounts. Any Idea how to support EC2 Windows mounts using Lambda Function or any other scripting technique?
EDITED -
Here is what is expected - I have secondary EBS volume mounted to EC2 Windows. I have taken AMI of this machine and associated with Auto Scaling Group and Launch Configuration. In case of DR, ASG spins off new EC2 instance using defined AMI. It is desired that this new spin off machine to use same secondary EBS volume from snapshot.
Just mount the volume as normal. It is supported for both Linux and Windows.
If you are worried about the Linux-like device name, see Device Naming on Windows Instances - Amazon Elastic Compute Cloud:
Recommended for EBS Volumes: xvd[f-z]
An Amazon Machine Image (AMI) can contain multiple volumes.
I suggest you:
Launch an Amazon EC2 instance with both desired volumes (Root + Volume X:)
Create a new AMI from that instance, specifying both volumes
Create a new Auto Scaling launch configuration using that new AMI
Edit the Auto Scaling group to use the new Launch Configuration
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 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/
My questions is pretty straightforward, I have an Amazon Elastic Beanstalk application and I want to attach an existing EBS instance everytime that my elastic autoscaling creates a new instance.
How can I do that?
THanks.
If you are talking about the "main" EBS from which your app instance was booting, then as far as I know, the elastic load balancer destroys that EBS when the instance is terminated. It isn't saved. It sounds like this is what you are describing.
If you are talking about a different EBS which is attached to the instance in addition to (and after) the one from which it is booting, then it should be easy enough to re-attach it to the new instance by using elastic beanstalk configuration files. I assume this kind of EBS could be saved. It's an interesting solution for ensuring that data persists between instances in some ways, but like you said, an EBS can't be mounted by multiple instances simultaneously.
I think most people use S3 or a separate instance(s) with an NFS (that's what I do) to keep data that shouldn't die with an unhealthy instance.
You need script that will on bootstrap of new ec2 instance will attach ebs. You need to add yo your bundle .ebextentions, create config file which will contains command for mounting of ebs to instance.
Following links will be useful:
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html
http://www.hudku.com/blog/configuration-setup-customizing-aws-elastic-beanstalk/