-->

Build a Relational Database Using RDS

 

Build a Relational Database Using RDS

1. Introduction

1.1 Key points

This lab is designed to build a relational database through RDS. RDS for MySQL is used as an example. After completing this lab, 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 labal 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

If you encounter some differences between the real labal 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 labal 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 lab environment

If you have just completed a lab session, ensure you log out of your Alibaba Cloud account before starting a new lab. This prevents issues when opening a new lab session in the same browser.

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

image desc

Once the lab environment is set up, the system auto-deploys essential resources for your lab, such as ECS and RDS instances, Server Load Balancers, OSS buckets, etc. You'll also receive login credentials for the Alibaba Cloud Web console.

image desc

A countdown timer starts once the lab environment is ready. You have two hours to complete the lab. Pay attention to the remaining time and plan accordingly.

Next, click Open the Console to access the Alibaba Cloud RAM login page. Use the Username and Password provided by the system to log in to Alibaba Cloud and view the relevant resources.

Copy and enter the provided account username and click Next.

image desc
 

Copy and enter the provided password and click Log On.

image desc
 

After successfully logging in, click OK to view the main console page.

 
image desc

Go to the RDS management page:

image

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

image

Wait until the RDS instance is successfully created.

image

2.2 Set a whitelist

Add the ECS intranet IP address to the RDS whitelist.

image

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

Click Create Whitelist.

image

Click Add Internal IP Addresses of ECS Instances.

image

Set the name to "labex".

image
 
image

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

2.3 Create a database and an account

Refer to the figure below and click Create Database.

image

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

2.4 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 (Silicon Valley) region. Click it to go to the ECS console as shown in the following picture.

image

Click on the Instances button in the left menu bar to switch to the instance console.

image

If the console prompts you that no instances were found in the current region, don't worry, this is because the instance we started is not in the current default region. Click on the region switch button above and switch to the US (Silicon Valley) region.

The same applies when using other services.

image

In the ECS console, locate the row that contains the target ECS instance and click Connect in the Actions column, as shown in the following figure.

image

Now, Alibaba Cloud provides us with a very useful tool called Workbench. It is a terminal program that runs in the browser and can seamlessly connect to our instance, as well as provide various advanced features.

If you want to use it, click the Sign in now button.

image

The default account name and password of the ECS instance:
Account name: root
Password: nkYHG890..

In the pop-up window, you only need to enter the password for your instance, as all other configurations are already associated with this instance by default.

image

Then click OK to connect to the instance. As shown in the following figure, you have successfully logged in to the instance.

image

You can also choose the tool you prefer to connect to the ECS instance. For details of remote logon, refer to logon.

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

2.5 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;

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.

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

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

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
 
image desc

3. Experiment conclusion

This lab 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 lab.

Anda mungkin menyukai postingan ini

  1. Untuk menyisipkan sebuah kode gunakan <i rel="pre">code_here</i>
  2. Untuk menyisipkan sebuah quote gunakan <b rel="quote">your_qoute</b>
  3. Untuk menyisipkan gambar gunakan <i rel="image">url_image_here</i>
Hello Welcome