Starting Websphere in Cloud and saving the data in S3


  

This tutorial assumes that you have already setup the Amazon cloud account and you know how to launch an instance. Just like we did in the last tutorial, go to the Amazon AWS console and click on the ‘Launch instance’ button. Now, you can see a new widow that has popped up. Go to the ‘Community AMIs’ tab and search for ‘smash’.

Then select ‘smash1111_dev.manifest.xml’ (probably the first one in the list) and proceed to the next stage.

 

smash - in AWS

 

In the next stage, you can enter your own username and password for the Smash application server. You need to remember these values as we need to enter them later.

 

instances in AWS

 

And, then select the security group (make sure that you have added SSH and HTTPS) and the key you created for the current zone.

Now your instance will start showing up under the ‘Running instances’ menu. Right click on the instance and select the ‘connect’ option (please see the earlier tutorial for details). And you will see a help box:

 

connecting - ssh -to AMI

 

Please copy the command shown in the box. You need this for connecting from the terminal.

 

ssh –i  YourKey.pem   root@ec2-184-73-3-248.compute-1.amazonaws.com

 

You may note that ec2-184-73-3-248.compute-1.amazonaws.com is the Public DNS of your deployed instance. Now go to:

 

https://your_public_dns

 

And accept the Smash and Amazon licenses. You have to enter your username and password to confirm the identity. Now open your terminal and enter the line you copied from the AWS console page

 

ssh –i  YourKey.pem   root@ec2-184-73-3-248.compute-1.amazonaws.com

 

Now you can SSH to your AMI (which is a SUSE Linux based one) :

 

AMI Amazon - Suse

 

 

Uploading the  EC2 API tools

Download the EC2 API package from the official website and secure copy (scp) it to your AMI:

 

scp –i US-East.pem ~/your_directory/ec2-api-tools.zip root@ec2-184-73-3-248.compute-1.amazonaws.com:/home

 

Before issuing this command, make sure that your have a ‘home’ directory in your AMI (if not, create – ‘mkdir’- one). This will copy the file from your system to the ‘home’ directory of your AMI.

Now upzip the zipped file and move them to /ec2tools/ folder (You can choose any directory name you like):

 

unzip ec2-api-tools.zip
mv ec2-api-tools-* ec2tools

 

Similarly upload your certificate and private key to the ‘home’ folder.

Open you .bashrc file (using vi) and enter the following:

 

export EC2_CERT=/home/cert-aasisvinayak-aws.pem
export EC2_PRIVATE_KEY=/home/pk-aasisvinayak-aws.pem
export EC2_HOME=/home
export PATH=$PATH:/home/ec2tools/bin
export EC2_URL=http://us-east-1.ec2.amazonaws.com

EC2 tools config

Please note that you need to edit the above lines in order to match your file names. Save the file by hitting ‘Esc :wq!’ (if you in vi).

 

Installing an application

 

Let’s write a Java application and compile from the AMI. For doing this, we need to install JAVA in the machine. Download the jdk-6u18-linux-i586-rpm.bin file from Sun’s website. Secure copy the file in the same way as we did in the case of EC2 Tools.

 

java bin

 

Now issue the following from the terminal – which we used for SSH (you should be in the AMI’s terminal for issuing these):

 

chmod +x jdk-6u18-linux-i586-rpm.bin
./ jdk-6u18-linux-i586-rpm.bin

 

This will work if you are already in the ‘home’ directory and will install JAVA in the machine.

 

installing java in aws ami

 

Saving Data

 

Now write a simple program in JAVA and compile it (use ‘javac’) from the AMI terminal. Now we have ‘some data’ in our machine. If we terminate the instance, then this data will be lost. This is the reason why we use a storage service (S3) along with EC2.

In order to store the data, we need to bundle it. For that, issue the following command:

ec2-bundle-vol -d /home/EC2IMAGE -k /home/pk-aasisvinayak-aws.pem -c /home/cert-aasisvinayak-aws.pem -u YOUR_ACCOUNT_NO -r i386 -p smashjava.img –e /tmp

 

This will ‘bundle’ our data as a package. Please note that we are skipping few directories as these contain generic and unwanted data.

 

bundling data in ami

 

This command will generate a set of image files. You may note that this process takes a couple of minutes.

 

bundle data - amazon cloud

 

Now issue:

ec2-upload-bundle -b vinayak-bucket -m /home/EC2IMAGE/smashjava.img.manifest.xml -a ACCESS_ID -s SECRET_ID

(Please replace the text by your access and secret id, which you can get from AWS website)

Also, note that you can give any name for your bundle. But you need to remember the name your have given. This command will upload all the images files to the storage base.

 

uploading bundle to S3

 

And this step will also take a couple of minutes to complete.

 

upload data - cloud

 

Now go to your AWS console and select AMI from the sidebar. This allows you to register a new image. Click on the ‘register new image’ button and enter:

 

vinayak-bucket/smashjava.img.manifest.xml

 

(Please edit the name as you like).

 

register new ami - aws

 

Alternatively you may register it from the command line using:

 

ec2-register vinayak-bucket/smashjava.img.manifest.xml

 

Now this will appear in the list of AMIs owned by you.

 

list own ami - aws

 

Whenever you want to continue working on that project, you can launch your AMI and continue working.

 

list running ami in aws

 

If you install the EC2 API in your local machine, them you can monitor all the activities directly from the terminal (see the screen shot given below)

 

ec2 api tools in localhost

 

You can also download the image files to your computer and manage your S3 space efficiently. I will be covering those aspects in the next edition.

Tags: , , ,


TechBlog on Facebook

Leave a Reply