How To Launch and Connect To An Amazon RDS DB Instance: Follow These Steps To Learn by Building Helpful Cloud Resources
How To Launch and Connect To An Amazon RDS DB Instance: Follow These Steps To Learn by Building Helpful Cloud Resources
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. You can
migrate existing applications and tools that utilize a relational database to the
Amazon Web Services because Amazon RDS offers access to the capabilities of
a MySQL, Oracle, SQL Server, and the PostgreSQL database engine. Amazon
RDS provides cost-efficient and resizable capacity while managing time-
consuming database administration tasks. This efficiency frees you to focus on
your applications and business.
This lab is focused on Amazon RDS. Follow along and learn to create and use
your first RDS database with Amazon AWS.
The AWS Management Console is a web control panel for managing all your
AWS resources, from EC2 instances to SNS topics. The console enables cloud
management for all aspects of the AWS account, including managing security
credentials, or even setting up new IAM Users.
We created a Console User just for you. Log in with the username student and
the password Ca1_lxkHfi7R .
Select the right AWS Region
Amazon Web Services is available in different regions all over the world, and the
console lets you provision resources across multiple regions. You usually choose
a region that best suits your business needs to optimize your customer’s
experience, but you must use the region US West (Oregon) for this laboratory.
Select the US West (Oregon) region using the upper right drop-down menu on
the AWS Console page.
Step 2 Create an RDS Subnet Group
Amazon Relational Database Service (Amazon RDS) makes it easy to set up,
operate, and scale a relational database in the cloud. Before launching actual
RDS instances, you need to configure a DB Subnet Group.
Subnets are segments of a VPC's IP address range that allow you to group your
resources based on security and operational needs. A DB Subnet Group is a
collection of subnets (typically private) that you create in a VPC and designate
for your DB instances. Each DB subnet group should have subnets in at least two
Availability Zones in a given region. Note that SQL Server Mirroring with a SQL
Server DB instance requires at least 3 subnets in distinct Availability Zones.
When creating a DB instance in a VPC, you must select a DB subnet group.
Amazon RDS uses that DB subnet group and your preferred Availability Zone to
select a subnet and an IP address within that subnet to associate with your DB
instance. When Amazon RDS creates a DB instance in a VPC, it assigns a
network interface to your DB instance by using an IP address selected from your
DB Subnet Group. If the primary DB instance of a Multi-AZ deployment fails,
Amazon RDS can promote the corresponding standby and subsequently create a
new standby using an IP address from an assigned subnet in one of the other
Availability Zones.
You can create an RDS Subnet Group using the RDS launch wizard.
Select the RDS service from the Management Console dashboard:
From the RDS dashboard, click Subnet Groups from the left-hand menu.
Click Create DB Subnet Group to open the creation wizard.
You must fill the form using the following data:
Name: cloudacademy
Description: rds lab
VPC ID: select the available one
You must add the available subnets of the selected VPC. Click add all the
subnets button for filling the subnet list and then click Create.
After a few seconds, your DB Subnet Group will be available and ready for use.
Step 3 Create a database cluster using RDS
Amazon Relational Database Service (Amazon RDS) makes it easy to set up,
operate, and scale a relational database in the cloud. Amazon RDS is designed
for developers or businesses who require the full features and capabilities of a
relational database or who wish to migrate existing applications and tools that
utilize a relational database. It gives you access to the capabilities of
a MySQL, Oracle, Microsoft SQL Server, MariaDB, Amazon Aurora,
or PostgreSQL database engine.
The RDS service is fully managed by Amazon. RDS will make sure that the
database software stays up-to-date with the latest patches and any faulty compute
instance powering your database deployment will be automatically replaced in
the event of a hardware failure. You can automatically or manually create
database snapshots and easily scale your infrastructure up or down using the
AWS Management Console.
You can launch an RDS instance using the RDS launch wizard. Select the RDS
service from the Management Console dashboard:
Select Instances from the left menu and click Launch DB Instance.
The Launch DB Instance Wizard appears and you must select the database
engine. Choose the MySQL database engine and click the Select button.
The next step asks if you are planning to use the DB instance you are creating for
production purposes. By selecting Yes, the failover option, Multi-AZ and the
Provisioned IOPS storage option will be preselected in the following step. For
this exercise, please select Dev/Test MySQL. Then click Next Step.
On the Specify DB Details page, you should select the following options:
Note: You've been working in the RDS console. Make sure you go back to the
main console and select the VPC console.
In the navigation pane, click Security Groups. Locate and click the rds-launch-
wizard security group.
On the Inbound Rules tab, click Edit.
Click Save, and you will be ready to connect to your RDS instance inside the
VPC.
The Choose an Amazon Machine Image (AMI) page displays a list of basic
configurations called Amazon Machine Images (AMIs) that serve as templates
for your instance. Click Select for the first listed 64-bit Amazon Linux AMI:
On the Choose an Instance Type page, you should not change any
options. Simply make sure the default t2.micro is selected:
server-ip is the Public IP of your server, you can find it in the EC2
instance details
user is the remote system user that will be used for the remote
authentication
Note: your SSH Client may refuse to start the connection, warning that the key
file is unprotected. You should deny the file access to any other system user by
changing its permissions. Issue the following command and then try again:
chmod 600 /home/youruser/keypair.pem
Connect using Windows
Windows has no SSH client, so you must use PuTTY (get it here!) and convert
the PEM key to PPK using PuTTYgen.
Starting a remote SSH session using PuTTY is easy:
Open PuTTY and insert the EC2 instance IP Address in the Host Name field.
Select Connection > SSH > Auth section and then select the downloaded
Keypair that you previously converted to PPK format.
After some seconds, you will see the authentication form. Login as ec2-
user and you will see the EC2 server welcome banner.
Step 7 Connect to RDS and create a database table
Your RDS instance is ready and accessible from any EC2 instance created within
the same VPC, so you can connect to the previously created EC2 instance and
use the database.
The MySQL client software isn't usually installed in the Linux Amazon AMI, but
you can download and install it using the YUM package manager.
Execute the following command: sudo yum -y install mysql
You are ready to connect to your RDS instance using the RDS Endpoint URL.
It's automatically generated during the RDS instance creation and you can find it
in the RDS instance details box.
In order to complete this lab step, you must connect to your instance, using the
RDS Endpoint URL, and create a table named "laboratory" in the database
"rdsappdb".
Connect to your RDS instance by using the mysql client and
replace your.endpoint.aws.com with your real endpoint URL (w/o including the
host port): mysql -h your.endpoint.aws.com -u cloudacademy -p rdsappdb
Insert the DB Master Password ( myStrongRDSpwd! ) and the MySQL console will
be ready to accept SQL queries.
Note: remember NOT to include the port number of your endpoint URL (e.g.
":3306") or you will not be able to connect to the remote host.
Create a new table in the "rdsappdb" database writing CREATE TABLE laboratory (
id INT, name VARCHAR(100) ); and then press ENTER.
You can check if the table was successfully created using the SQL
command: DESC laboratory;
Close your database connection writing the command: quit;
Step 8 Destroy an RDS instance
You can delete an RDS Instance using the AWS Management Console.
Select the RDS service from the Management Console dashboard:
From the RDS dashboard, click Instances from the left menu.
Select rds-lab from the RDS Instances list. Click on the Instance
Actions button, then select Delete.
On the Delete DB Instance page, answer No to the Create final Snaphot? query.
Check the acknowledgement checkbox, and click Delete.
Your RDS instance is now in the deleting status, which will take a few minutes
to complete.