×
Community Blog How to Use an AsparaDB for RDS Instance to Store the Data of Your Application Server

How to Use an AsparaDB for RDS Instance to Store the Data of Your Application Server

This article explains how to use an AsparaDB for RDS instance to store the data of your application server.

By Alain Francois

When you host your application on the cloud, you need to store your data effectively on a secure and fast database management tool that can meet some interesting requirements. We recommend not deploying the database management tool and the application server on the same instance to ensure security and data availabilities. It will be more interesting if you have a fully managed solution for your database instance. Alibaba Cloud offers AsparaDB for RDS as a database management system. You can deploy your application server on the cloud and connect it to an AsparaDB for RDS to keep your data on a fully-managed database service that helps you manage and administer your relational databases on the cloud.

What Is AsparaDB for RDS?

ApsaraDB for RDS is an online database service that handles some of the administrative tasks associated with managing a database. It is stable, reliable, scalable, and built on top of the Apsara Distributed File System and high-performance SSDs of Alibaba Cloud. AsparaDB for RDS supports many popular Relational Database Management System (RDBMS) engines, including MySQL, SQL Server, PostgreSQL, PPAS (highly compatible with Oracle), and MariaDB. The service allows you to quickly build a stable and reliable database system and provides a portfolio of solutions for disaster recovery, backup, restoration, monitoring, and migration to facilitate database operations and maintenance.

Why Should You Use Aspara RDS?

ApsaraDB for RDS can also protect against network attacks and intercept SQL injections, brute force attacks, and other types of database threats. It also offers some advantages compared with user-created databases and has significant advantages in cost-effectiveness, availability, reliability, ease of use, and performance:

  • Supports five databases engines – AsparaDB for RDS MySQL, SQL Server, PostgreSQL, PPAs (compatible with oracle), and MariaDB TX
  • High performance, including suggestions on parameter and SQL query optimization
  • High-availability architecture and multiple disaster recovery solutions
  • High security with traffic cleaning against DDoS attacks, IP whitelists for remote access, multiple firewall layers that block various network attacks to guarantee data security
  • RDS instances management, such as creating instances, databases, and accounts, and configuring the network through the console, CLI, SDK, and API
  • Log on to an RDS instance using DMS and develop databases on a web-based GUI or by using common database clients, such as MySQL Workbench, SQL Server Management Studio (SSMS), and pgAdmin
  • Support of a wide range of features, such as instance management (including instance creation and specification changes), backup and restoration, log audit, and monitoring and alerting

Running an AsparaDB for RDS Instance

You need an account to run an Alibaba Cloud AsparaDB for RDS instance. If you don’t have an account, you can get a coupon to start a new account during the Mega March Sale.

Log into your account and go to the AsparaDB service:

1

You can see the homepage:

2

Create a new instance:

3

You will need to choose the RDMS engine during the creation of the instance, and we will choose _PostgreSQL_. We will connect our RDS instance to an ECS instance, so we need to create our RDS instance in the same region and zone of the ECS instance the region:

4

Now, we need to configure the VPC setting of the instance. Make sure to take the good VPC configuration of the AsparaDB for RDS instance. We will select the same VPC as the ECS instance:

5

Complete the order:

6

Now, you can go back to the AsparaDB console and overview the new instance. After some time, you will be able to see the status updating from Creating to _Running_:

7

You can also rename the instance or click it to see the settings. You can have a detailed page of the new instance:

8

The new instance doesn't have any information yet by default. It means you need to create a user account for the database to log in to the instance. Go and create the user DB account. The account should have administrator privileges so it can be used to operate on the database:

9

Create the database on which you will connect:

10

Once created, you can connect to the database instance through an RDM:

11

You will be prompted to enter the information regarding the database user and the password:

12

You are connected to your AsparaDB for RDS instance. You can see some new information and which one can be used to connect to the database from an ECS instance:

13

Now that your AsparaDB for RDS instance is running, you need to connect your application server to the database instance to store all your data.

Connecting Your Application Server to the AsparaDB for RDS Instance

You need to go back to the AsparaDB console to connect your application server to your AsparaDB for RDS instance. In this guide, we will try to connect our SonarQube server to the PostgreSQL RDS instance instead of a local database service running on the same ECS.

Normally, since RDS and ECS instances are in the same VPC, they could be able to communicate. However, for some security, a RDS instance is only reachable from the servers whose IPs have been added on a whitelist. You need to add the IP address of your ECS instance to the RDS whitelist:

14

To connect your Sonarqube service to a remote database, you need to indicate the IP address of the database server. But you should have noticed that the information was not available. There is a notion of Internal Endpoint that can be considered as a virtual domain name (mapped to an IP address) to use for a remote connection. Its value can be long, so you can edit it to something easy to remember by default. If you want to connect to the RDS instance over an internal network, you need to use its internal endpoint:

15

Edit it if you want to make it simple. After you change an endpoint or port number of an RDS instance, the change immediately takes effect without restarting the RDS instance:

16

You can connect to the ECS instance and try a command-line connection to the PostgreSQL RDS database instance:

$ psql -U userdb -h pgm-demo-enpoint.pgsql.germany.rds.aliyuncs.com --d appsdb -W

17

After confirming that your ECS instance can communicate with your RDS instance, you can run your application server and indicate the necessary information to connect the database. In our case, we are running a SonarQube service with Docker. Then, we start our container with the following command:

$ docker run -d --name sonarqube-demo \
    -e VIRTUAL_HOST=web-demo.com \
    -e VIRTUAL_PORT=9000 \
    -p 9000:9000 \
    -e SONAR_JDBC_URL="jdbc:postgresql://pgm-demo-enpoint.pgsql.germany.rds.aliyuncs.com:5432/appsdb" \
    -e SONAR_JDBC_USERNAME=userdb \
    -e SONAR_JDBC_PASSWORD='34zvTKjis097BB' \
    -v /opt/volume/sonarqube-demo/conf:/opt/sonarqube/conf \
    -v /opt/volume/sonarqube-demo/extensions:/opt/sonarqube/extensions \
    -v /opt/volume/sonarqube-demo/logs:/opt/sonarqube/logs \
    -v /opt/volume/sonarqube-demo/data:/opt/sonarqube/data \
    sonarqube:lts-community

If SonarQube can't communicate with the remote database, it will not start, and you will face some errors when checking the logs. We will check the logs and look at the line regarding the connection to the database:

$ docker logs -f sonarque-demo

18

You can see through the logs that sonar was able to connect to the RDS instance. You can access your application service through the browser http://domain.com:

19

Our application is working and connected to our RDS instance. After changing an endpoint or port number of an RDS instance, you must change them on your application. If you do not change them on your application, your application cannot connect to the RDS instance.

Conclusion

You gain more benefits using AsparaDB for RDS to store the data of your application server. You have protection against DDoS attacks, SQL injections, etc. Since the service is managed, it means you will have less stress. You can also secure your RDS instance by adding it to a security group and creating more security rules.

Related Articles

How to Set up Alibaba Cloud ApsaraDB for MongoDB for Your NoSQL Database Requirements

Alibaba Cloud ApsaraDB for MongoDB is a secure and elastically scalable MongoDB database service. The service is relatively easy-to-set up.

How to Install SonarQube and PostgreSQL with Docker on Alibaba Cloud ECS Instance

SonarQube is a cross-platform and web-based tool used for continuous source code inspection that can be integrated into platforms, such as GitHub, GitLab, BitBucket, and more. This article explains how to install SonarQube and PostgreSQL using Docker on your ECS instance.

How to Create a VPC and Configure a Security Group to Protect Your Alibaba Cloud Instances.

Alibaba Cloud offers a Virtual Private Network (VPC), which is a secure and isolated private cloud that contains your Elastic Compute Services (ECS) instances within a public cloud. You can access a VPC publicly from the Internet and secure traffic by configuring a security group.

0 0 0
Share on

Alibaba Cloud Community

474 posts | 24 followers

You may also like

Comments

Alibaba Cloud Community

474 posts | 24 followers

Related Products