Amazon EC2/S3 Tutorial

    版本為 01:32, 27 Dec 2024

    到這個版本。

    返回到 版本存檔.

    查閱目前版本

    Amazon EC2/S3 教學

    Creating AMI from existing instance

    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
    

    註冊備份好的 AMI image

    ec2-register -K pk-*.pem -C cert-*.pem your-bucket/image.manifest.xml
    

    NOTES:

    * pk-*.pem, cert-*.pem 這兩個是 x509 的 key,需要透過 AWS Console 來產生。

    * 註冊後的 AMI,可以在 Elasticfox > Images > Filter: My AMIs 看到。

    安裝 EC2 API Tools

    // 下載 JRE 1.6 - jre-6u21-linux-i586.bin

    http://www.oracle.com/technetwork/ja...ads/index.html

    // 安裝 JRE 1.6

    # chmod u+x jre-6u21-linux-i586.bin
    # ./jre-6u21-linux-i586.bin
    # mv jre1.6.0_21/ /opt
    

    // 設定 JRE

    # vi /etc/profile.d/java.sh
    
    export JAVA_HOME=/opt/jre1.6.0_21
    export PATH=$JAVA_HOME/bin:$PATH 
    

    // 下載 ec2-api-tools

    http://developer.amazonwebservices.c...externalID=351

    // 安裝 ec2-api-tools

    unzip  ec2-api-tools.zip
    mv ec2-api-tools-1.3-53907/ ~/.ec2
    vi ~/.bashrc
    
    # for EC2 API Tools
    export EC2_HOME=~/.ec2
    export PATH=$PATH:$EC2_HOME/bin 
    

     

    如何增加 EBS volume 空間

    Powered by MindTouch Core