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.