arrow

Quickly Build a Relational Database Through RDS

1. Experiment overview

1.1 Key points

This experiment is designed to build a relational database through RDS. RDS for MySQL is used as an example. After completing this experiment, you will learn the following skills:

  • Basic concepts about RDS
  • How to set an RDS whitelist
  • How to create an RDS database
  • How to create an RDS account
  • How to remotely connect to an RDS instance
  • How to run simple SQL commands

1.2 Procedure

  • Set up experimental environment
  • Set RDS whitelist
  • Acquire RDS Internet address
  • Create RDS account
  • Create RDS database
  • Log in RDS Instance and run execution

1.3 Cloud resources

  • RDS instance: MySQL 5.6
  • ECS instance: Ubuntu 16.04.2 LTS

1.4 Prerequisites

  • An Alibaba Cloud account has been assigned automatically.
  • An RDS instance has been created automatically.

1.5 Hint

  • When you enter the ECS console, the default region area may be different because of the different network addresses of your logon location. If you find that the resource automatically created in the document does not exist at the console interface, please manually switch to the United States - Silicon Valley’s region, you will find them there.

  • If you encounter some differences between the real experimental environment and the captured pictures in the lab manual, it may be caused by cloud portal version difference, which does not have a great impact on your experimental experience. You can click comment to give feedback to us. We will update the document in time. Thank you for your cooperation.

2. Experiment instructions

2.1 Start the experiment environment

Click Start Lab in the upper right corner of the page to start the experiment.

image desc.

After the experiment environment is successfully started, the system has deployed resources required by this experiment in the background, including the ECS instance, RDS instance, Server Load Balancer instance, and OSS bucket. An account consisting of the username and password for logging on to the Web console of Alibaba Cloud is also provided.

image desc

After the experiment environment is started and related resources are properly deployed, the experiment starts a countdown. You have two hours to perform experimental operations. After the countdown ends, the experiment stops, and related resources are released. During the experiment, pay attention to the remaining time and arrange your time wisely. Next, use the username and password provided by the system to log on to the Web console of Alibaba Cloud and view related resources:

openCole

Go to the logon page of Alibaba Cloud console.

image desc

Fill in the sub-user account and click Next.

image desc

Fill in the sub-user password and click Log on.

image desc

After you successfully log on to the console, the following page is displayed.

image desc

Go to the RDS management page:

image desc

Select the US (Silicon Valley) area, you can see that an rds instance is being created, please wait a few minutes.

image desc

Wait until the RDS instance is successfully created:

image desc

2.2 Set a whitelist

Add the ECS intranet IP address to the RDS whitelist.

image desc

image desc

Add the IP address of the ECS instance to the RDS whitelist.

image desc

image desc

Click Create Whitelist.

image desc

Click Loading ECS Inner IP.

image desc

Set the name to “labex”.

image desc

image desc

Now you can view the intranet IP address of the RDS instance.

image desc

title: Whether to add an RDS whitelist
name: v1_40

2.3 Switch network type

Since the ECS instance is in the VPC network and the RDS instance is in the classic network, the two instances cannot communicate directly over the intranet address.

To make ECS instance and RDS instance intranet accessable to each other, we need to switch RDS’s network type from Classic Network to VPC. We will swtich RDS to the same VPC network as the ECS instance so that ECS can use its intranet address to connect to and manage RDS instances. With above steps done, we will not longer need to apply for RDS’s internet access.

Then switch the network mode to VPC network:

image desc

image desc

Select the default VPC network and start switching:

image desc

Wait a moment and switch is complete.

image desc

At this point, the RDS is in the same VPC network as the ECS instance. They can communicate through the intranet address.

title: Whether to switch RDS network type
name: v2_40

2.4 Create a database and an account

Refer to the figure below and click Create Database.

image desc

Refer to the figure below to set the database name, click Create.

image desc

Created successfully.

image desc

Refer to the figure below and click Create Account.

image desc

Refer to the following to set the account name and password.

Account information

Username: rds_admin

Password: Aliyun-test

image desc

Click OK.

image desc

Created successfully.

image desc

title: Whether to create RDS database and account
name: v3_40

2.5 Remotely connect to the RDS instance

Click Elastic Computer Service, as shown in the following picture.

image desc

We can see one running ECS instance in the US West 1 region. Click it to go to the ECS console as shown in the following figure.

image desc

Copy this ECS instance’s Internet IP address and remotely log on to this ECS (Ubuntu system) instance. For details of remote login, refer to login

image desc

The default account name and password of the ECS instance:

Account name: root

Password: nkYHG890..

Run the following commands:

apt-get update
apt-get install mysql-client -y

Remote connection command:

mysql -urds_admin -p -h YOUR-INTRANET-ADDRESS-OF-RDS -P3306

Password: Aliyun-test

image desc

2.6 Add data

Run SQL statements to create data tables and add instance data. Note that every SQL statement ends with a semicolon (;).

View the current database:

show databases;

image desc

The name of the created database labex is returned. Select labex and create a data table:

use labex;
create table user (id int, name char(11));

A data table named “user” is created in labex.

image desc

Insert a test data record and query the data in the data table:

insert into user values (1, 'aliyun');
select * from user;

image desc

This completes the creation and usage of an RDS for MySQL database.

Reminder:
Before you leave this lab, remember to log out your Alibaba RAM account before you click the ‘stop’ button of your lab. Otherwise you’ll encounter some issue when opening a new lab session in the same browser:

image desc image desc

3. Experiment conclusion

This experiment is designed to build a relational database through RDS. RDS for MySQL is used as an example. The process of building the relational database is summarized as follows:

  1. Create an RDS instance
  2. Set a whitelist
  3. Apply for an Internet address
  4. Create an account and a database
  5. Remotely log on to the RDS instance
  6. Run SQL commands in the RDS instance

The building process is simple. I hope you can understand the knowledge points in this experiment.