Amazon EC2/S3 教學
Today I will describe in short how to create an AMI instance of EC2 and than upload it to S3 server. All you need to have is running instance of EC2 server (I’m using Debian) with EC2
tools preinstalled.
First of all, make sure that you don’t have any unnecessary files on your server filesystem which you don’t need to bundle in an image as it will only slow the process down and make
your costs of storing backup images higher.
Once you are sure that your instance is fine and EC2 tools are in place you have to transfer your private key file and certificate file to the server. Lets put the files under /root
directory.
If all is set up correctly, first of all, we create and image by running:
ec2-bundle-vol -d /mnt -k /root/PrivateKey.pem --cert /root/Certificate.pem -u 012345678901
The number after the -u flag is your Amazon account ID which you can find on the AWS website once logged in.
Running above command will take a bit and will create a number of files under /mnt directory.
Once we have the files and manifest ready (all happens auto-magically) we can start transferring the image onto S3 account.
In order to transfer your image on S3 you would have to create a bucket there first, for this you can use famous firefox plugin (S3 Organizer) or do it using Affirma’s library (previous post).
ec2-upload-bundle -b yourbucketname00404042009 -m /mnt/image.manifest.xml -a your_s3_access_key -s your_s3_secret_access_key
If for some reason you encouter any problems during upload but your bundling went ok, you can retry the upload using –retry flag:
ec2-upload-bundle -b yourbucketname00404042009 -m /mnt/image.manifest.xml -a your_s3_access_key -s your_s3_secret_access_key --retry
//