This article will discuss basic topics about Amazon Relational Database Service (RDS).
These are the topics we will cover:
- Basic RDS concepts
- Creating an RDS instance
- Connecting to an RDS instance
- Deleting an RDS instance
Amazon RDS is a service that provides a highly available and highly scalable relational database. The relational databases that you can use with RDS are MySQL, PostgreSQL, Oracle and Microsoft SQL Server.
VMware Training – Resources (Intense)
AWS is not reinventing the wheel when it comes to relational databases used with RDS. It allows you to use well known products as a managed service. Why would you want to do this? There are various reasons:
- AWS deals with backups, software patching, failure detection and recovery.
- You can scale the CPU, memory and storage separately based on your needs.
- You can set up automated or manual backups.
- Using IAM you can refine the users’ access to the databases and this is on top of other security policies coming from security groups.
Let’s discuss a little bit about RDS components.
The first one is the DB instance. The DB instance is a database in an isolated environment. One DB instance can contain multiple databases that a user creates. Access to the databases is done similarly to the way databases outside the AWS cloud would run.
I was mentioning above the databases that you can use. All of them are database engines and when a DB instance is set, there are particular settings to each engine based on your choice. DB instance class determines the computation and memory scale. Each instance class determines the minimum and maximum storage that the DB instance can have. The hard minimum and maximum values for storage are 5GB and 3TB. The storage comes in two types: standard and preprovisioned storage.
Another component is Availability Zones. This is for redundancy. Actually, you can deploy RDS in different regions, but within the same region, you have the option to deploy a multi-AZ instance. This means that the same DB instance is deployed in multiple AZ. The primary DB instance is replicated across multiple AZ to the standby DB instances.
Security groups are another component and specify who can access the DB instances. Restrictions can be based on either IP or EC2 instances.
A DB parameters group allows a user to manage the configuration of a DB engine. A parameter group has the engine configuration details that can be applied to multiple identical instance type DB instances. There is a default group that will be applied in case the user doesn’t provide one.
The last component is DB option groups, which allow AWS to make specific tools available to different database engines that make working with them easier. Option groups are not available for PostgreSQL.
For this article, we will create a DB instance based on MySQL.
From the AWS console, choose “RDS” from “Database” section. From the “RDS Dashboard”, click on “Get Started Now”. On the next screen, choose MySQL:
On the next screen, you will be asked if you would like to have a multi-AZ deployment or not. As this is a lab and there is not that much difference in configuration between the two deployments, choose a single AZ deployment and then click on “Next”:
In the next screen, you will need to provide the DB instance name, the master username and the password for master user. In this case, I chose the user to be “master” and the password “master123” (you need to input at least 8 characters for the password). Click on “Next” once you are done:
On the next step, leave everything as default and choose a name for your database. In this case, I used “RDS_DB”. Once you fill this in, click on “Launch DB Instance”:
Then the DB instance creation will be in progress:
You can see this as well in the status of the DB instance:
After the DB instance is created, you should see something similar to this. Take a look at all the details regarding your DB instance:
To connect to the DB instance, you will need the “Endpoint”. In this case it is rds-mysql.cb9fhtt370u9.us-east-1.rds.amazonaws.com.
We will connect to the MySQL using MySQL Workbench.
Add a new connection and provide the username and password used for this connection. Add the endpoint in the hostname field and then click on “OK”:
You will see a new connection being added:
Double clicking it will connect you to your DB instance and you can see in the lower left side the database we created, “RDS-DB”:
You can also connect to the MySQL database using well-known MySQL commands. For instance, from a Linux:
[ec2-user@AMAZON_AMI ~]$ mysql -h rds-mysql.cb9fhtt370u9.us-east-1.rds.amazonaws.com -P 3306 -u master -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 17 Server version: 5.6.19-log MySQL Community Server (GPL) Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | RDS_DB | | innodb | | mysql | | performance_schema | +--------------------+ 5 rows in set (0.00 sec) mysql>
As you can see, our database shows up.
Now let’s delete the DB instance. Select the DB instance and from “Instance Actions” choose to delete the DB instance. Do not choose to create a final snapshot and then click on “Yes, Delete”:
The DB instance will transition to a “deleting” state:
As you can see, deploying a relational database is pretty simple in AWS. The hard part is making use of it, which is not related to AWS at all. If you are developing a web application, you should know the ins and outs of the relational database. AWS just makes it easier for you to have a database that you can use in no time.
You should now know what AWS RDS is, how you can create and delete a DB instance with your database engine of your choice and how to connect to your DB instance.