Adolph
Engineer
Engineer
  • UID623
  • Fans4
  • Follows1
  • Posts72
Reads:51738Replies:0

A Simple Tutorial on Alibaba Cloud RDS Usage

Created#
More Posted time:Jul 14, 2016 14:05 PM
This tutorial uses RDS for MySQL as an example. The procedure for RDS for MS SQL is similar. In this example, the data for migration and import is a forum named DiscuzX and the tool is Navicat for MySQL.  
  
Purchasing  
It is very easy to buy an RDS instance. Just go to the RDS area on the Alibaba Cloud website and find a configuration set that suits you.  
You can select three parameters, Memory, Storage Space and Connection Quantity, based on your needs. For example, the website I needed to migrate gets about 300,000 page views per day and has a maximum of 113 MySQL connections during the past year. The database adds up to 1.8 GB in size. Therefore, I chose the New Type II RDS for MySQL.  
A storage space equivalent to your need is enough. If the connection limit is too low, the error "too many connections" may occur. In this case, use the data presented above for reference. For a new website, I suggest that you buy the minimum configurations. You can easily upgrade the configuration as needed at any time.  
Currently Alibaba Cloud RDS provides MySQL version 5.1.  
  
Setting RDS  
After purchasing and activating a suitable plan, log in to the Alibaba Cloud console to view your RDS instances.
  
In this example, we have purchased one RDS instance. In this instance, you can create MySQL databases and accounts. For example, New Type II that I purchased supports up to 50 database accounts and 200 databases. It is enough for my website. These databases share the memory, storage space, and maximum connections in New Type II.  
  
Next, we need to configure the RDS.
1. Create Databases and Users
On the console, in "Database Management", select Create Database. This will open the Add Database page, as shown below. You can select a database name and character set as needed. RDS supports UTF-8, GBK, and Latin-1 character sets. I chose GBK encoding for my website. Then, set database account and password. The password should not be too simple. Select "Read/Write" for the account type. This is shown in the figure below.  
  
2. Switch the Connection Mode
If you connect to RDS over an Alibaba Cloud server, select Intranet mode; otherwise, select Internet mode. You can switch the connection mode in the top-right corner of the console.  
3. Set the IP White List
You can set the IP addresses that are allowed to access your RDS instance. This is very useful for security purposes. Here, simply enter the IP address of the server to be allowed to access the RDS. In Internet mode, enter the Internet IP address; in intranet mode, enter the intranet IP address. Entering % will allow access by all IP addresses. However, I do not recommend doing this.  
After configuring the above settings, you can start using RDS.  
  
Data Migration  
Alibaba Cloud provides a set of migration tools, which are a bit difficult for novices. You do not have to use it if your database is small. I use Navicat for MySQL, a simple tool for novices.  
My database is only 1.8 GB, so the migration is easy. First, I installed Navicat on the source server. Then, I established connections on Navicat respectively to the existing database and to the RDS. Remember to add the IP address of the server that runs Navicat to the IP white list.  
  
Then, right-click the existing database and select "Data Transmission".  
  
In the pop-up Data Transmission interface, select the database you currently use as the source database and check all the "Tables" in the database objects. If you use views or other objects, check them as well. Select a database you have created in RDS as the target database. Then, click Start to transmit the data. Next, make yourself a cup of coffee and wait for the process to finish.  
  
Other Deployment Tasks  
The previous steps migrated my database to Navicat. If you do not need to migrate your programs to the Alibaba Cloud server, just modify your programs' database connection parameters. For the DiscuzX2.5 example, I need to modify the database connection address, username, password, and database name in the /config/config_global.php, /config/config_ucenter.php, and /uc_server/data/config.inc.php files. After doing this, I can use the program.  
  
A Few More Things  
Database migration is easy because the RDS is basically compatible with all native operations of MySQL, so it will not impose any additional costs on our operations. Of course, there are a few details we need to consider:
1. RDS is not 100% compatible with MySQL and MS SQL, especially regarding the storage process, views, and other advanced functions. For any problem regarding compatibility, you may consult with Alibaba Cloud customer service before purchasing the product.  
2. The RDS has a strict requirement for SQL statements. Standardize your SQL statements to avoid unnecessary errors.  
3. Although the RDS supports both intranet and Internet connections, it is suggested that you use it with an Alibaba Cloud server. Connecting to the RDS from another provider's server will produce a cost for Internet traffic and noticeable connection delay.
[Adolph edited the post at Mar 28, 2017 11:31 AM]
Guest