I have an EC2 instance with "instance store" device as a root device (I did not know the difference between it and EBS before launching it). I would like to stop it but I can not do it with the command ec2-stop-instances, the output is:
Client.UnsupportedOperation: The instance 'i-XXXXXXXX' does not have an 'ebs' root device type and cannot be stopped.
Does anybody know how to stop it with Windows Console (I am not the owner of the Amazon account and I won't be able to contact with him for weeks)
Thanks in advance.
EC2 instance with "instance store" cannot be stopped. They can only be terminated.
If you would like the ability to stop an instance, I suggest recreating the instance with an EBS root device. These types of instances support the ec2-stop-instances command. You can consider this command as a "pause", since it can be resumed at any time, and you will not be charged for the time the instance is stopped.
Amazon announced the ability to boot instances from an EBS root volume only in December 2009, so you will find that older documentation and tutorials ignore the extended command-set that came with the EBS root volumes.
Further reading: Amazon EC2 Instances Now Can Boot from Amazon EBS
I am not the owner of the Amazon
account and I won't be able to contact
with him for weeks.
If you really want to "pause" this instance for a few weeks, you can create a machine image (AMI) of your instance and terminate it.
You will then be able to launch a new instance with your private AMI when you want to "resume" this instance. It will not be the same instance, as in it will have a different instance ID and a different IP, but you will be cloning the setup of your instance.
The methods to build an AMI differ if your instance is running Windows or Linux, but you should be able to find adequate information on the web about both scenarios.
Related
I have a p3.2xlarge instance with Deep Learning AMI (Ubuntu). I have installed various packages on it. I also attached EFS to this machine. Now, I wanted to implement autoscaling so I created image from this instance. Now the instances launched from the AMI and the original instance seem to stuck at same point. When I go to the original instance's screenshot, this is the last line:
[22.675975] systemd-journald [464] : Received request to flush runtime journal from PID 1
I have an Amazon EC2 instance which is registered to a cluster of Amazon ECS.
And I want to change this instance's type from c4.large to c4.8xlarge.
I'm able to change its type from c4.large to c4.8xlarge in AWS console. But after the change, I found
[ERROR] Could not register module="api client" err="ClientException: Container instance type changes are not supported. Container instance XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX was previously registered as c4.large.
being printed in /var/log/ecs/ecs-agent.log.20XX-XX-XX-XX file.
Is it possible to change ec2 instance type and re-register it to a cluster?
I think maybe deregister it first, then register it again should work. But I'm afraid this may cause something irreversible in my AWS working environment. So I haven't tried this method yet.
To solve this connection problem between the agent and cluster, just delete the file /var/lib/ecs/data/ecs_agent_data.json and restart docker and ECS.
After that, a new container instance will be created in your cluster with the new size.
sudo rm /var/lib/ecs/data/ecs_agent_data.json
sudo service docker restart
sudo start ecs
Then you can go to the ECS cluster console and deregister the old container instance
UPDATE:
According to #florins and #MBear commented below, AWS updated the data file on ECS instances.
sudo rm /var/lib/ecs/data/agent.db
sudo service docker restart
sudo start ecs
As of March 2021 / AMI image ami-0db98e57137013b2d, /var/lib/ecs/data/ecs_agent_data.json mentioned in the last useful answer does not exist. For me, the commands to execute on the changed instance were:
sudo rm /var/lib/ecs/data/agent.db
sudo service docker restart
After that, it was possible to deploy containers to the instance, without fresh registration (AWS automatically registered a second ECS container instance of the new type). I did have a leftover container instance with the resources of the old instance type to remove.
You can't do this. Per their docs:
The type of EC2 instance that you choose for your container instances determines the resources available in your cluster. Amazon EC2 provides different instance types, each with different CPU, memory, storage, and networking capacity that you can use to run your tasks. For more information, see Amazon EC2 Instances.
This means that when you launch a container on an instance, the agent gathers a bunch of metadata about the instance to run it. If you change it, all of that metadata (or a lot) has changed in a bad way. CPU units, memory, etc. The agent is aware of this and will report it as an error.
You should spin up a new instance of the new type and register it to the cluster and let the task run on it. If it's a service, just terminate the old instance and let it run it against the new one.
I can't think of any real reason why terminating your old instance would cause something irreversible unless it is misconfigured or fragile via user specific settings, by default this would not cause anything destructive.
As alternative approach if the EC2 instance does not store any valuable a new instance using the old instance as template could be started. This takes all existing values and can be achieved just with a few clicks in minutes.
Select the EC2 instance and then "Actions -> Images and templates -> Start more like this". Just change the instance type.
When the instance is running got the the ECS cluster to the tab "ECS instances" and activate the new created instance.
Shutdown the old instance
Update your task maybe taking more cpu and memory and update the service to take the new task revision
I have an EC2 small instance, which has two EBS volumes attached and has EBS as root device. Now the EC2 instance is not reachable for some reason (AWS engineers are looking into it). In the mean while, we are thinking about launch another EC2 instance and attach it to the two EBS volumes. What's the best practice for that purpose? Do I need to take snapshot of the volumes before re-attach to the new EC2 instance? Can we attach to them without destroying the existing data on the volumes?
You do not need to take a snapshot in order to attach the volume to a new instance. You can simply detach the volumes and re-attach them to a new instance.
Your data will not be destroyed in this process.
Hope it helps.
I understand that when I launch an instance on ec2, that the instance has to be located on a particular data center, and that after launching you can't change that. I also understand that an AMI is created from an instance.
But what I dont understand, is when I launch an instance from an AMI, why can't I specify what region I want it to run on? Seems like it shouldnt matter, once the AMI is created you should be able to launch it in any region. What does the AMI contain that ties it to a region and why?
Kernels. The kernel IDs change across regions (don't ask me why).
Meaning an AMI which specifies a kernel ID to be booted with can only be booted in the region this kernel ID exists.
AMI is region specific because AMI basically contains a software configuration (for example, an operating system, an application server, and applications). From an AMI, you launch an instance, which is a copy of the AMI running as a virtual server in the cloud. And if we consider AMI a global service, it means all AMIs are stored in one place and have access to all regions. For this, it will take more time to pull and then create instances. So if it is available in a region(region-specific), then we can quickly launch instances fast without time delay.
Or is it absolutely necessary to have an EBS backed storage? Does anyone have manuals/Howtos?
I am following the manual given on this site.
You can create an AMI from either an EBS or S3-backed running instance. The simplest way is to use the AWS Management Console to select the instance and click 'Create Image' from the Instance Actions menu.
This will create either an EBS or S3-backed AMI, depending on the type of instance.
Be aware that creating an AMI from a Running instance is inherently potentially unsafe - the storage is not imaged as a hard 'point-in-time' snapshot, so changes to the filesystem whilst the image is being created may not be recorded, and may even result in a compromised image. You should quiesce the OS as far as possible before starting.
Note also that your instance will reboot during the image-creation process, so make sure you're prepared for any temporary loss of service from the VM.
If you bundle a Windows EBS instance while it is running, its Administrator password will be reset by Amazon's rebundling tools - so you'll have to use the EC2 "get Admin password" function with instances launched from the new AMI.
If you stop your Windows instance before rebundling, its Administrator password will remain intact through the rebundling process.
I don't know if this is documented anywhere, but it's certainly been my experience with Windows 2003 instances.
you will to refer the manual for the three commands:
ec2-bundle-vol, ec2-upload-bundle, ec2-register.
Keep at hand your private and certificate key (eg. pk.pem, cert.pem files) and your access and shared key. Download the ec2 ami tools and setup the environment variables for the ec2 ami tools. This site might give you the details on how to bundle the volume, create the images, upload them to S3 and finally register it as your own ami.
http://alestic.com/2009/06/ec2-ami-bundle
It is possible to create an AMI from an EBS running instance using the AWS management console. as mentioned by Eight-Bit Guru by clicking 'Create Image' from the Instance Actions menu.
For the S3 backed instance it is currently not possible without bundling the instance.
If you are using a linux ami then you have two ways as explained in this guide:
Creating an AMI from S3 backed instance - For Linux
For windows based S3 backed instance you can follow other guide
Creating an AMI from S3 backed instance - For Windows
Hope this will help for creating an AMI for S3 backed intances.