MySQL Migration Synchronization to StarRocks
NineData data replication supports the synchronization of structure, full data, and incremental data from MySQL to StarRocks data sources.
Feature Introduction
NineData data replication supports high-performance replication of structure, full data, and incremental data between data sources. For MySQL data sources, it also provides bidirectional replication, enabling the quick construction of geo-distributed active-active business architectures.
- Structure: Supports the replication of object structures between homogeneous and heterogeneous data sources, greatly reducing the barrier to data replication between two sources.
- Full Data: Achieves row-level concurrent batch replication through intelligent data sharding, effectively ensuring replication performance. The independently developed novel breakpoint resume technology ensures the accuracy of data in tables without primary keys.
- Incremental Data: Supports incremental data replication of full object types DML|DDL, combined with transaction-level concurrency, hotspot merging, and other technologies to provide robust replication performance while ensuring transaction consistency.
- Bidirectional Real-time Data Replication (only between MySQL instances): Direct bidirectional replication of data between multiple nodes ensures that all node data remains up-to-date.
With the above features, it is easy and efficient to achieve scenarios such as full|incremental data replication, full|incremental data migration, full|incremental data synchronization, data integration, and seamless migration without downtime, providing enterprises with flexible and reliable data replication solutions.
Background Information
Apache StarRocks is a high-performance, real-time analytical database based on the MPP architecture, known for its ultra-fast and easy-to-use features. It has become a popular data warehouse product in China, in addition to ClickHouse and Doris.
StarRocks is built based on the Doris version and has been developing as an independent branch since 2021. Currently, many enterprises choose to build reporting analysis systems, enterprise data warehouses, and ad-hoc query analysis based on StarRocks. Based on these platform capabilities, applications such as user behavior analysis, AB testing platforms, log retrieval analysis, user profile analysis, and order analysis can be constructed.
As a data warehouse, enterprises need to process various source data through ETL before warehousing for data analysis. Relational databases, due to their extensive application scenarios and scale, have also become the core data source for StarRocks data integration.
NineData provides end-to-end data replication capabilities to help enterprises quickly achieve real-time replication of MySQL to StarRocks, enhancing the value of data applications.
Prerequisites
The source and target data sources have been added to NineData. For details on how to add them, please refer to Adding Data Sources.
The source database type is MySQL or a MySQL-like database, such as MySQL, MariaDB, PolarDB MySQL, TDSQL-C, GaussDB MySQL, Aurora, etc.
The target database is StarRocks 3.1, 3.0, 2.5, 2.4, 2.3, 2.2, 2.1, 2.0.
For incremental replication, the source data source must have Binlog enabled, and the Binlog-related parameters are set as follows:
binlog_format
=ROW
binlog_row_image
=FULL
tipIf the source data source is a replica database, to ensure the acquisition of complete Binlog logs, the
log_slave_updates
parameter also needs to be enabled.You must have the following permissions for the source and target data sources.
Replication Type Source Data Source Target Data Source Full Replication SELECT TABLE-related permissions (ALTER, DROP, SELECT, INSERT, UPDATE, DELETE) Incremental Replication SELECT, REPLICATION CLIENT, REPLICATION SLAVE TABLE-related permissions (ALTER, DROP, SELECT, INSERT, UPDATE, DELETE)
Usage Limitations
- The data replication feature is only for user databases in the data source, and system databases will not be replicated. For example, system libraries such as
information_schema
,mysql
,performance_schema
,sys
in MySQL-type data sources will not be replicated. - Before performing data synchronization, it is necessary to assess the performance of the source and target data sources, and it is recommended to perform data synchronization during off-peak business hours. Otherwise, the full data initialization will occupy certain read and write resources of the source and target data sources, leading to increased database load.
- It is recommended to ensure that each table in the synchronization object has a primary key or unique constraint, and the column names are unique, otherwise, the same data may be synchronized repeatedly.
Operation Steps
NineData’s data replication product has been commercialized. You can still use 10 replication tasks for free, with the following considerations:
Among the 10 replication tasks, you can include 1 task, with a specification of Micro.
Tasks with a status of do not count towards the 10-task limit. If you have already created 10 replication tasks and want to create more, you can terminate previous replication tasks and then create new ones.
When creating replication tasks, you can only select the you have purchased. Specifications that have not been purchased will be grayed out and cannot be selected. If you need to purchase additional specifications, please contact us through the customer service icon at the bottom right of the page.
Log in to the NineData Console.
Click on in the left navigation bar.
On the page, click on in the upper right corner.
On the tab, configure according to the table below and click .
Parameter Description Enter the name of the data synchronization task. To facilitate subsequent search and management, please use a meaningful name. Up to 64 characters are supported. The data source where the synchronization object is located. The data source that receives the synchronization object. Select the content to be replicated to the target data source. - : Only synchronize the database table structure of the source data source, without synchronizing data.
- : Synchronize all objects and data of the source data source, that is, full data replication.
- : After the full synchronization is completed, incrementally synchronize based on the logs of the source data source. Click on the icon to deselect some operation types according to your needs. After deselection, these operations will be ignored in the incremental synchronization.
(Required when is selected) - : Stop the task when the same name table is detected during the pre-inspection phase.
- : Send a prompt and continue the task when the same name table is detected during the pre-inspection phase. During the structure replication, ignore the table with the same name. If you also perform data replication, the data will be appended to the table with the same name without overwriting the existing data.
- : Send a prompt and continue the task when the same name table is detected during the pre-inspection phase. During the structure replication, delete the table with the same name in the target database and re-replicate the table structure based on the source database. If you also perform data replication, the data will be written after the table structure replication is completed.
- (Optional when both structure and data replication are performed): Send a prompt and continue the task when the same name table is detected during the pre-inspection phase. During the structure replication, retain the table structure in the target database, and clear the data in the table with the same name at the beginning of the data replication, then replicate from the original table again.
(Required when is not selected) - : Stop the task when data is detected in the target table during the pre-inspection phase.
- : Ignore the data when it is detected in the target table during the pre-inspection phase, and append the other data.
- : Delete the data when it is detected in the target table during the pre-inspection phase, and re-enter it.
On the tab, configure the following parameters, and then click .
Parameter Description Select the content to be replicated. You can choose to replicate all content from the source database, or you can choose , select the content to be replicated in the list, and click > to add it to the right list. On the tab, select different operations based on the selected replication type.
Including : Configure the table name after the target table is synchronized to the target data source, and click .
tipYou can click on the on the right side of the page to customize the name of the column name synchronized to the target data source. In addition, you can also set , and only data that meets the filtering conditions will be synchronized to the target data source. For example, for the test data employees table, set the filtering condition to
emp_no>=10005
, then data with emp_no column less than 10005 will not be synchronized to the target data source.Not including : The system defaults to selecting the database with the same name in the target data source. If it does not exist, you need to manually select the target library. The table name and column name in the target library need to be consistent with the synchronization object. If they are not consistent, you can also manually map the table name and column name.
On the tab, wait for the system to complete the pre-inspection, and after the pre-inspection is passed, click .
tip- You can check . After the synchronization task is completed, automatically start the data consistency comparison based on the source data source to ensure that the data on both sides is consistent. Depending on the you selected, the timing for starting is as follows:
- : Start after the structure replication is completed.
- +, : Start after the full replication is completed.
- ++, : Start when the incremental data is consistent with the source data source for the first time and is 0 seconds. You can click to view the synchronization delay on the page.
- If the pre-inspection does not pass, you need to click in the column on the right side of the target inspection item to investigate the cause of the failure, manually fix it, and then click to re-execute the pre-inspection until it passes.
- If the is , you can fix or ignore it according to the specific situation.
- You can check . After the synchronization task is completed, automatically start the data consistency comparison based on the source data source to ensure that the data on both sides is consistent. Depending on the you selected, the timing for starting is as follows:
On the page, it prompts , and the synchronization task starts running. At this time, you can perform the following operations:
- Click to view the execution of each stage of the synchronization task.
- Click to return to the task list page.
View Synchronization Results
Log in to the NineData Console.
Click on in the left navigation bar.
Click on the of the target synchronization task on the page, and the page description is as follows.
No. Function Description 1 Synchronization Delay The data synchronization delay between the source data source and the target data source, 0 seconds means there is no delay between the two ends. At this time, you can choose to switch the business to the target data source to achieve smooth migration. 2 Configure Alerts After configuring the alert, the system will notify you through the method you choose when the task fails. For more information, please refer to Introduction to Operations Monitoring. 3 More - Pause: Pause the task, only tasks in the Running status are optional.
- Terminate: End the unfinished or listening (i.e., incremental synchronization) task. After terminating the task, it cannot be restarted, please proceed with caution. If the synchronization object contains triggers, the trigger replication option will pop up, please choose as needed.
- Delete: Delete the task, the task cannot be restored after deletion, please proceed with caution.
4 Structure Replication (Displayed in scenarios including structure replication) Display the progress and detailed information of structure replication. - Click on the Logs on the right side of the page: View the execution logs of structure replication.
- Click on the on the right side of the page: View the latest information.
- Click on View DDL in the Operation column on the right side of the target object in the list: You can view the SQL replay.
5 Full Replication (Displayed in scenarios including full replication) Display the progress and detailed information of full replication. - Click on the Monitoring on the right side of the page: View the monitoring metrics during the full replication process. During the full replication process, you can also click on the Throttling Settings on the right side of the monitoring metric page to limit the rate of writing to the target data source per second. The unit is rows/second.
- Click on the Logs on the right side of the page: View the execution logs of full replication.
- Click on the on the right side of the page: View the latest information.
6 Incremental Replication (Displayed in scenarios including incremental replication) Display the monitoring metrics of incremental replication. - Click on on the right side of the page: View the operations currently being executed by the current replication task, including:
- : The replication task is executed by multiple threads for replication operations, displaying the current thread number.
- : Details of the SQL statement currently being executed by the current thread.
- : The response time of the current thread, if this value increases, it means that the current thread may be stuck for some reason.
- : The timestamp when the current thread started.
- : The current status of the thread.
- Click on the Throttling Settings on the right side of the page: Limit the rate of writing to the target data source per second. The unit is rows/second.
- Click on the Logs on the right side of the page: View the execution logs of incremental replication.
- Click on the on the right side of the page: View the latest information.
7 Modify Object Display the modification records of the synchronization object. - Click on Modify Synchronization Object on the right side of the page to configure the synchronization object.
- Click on the on the right side of the page: View the latest information.
8 Data Comparison Display the results of data comparison between the source data source and the target data source. If you have not enabled data comparison, please click on Enable Data Comparison on the page. - Click on Re-compare on the right side of the page: Re-initiate the comparison between the current source and target data.
- Click on the Logs on the right side of the page: View the execution logs of consistency comparison.
- Click on the Monitoring (only displayed when data comparison is displayed) on the right side of the page: View the trend chart of comparison RPS (number of records compared per second). Click on Details to view records from earlier times.
- Click on in the Operation column on the right side of the comparison list (displayed when inconsistent): View the comparison details of the source and target ends.
- Click on in the Operation column on the right side of the comparison list (displayed when inconsistent): Generate a change SQL, you can directly copy this SQL to the target data source for execution, and modify the inconsistent content.
9 Expand Display the detailed information of the current replication task, including Replication Type, Replication Object, Start Time, etc.
Appendix 1: MySQL and StarRocks Data Type Mapping Table
During the data replication process, MySQL data types are mapped to corresponding StarRocks data types.
Category | MySQL Data Type | StarRocks Data Type |
---|---|---|
Numeric | TINYINT | SMALLINT |
TINYINT UNSIGNED | SMALLINT | |
SMALLINT | SMALLINT | |
SMALLINT UNSIGNED | INT | |
MEDIUMINT | INT | |
MEDIUMINT UNSIGNED | INT | |
INT | INT | |
INT UNSIGNED | BIGINT | |
BIGINT | BIGINT | |
BIGINT UNSIGNED | LARGEINT | |
BIT(M) | SAMLLINT | |
DECIMAL | DECIMAL | |
NUMERIC | DECIMAL | |
FLOAT | FLOAT | |
DOUBLE | DOUBLE | |
BOOL,BOOLEAN | BOOLEAN | |
DATE AND TIME | DATE | DATE |
DATETIME[(fsp)] | DATETIME | |
DATETIME[(fsp)] | DATETIME | |
TIME[(fsp)] | VARCHAR | |
YEAR[(4)] | INT | |
STRING | CHAR/VARCHAR | CHAR |
VARCHAR | VARCHAR | |
BINARY/VARBINARY | BINARY/VARBINARY | |
TINYTEXT/TEXT/MEDIUMTEXT/LONGTEXT | STRING | |
TINYBLOB/BLOB/MEDIUMBOLB/LONGBLOB | STRING | |
ENUM | STRING | |
SET | STRING | |
JSON | JSON | JSON |
Appendix 2: Pre-inspection Item Overview
Check Item | Check Item Description | Does Not Pass to Prevent Task Continuation | Failure Reason and Repair Strategy |
---|---|---|---|
Source Data Source Connection Test | Test the connectivity of the source data source | Yes |
|
Target Data Source Connection Test | Test the connectivity of the target data source | Yes |
|
Source Data Source Permission Check | Check the account permissions of the source data source | Yes |
|
Target Data Source Permission Check | Check the account permissions of the target data source | Yes |
|
Whether the Source Database has Binlog Enabled | Check if the Binlog is enabled for the source database | Yes |
|
Whether the Source Database binlog format supports row mode | Check if the binlog format of the source database is row | Yes |
|
Whether binlog_row_image is full | Check if the binlog_row_image of the source database is full | Yes |
|
Check for Existing Objects with the Same Name | Check if there are objects with the same name as the objects to be replicated in the target |
|
|
Data Existence Check | Check if the replication object in the target data source already has data |
|
|