0% found this document useful (0 votes)
101 views

How To Launch and Connect To An Amazon RDS DB Instance: Follow These Steps To Learn by Building Helpful Cloud Resources

This document provides instructions for creating and connecting to an Amazon RDS database instance. It explains that Amazon RDS makes it easy to set up and manage relational databases in the cloud. It then outlines the steps to create an RDS subnet group, launch a MySQL database cluster on RDS, set up security group rules to access the database, launch an EC2 instance, and connect to the RDS database from the EC2 instance. The steps guide the user through the AWS Management Console to build out these cloud resources and connect all the pieces.

Uploaded by

Andres Bustos
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
101 views

How To Launch and Connect To An Amazon RDS DB Instance: Follow These Steps To Learn by Building Helpful Cloud Resources

This document provides instructions for creating and connecting to an Amazon RDS database instance. It explains that Amazon RDS makes it easy to set up and manage relational databases in the cloud. It then outlines the steps to create an RDS subnet group, launch a MySQL database cluster on RDS, set up security group rules to access the database, launch an EC2 instance, and connect to the RDS database from the EC2 instance. The steps guide the user through the AWS Management Console to build out these cloud resources and connect all the pieces.

Uploaded by

Andres Bustos
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 25

How to launch and connect to an Amazon RDS DB instance

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.

Follow these steps to learn by building helpful cloud resources


Log In to the Amazon Web Service Console
Your first step to start the Lab experience

Create an RDS Subnet Group


How to create a DB Subnet Group for RDS instances

Create a database cluster using RDS


Create an RDS instance using the MySQL engine

Setup security group rules for connecting to the RDS instance


How to add the right rules to connect to the RDS instance

Create an EC2 instance


Launch a new EC2 instance using the management console wizard

Connect to a remote shell using an SSH connection


How to use a remote Linux shell from Windows, Linux or Mac

Connect to RDS and create a database table


How to use the mysql client to connect to an RDS instance

Destroy an RDS instance


How to destroy an RDS instance
Step 1 Log In to the Amazon Web Service Console
This Lab experience involves Amazon Web Services, and you will use the AWS
Management Console to complete all the Lab Steps. Please note that you will
have a space storage limit of 100GB for this lab, which will be more than
sufficient to complete it.

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.

Log in to the AWS Management Console


To start the Lab experience, open the Amazon Console by clicking this button:
OPEN AWS CONSOLE

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:

 License Model: general-public-license


 DB Engine Version: select the latest one
 DB Instance Class: db.t2.micro
 Multi-AZ Deployment: No
 Storage Type: General Purpose (SSD)
 Allocated Storage: 5GB
Scroll down the page and continue configuring your RDS Instance by filling-in
the following fields:

 DB Instance Identifier: rds-lab


 Master Username: cloudacademy
 Master Password: myStrongRDSpwd!
Click Next Step, and start configuring the Advanced Settings.
On the Configure Advanced Settings page, provide additional information that
RDS needs to launch the MySQL DB instance.
You need to select the following options:

 VPC: select the available one


 Subnet Group: cloudacademy
 Publicly Accessible: No
 Availability Zone: us-west-2a
 VPC Security Group(s): Create new Security Group
 Database Name: rdsappdb
 Database Port: 3306
 DB Parameter Group: default
 Option Group: default
 Enable Encryption: No
Continue specifying the following settings for
the Backup and Mainteniance options:

 Backup Retention Period: 0 days


 Backup Window: No preference
 Auto Minor Version Upgrade: Yes
 Mainteniance Window: No preference
Click Launch DB Instance, and then click View Your DB Instances.

N.B., RDS instance creation requires up to 10 minutes for completion. Wait


until its status becomes available.

Step 4Setup security group rules for connecting to the RDS


instance
In order to use the previously created RDS instance inside the VPC, you need
to add an inbound rule to the VPC Security Group created during the RDS
instance creation.
The rules of a Security Group control the inbound traffic that's allowed to reach
the instances that are associated with the security group and the outbound traffic
that's allowed to leave them. By default, security groups allow all outbound
traffic and deny all inbound traffic.
You can add new rules to a VPC Security Group using the AWS Management
Console.
Select the VPC service from the Management Console dashboard:

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.

Ensure that the rule is completed using the following information:


 Type: MYSQL
 Protocol: TCP
 Port: 3306
 Source: 172.31.0.0/16

Click Save, and you will be ready to connect to your RDS instance inside the
VPC.

Step 5 Create an EC2 instance


You can launch an EC2 instance using the EC2 launch wizard.
Select the EC2 service from the Management Console dashboard:

From the EC2 dashboard, click Launch Instance.

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:

Click the Review and Launch button. Spend a few minutes


expanding/collapsing the various sections on the review page, noting the type of
information that is included. For example, look over the Instance
Type, Instance Details and Storage sections. (None of these settings need to be
changed for this lab.)
On the Review Instance Launch page, click Launch.
In the Select an existing key pair or create a new key pair dialog box,
select Create a new key pair, then type a KeyPair name (e.g., "TestKeys") and
download it.
Select the acknowledgment checkbox, and then click Launch Instances.
A confirmation page will let you know that your instance is launching.
Click View Instances to close the confirmation page and return to the console.
On the Instances Screen, you can view the status of your instance. It will take a
short time for your instance to be launched. When you launch an instance, its
initial state defaults to pending. After the instance starts, its Instance State
changes to running, and it receives a public DNS name.

Step 6 Connect to a remote shell using an SSH connection


In order to manage a remote Linux server, you must employ an SSH Client.
Secure Shell (SSH) is a cryptographic network protocol for securing data
communication. It establishes a secure channel over an insecure network.
Common applications include remote command-line login and remote command
execution.

Connect using Linux / Mac OS


Linux distributions and Mac OS are shipped with a fully working SSH client that
accepts standard PEM Keys.
Starting a remote SSH session is easy:
 Open your Terminal application
 Write and run the following command: ssh -i
/path/to/your/keypair.pem user@server-ip .

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

Amazon Linux AMIs typically use ec2-user as username.


Ubuntu AMIs login user is ubuntu , Debian AMIs use admin instead.
Assuming that you selected the Amazon Linux AMI, your assigned public IP is
123.123.123.123, and your keypair (named "keypair.pem") is stored in
/home/youruser/keypair.pem, the right command to run is: ssh -i
/home/youruser/keypair.pem [email protected]

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.

You might also like