By Jessie Angelica,Solution Architect Intern
Data Transmission Service supports data migration and data synchronization between data engines, such as relational database, NoSQL, data warehouses, and OLAP. With Data Transmission Service (DTS), you can implement the following business scenarios: data migration, remote real time data backup, real time data integration and cache refresh. The Data Transmission Service (DTS) supports incremental data transfers from on-premises to the cloud and from cloud to cloud, and helps you migrate data with virtually no downtime.
This blog focused on Data Synchronization which used to synchronize data in real-time between two data stores. Usually, this is used with Online Transaction Processing to Online Analytical Processing (OLTP to OLAP.) Typical scenarios include active geo-redundancy, geo-disaster recovery, zone-disaster recovery, cross-border data synchronization, cloud business intelligence (BI) systems, and real-time data warehousing. It can be Schema synchronization, Full data synchronization, and Incremental data synchronization.
1). Go to the ApsaraDB RDS console
2). Create and differentiate the two instances by renaming them to RDS_A and RDS_B.
3). Click Configure Whitelist in Basic Information side and configure the whitelist to 0.0.0.0/0
4). Click Apply for Internet Public Endpoint in Database Connection
5). Create Account in RDS_A by filling the Database Account name, password, and choose Privileged Account and Click Create.
6). Then, create the same things on RDS_B.
7). Create Database in RDS_A by filling the database name and choose utf8
1). Log on to your ECS. Enter the following command and view the internal network address of ECS
2). Enter command "vim /etc/hosts" and Replace YOUR-PRIVATE-IP and YOUR-HOST-NAME with your own
YOUR-PRIVATE-IP YOUR-HOST-NAME
3). Update the apt installation source:
4). Install the dependency package of the MySQL client and Python dependency package of MySQL
5). Run the following command to connect to the database of the RDSA instance. Remember to replace YOUR-RDS-INTERNET-ADDRESS with the public IP address of your RDS_A instance.
mysql -uYOUR-DATABASE -hYOUR-RDS-INTERNET-ADDRESS -pYOUR-PASSWORD
6). Switch to your database and create a table
7). Run the "vim data.py" and copy the following content to the file used to add data to your database.
8). Execute the data.py script:
9). Run the "vim select.py" command, and copy the following content to the file used to query the data volume of the info table in the database of the RDS_A instance.
10). Execute the following command, then the info table in the RDS_A currently has a total of 1,000 data records.
1). Go to Data Transmission Service.
2). Create task in the data synchronization task. Configure the source database and target database settings according this following figure.
3). Select your database and click Next
4). Click Next: Save Task Settings and Precheck.
5). Click Purchase, then Click Buy and Start
After initialization is complete, the synchronization link enters the Synchronizing state, and the synchronization link between the RDS_A and the RDS_B is fully established.
1). Return to the CLI terminal and enters this following command.
mysql -uYOUR-DATABASE-NAME -hYOUR-RDS_B-INTERNET-ADDRESS -pYOUR-PASSWORD
The number of data records is 1,000, which indicates that data is successfully synchronized from RDS_A.
2). Run the following command to execute the data.py script, which inserts 1,000 data records to RDS_A:
After the data is successfully inserted, RDS_A has a total of 2,000 data records.
3). Run the following command to query the data volume again:
The number of data records in RDS_B now changes to 2,000, which indicates that your real-time synchronization task is successfully implemented.
4). Return to the DTS console and release the real-time synchronization task by click Delete Task
5). Return to the CLI terminal and run the following command to execute the data.py script, which inserts 1,000 more data records to RDS_A:
After the data is successfully inserted, RDS_A has a total of 3,000 data records, but the number of data records in RDS_B is still 2,000. It means the synchronization task is already deleted and data is no longer synchronized between two RDS instances.
100 posts | 17 followers
FollowApsaraDB - March 15, 2024
Alibaba Clouder - December 29, 2020
Alibaba Clouder - March 1, 2021
ApsaraDB - March 26, 2024
ApsaraDB - May 15, 2023
Data Geek - May 10, 2024
100 posts | 17 followers
FollowAn on-demand database hosting service for MySQL with automated monitoring, backup and disaster recovery capabilities
Learn MoreSupports data migration and data synchronization between data engines, such as relational database, NoSQL and OLAP
Learn MoreAlibaba Cloud PolarDB for MySQL is a cloud-native relational database service 100% compatible with MySQL.
Learn MoreTair is a Redis-compatible in-memory database service that provides a variety of data structures and enterprise-level capabilities.
Learn MoreMore Posts by Alibaba Cloud Indonesia