Setup AWS API tool

Setup AWS API tool

Download API tool
wget http://s3.amazonaws.com/ec2-downloads/ec2-api-tools.zip
unzip ec2-api-tools.zip -d /usr/local/ec2

Where is Java?
which java
file /usr/bin/java
file /etc/alternatives/java
/usr/lib/jvm/jre-1.x.0-openjdk.x86_64/
User this path for the config

Setup env
vi ~/.bash_profile

export JAVA_HOME=”/usr/lib/jvm/jre-1.x.0-openjdk.x86_64/”
export EC2_HOME=”/usr/local/ec2/ec2-api-tools-1.7.3.0″
export AWS_ELB_HOME=”/usr/local/ec2/ElasticLoadBalancing-1.0.35.0/”
export PATH=$PATH:$EC2_HOME/bin:$AWS_ELB_HOME/bin
export aws_access_key_id=”AAAAAAAAAAAAA”
export aws_secret_access_key=”KKKKKKKKKKKKKKKKKKKKKK”
export EC2_URL=”https://ec2.us-west-1.amazonaws.com:443″

Create my own AWS AMI

Followed this very detailed instruction to create my own CentOS5 AWS AMI image

How to create an Amazon Elastic Compute Cloud EC2 Machine Image (AMI)

Every thing went all right except the problem came when booting the image…it doesn’t boot.

It seems that the kernel 2.6.16 is too old, so download 2.6.18 from Amazon Dev forum.
Rebundled and registered the image with new kernel but still it doesn’t boot….
The next thing I tried is to specify the kernel ID and RAM ID as the same ones which is used to bundle/upload AMI images, when bringing up the instance. It booted this time.

Using the following way to convert the instance-store backed image to EBS backed image.
Bring up a EBS volume and attach to this server,
# mkdir /newos && mount /dev/sdf /newos
# rsync -avHx / /newos
# rsync -avHx /dev /newos
# sync;sync;sync;sync && umount /newos
Then create a snapshot of the volume.

Use command line or aws admin console to register AMI
Register the AMI
# ec2-register -a x86_64 –block-device-mapping /dev/sda1=snap-2715c442::false –name mycentos5ebs_2012 –kernel aki-xxxxxx –ramdisk ari-xxxxxx -K pk-xxxxxxxxxxxxx.pem -C cert-xxxxxxxxxxxx.pem –region us-west-1
IMAGE ami-xxxxxx
(use the same aki-xxxxx and ari-xxxxxx as the original server used for creating image)

Another issue:
When running “yum update”, it shows error message for corrupted rpm db.
It seems that rpm db is using Berkely DB and after tried to fix the db by
rm -f /var/lib/rpm/__db*
rpm –rebuilddb
It still shows error “cannot open Packages index using db3”

So initial the db by
rpm –initdb
then install the Base yum packages again
yum -y groupinstall Base

References
http://www.howtoforge.com/kernel_compilation_fedora
http://www.cyberciti.biz/tips/compiling-linux-kernel-26.html
http://aws.typepad.com/aws/2010/07/use-your-own-kernel-with-amazon-ec2.html
http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/UserProvidedkernels.html
http://www.ibm.com/developerworks/linux/library/l-linuxboot/
http://amazonaws.michael–martinez.com/

Installing Cent OS 5.5 on EC2 with the Cent OS 5.5 Kernel

New VM network issum

After brought up a new VM on VMware using CentOS template, I had problem to setup the network.
“The network device eth0 seems missing” was shown when I tried to bring up eth0. But actually the system thought the device is eth2!

Here is a good article showing how to fix this issue,

Here