Wednesday, June 20, 2012

Creating An Amazon EC2 From A Running Instance

Follow below given link, its very good article:

http://webkist.wordpress.com/2010/03/16/creating-an-amazon-ec2-ebs-ami-from-a-running-instance/ 

Otherwise after completion of Step 2 in above link follow below steps:

1) Go to Amazon Management Console

2) Go to EC2 Dashboard

3) Go to Volumes Panel (which is in left side)

4) Right Click on the Volume where image has been copied

5) Click on "Create Snapshot"

6) Click on Snapshot Panel ( which is in left side and after Volume Panel)

7) Select Snapshot which is just created and then Click on the "Create Image" button just above the list ofSnapshots

8) This will ask for RAM Disk and Kernel ID (copy from the Actual image description)

9) Click on "Create Image"

Thats it!!!

Thursday, January 7, 2010

Amazon RDS

CLOUD COMPUTING: AMAZON RDS



Amazon Relational Database Service (Amazon RDS) is a web service that makes it easy to set up, operate, and scale a relational database in the cloud.

We do not need to install and configure MySQL over the server/hardware which is a time consuming process, so Amazon provides RDS Service which is pre-installed and optimized MySQL Database Service. RDS Service provide a Administrator level user to you so that user can do Database administrative work like assigning/revoking privileges, changing global variables, changing database engine etc..

Silent features:
Replication--Replication is disabled, but the master user does not have privileges to run SHOW MASTER STATUS.
Scalable—With a simple API call you can scale the compute and storage resources available to your database to meet your business needs and application load.
Designed for use with other AWS products—Amazon RDS is tightly integrated with other Amazon products. For example, applications running in Amazon EC2 experience low-latency database access to Amazon RDS.
Backup—Amazon RDS Service provides backup to user as per their defined period.
Recovery--Amazon docs state that database can be recovered up to the last 5 minutes. That means amazon is taking backup after every 5 minutes somewhere on cloud.
Security--Assign/revoke permission from security group.
Start/Stop--Reboot RDS instance.
Inexpensive—You pay a low rate for the resources you actually consume.



For using Amazon RDS we must have API Tools. Here are the commands to start and manage RDS:

We need to export some variables for using API Tools such as:

export JAVA_HOME=/opt/java
export AWS_RDS_HOME=/path/to/amazon_rds/api
export PATH=$PATH: $AWS_RDS_HOME/bin:$JAVA_HOME/bin



CREATING INSTANCE USING RDS API's


1) How To create a RDS with storage 15GB and extra large database instance?

rds-create-db-instance --engine MySQL5.1 --master-username root --master-user-password mpass --db-name tekritidb --db-instance-identifier tekriti_instance --allocated-storage 15 --db-instance-class db.m1.xlarge --header -K /private/key/path -S /secret/key/path

OUTPUT:

DBINSTANCE DBInstanceId Class Engine Storage MasterUsername Status Backup Retention
DBINSTANCE tekriti_instance db.m1.xlarge mysql5.1 5 root creating 1

SECGROUP Name Status
SECGROUP default active
PARAMGRP Group Name Apply Status
PARAMGRP default.mysql5.1 in-sync


NOTE: Instead of defining access and secret keys with command every time, we can also define in file ${AWS_RDS_HOME}/credential-file-path.template.


2) How to check/describe running RDS instances?

rds-describe-db-instances -K /private/key/path -S /secret/key/path

OUTPUT:

DBINSTANCE tekriti_instance 2009-12-08T06:34:52.571Z db.m1.xlarge mysql5.1
5 root available tekriti_instance.clc2ed76md1v.us-east-1.rds.amazonaws.com 3306 us-east-1d 1
SECGROUP default active
PARAMGRP default.mysql5.1 in-sync


AUTHORIZE NETWORK ACCESS TO RDS INSTANCE

3) Authorizing network access to RDS instance:

i) How to Grant access to 192.168.0.0/24 network


rds-authorize-db-security-group-ingress default --cidr-ip 192.168.0.0/24 --headers


ii) How to Check the state of authorization


rds-describe-db-security-groups default --headers


iii) How to Grant access to the existing EC2 Security Group

rds-authorize-db-security-group-ingress default --ec2-security-group-name myec2group --ec2-security-group-owner-id 987654321021


--ec2-security-group-owner-id = AWS account number of the security group.


CONNECT TO RDS INSTANCE DB


4) How to Connect RDS instance from EC2 instance

Log in over your EC2 server and run following command to access your MySQL RDS instance:

mysql -u root -p mpass -h tekriti_instance.clc2ed76md1v.us-east-1.rds.amazonaws.com

mysql>

This will drop you on RDS instance MYSQL prompt, that means you are connected to RDS instance MYSQL.

Now you can run your application on EC2 server with database on RDS.

Missing features:

Remote Connectivity-- I did not see an option to enable SSH connections to MySQL. I think that is required for this to be a good way to run MySQL.
Replication/NDB Cluster-- Replication and NDB Cluster is not available in RDS.

Sunday, October 18, 2009

HOW TO SETUP AMAZON LOAD BALANCER AND AUTO SCALING

How to setup Load Balancer for Amazon EC2 instaces/Applications?


First of all we must have Elastic Load Balancer API Tools.

Download Elastic Load Balancer API Tools and unzip into a folder suppose /Backup/elb.


Export variable AWS_ELB_HOME='/Backup/elb'


Elb-create-lb – This is the first command to create Load Balancer.

Go to Directory /Backup/elb/bin and run following command:

./elb-create-lb LBName --ec2-cert-file-path Certificate-file-path --ec2-private-key-file-path privatekey-file-path --availability-zones us-east-1c --listener "protocol=http, lb-port=80, instance-port=80"


This command will give you Load Balancers Public DNS Name.


Next is to register this Load Balancer


./elb-register-instances-with-lb LBName --ec2-cert-file-path Certificate-file-path - -ec2-private-key-file-path privatekey-file-path --instances InstanceID1,InstanceID2


This will show you results like

Instance : InstanceID1
Instance : InstanceID2



Now Setup Auto Scaling


For setting up Auto Scaling using Command Line we must have AutoScaling API Tools.

Download AutoScaling API Tools and unzip into a folder suppose /Backup/amazon/als.

Export variable AWS_AUTO_SCALING_HOME='/Backup/amazon/als'

Go to Directory /Backup/amazon/als/bin

First we need to define / create configuration for AutoScalingGroup

./as-create-launch-config --launch-config ASLaunchConfigurationName - -ec2-cert-file-path /path/to/certificate/file - -ec2-private-key-file-path /path/to/private/key/file - -image-id ami-ID - -instance-type m1.small


OK-Created launch config

Now show installed or created configurations

./as-describe-launch-configs - -ec2-cert-file-path--ec2-cert-file-path /path/to/certificate/file - -ec2-private-key-file-path /path/to/private/key/file


Will display like ::

LAUNCH-CONFIG FirstAS ami-3b53b452 m1.small

Now time to create AutoScalingGroup

./as-create-auto-scaling-group AutoScalingGroupName - -ec2-cert-file-path /path/to/certificate/file - -ec2-private-key-file-path /path/to/private/key/file --launch-configuration ASLaunchConfigurationName --availability-zones us-east-1a - -min-size 2 - -max-size 4 --load-balancers LBName

OK-Created AutoScalingGroup

Now create or setup trigger to customize parameters of AutoScalingGroup for creation and termination of any Instance using following command:

CreateOrUpdateScaling