11.19
Here is another hot topic that seems extremely confusing from the start, but is actually very easy to implement. Amazon Web Services EC2 seems to be the most fully-featured cloud-based web services on the internet. Amazon was the first major party to rollout a massive network of VM’s in the ‘cloud’ and remains to be the highest-respected service out there for Linux computing.
Due to the way Amazon is setup using XEN vm software, if there was ever physical hard drive failure, an ‘instance’ would essentially vanish into thin air (all except ‘Volumes). Not good. There does lie great integration with S3 (Amazon’s Simple Storage) that enables you to backup your instance to S3 for easy retrieval in the even that the random occurence actually does happen.
Summarizing the process in as very few steps as possible, the below is how one would go about creating a ‘bundle’, transferring it to S3 for reliable backup, and registering it as an AMI in your AWS Console.
Create Bundle
*ETA: 20 minutes
- Replace X’s with X.509 Certificate Private Key & Certificate.
- Replace 123456789012 with AWS Account ID (found on Security Credentials page).
/home/ec2/bin/ec2-bundle-vol --destination /mnt --privatekey /root/pk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.pem --cert /root/cert-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.pem --user 123456789012 --exclude /home --prefix image-20091119 --arch i386
Upload to S3 Bucket
*ETA: 5 minutes
- Replace X’s with Access Key ID & Secret Access Key (found on Security Credentials page).
- Replace BUCKETNAME with name of bucket setup on S3.
/home/ec2/bin/ec2-upload-bundle -b BUCKETNAME/instance-snapshots/image-20091119 --manifest /mnt/image-20091119.manifest.xml --access-key XXXXXXXXXXXXXXXXXXXX --secret-key XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Remove Unneeded Bundle Files
- Bundle is now stored on S3, so no need to keep a copy locally.
rm -rf /mnt/im*
Register Bundle on S3 as AMI
*ETA: 1 minute
- AMI is defaulted to Private AMI. You may change this from the AWS Console.
- Replace X’s with X.509 Certificate Private Key & Certificate.
- Replace BUCKETNAME with name of bucket setup on S3.
/home/ec2/bin/ec2-register --private-key /root/pk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.pem --cert /root/cert-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.pem BUCKETNAME/instance-snapshots/image-20091119/image-20091119.manifest.xml
Other
Be sure to note, that if you have an EBS storage that is connecting on boot via /etc/fstab, you will need to provide an alternate fstab file and then activate it after instance launch. It is best to copy /etc/fstab to something like /etc/fstab.bundled, and then comment out the EBS drive for easy uncommenting later. If you do not do this, there is a good chance the instance will not boot and will be inaccessible.
Below is a sample line for bundling the instance with a customized fstab file.
/home/ec2/bin/ec2-bundle-vol --destination /mnt --privatekey /root/pk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.pem --cert /root/cert-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.pem --user 123456789012 --exclude /home --prefix image-20091119 --arch i386 --fstab /etc/fstab.bundled


why it makes parts by 10mb?
is here way to make bigger parts (~1Gb)?
or maybe one big img?)
thanks
That is a predefined value Amazon setup to handle transfers. If the files you transfer haven’t changed since the last upload, Amazon will not transfer anything, and if only parts of the files have changed they will only transfer the parts of the file that have changed (the ‘chunk’). It also ensures upload reliability for larger files. Amazon recommends you keep the existing 10MB default chunk size as long as your max size is around 90GB (10k chunk limit X 10MB chunk size) — apparently Amazon themselves even transfers files these way.
I believe Amazon allows different chunk sizes, but I’m not exactly sure what the command is for ec2-bundle-vol.