Method and related device for automatic remote data synchronization in a multi-tenant environment

By using a data synchronization server to convert the log change data of the tenant database into JSON format in a multi-tenant environment and then convert it into SQL statements for the data middle platform database, the problem of tenant data not being able to be automatically synchronized to the data middle platform in existing technologies is solved, and automated, real-time data synchronization is achieved.

CN115757428BActive Publication Date: 2026-06-02DONGFANG HEZHI DATA TECH (GUANGDONG) CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
DONGFANG HEZHI DATA TECH (GUANGDONG) CO LTD
Filing Date
2022-12-01
Publication Date
2026-06-02

AI Technical Summary

Technical Problem

In existing technologies, tenant data in a multi-tenant environment cannot be automatically synchronized to the data platform remotely. Traditional synchronization methods are cumbersome and cannot achieve real-time synchronization. Existing tools require a lot of configuration or coding to implement.

Method used

This paper provides a method for automatic remote data synchronization in a multi-tenant environment. The method involves receiving synchronization requests through a data synchronization server, establishing a connection between the tenant database and the data platform database, converting log change data into a general JSON format statement, and then converting it into an SQL statement supported by the data platform database for real-time synchronization.

Benefits of technology

It enables automatic, real-time data synchronization between the tenant database and the data platform database, reducing manual operations, improving synchronization efficiency and flexibility, and adapting to different database types.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115757428B_ABST
    Figure CN115757428B_ABST
Patent Text Reader

Abstract

The application discloses a kind of methods and related equipment for automatic remote data synchronization under multi-tenant environment, it is related to data processing technical field, the method includes: when SAAS platform creates tenant database, data synchronization server receives the data synchronization request sent by the SAAS platform, respectively with the tenant database and data center database connection is established;The data synchronization server obtains the log change data of the tenant database, is converted into general JSON format sentence, and is saved into local database;The data synchronization server converts the general JSON format sentence into the SQL sentence that the data center database supports, and the SQL sentence is sent to the data center database real-time reading is saved, to complete the remote data synchronization of the tenant database and the data center database.The application realizes the automatic remote data synchronization of tenant database and data center database in real time dynamically according to new tenant.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data processing technology, and in particular to a method, system, terminal, and computer-readable storage medium for automatic remote data synchronization in a multi-tenant environment. Background Technology

[0002] In a multi-tenant SaaS (Software-as-a-Service) platform, compared to traditional software delivery models that require on-premises client deployment, SaaS software is deployed in the cloud, allowing enterprises to access its features simply by registering an enterprise account. This requires real-time synchronization of tenant business system data to a data platform (a module within the SaaS system with big data processing capabilities, primarily aggregating data from various systems on the SaaS platform for statistical analysis and data sharing between systems) for data analysis. However, existing data synchronization solutions suffer from the following problems:

[0003] Traditional data synchronization methods require manual offline execution. After a tenant registers an account on the platform, platform operations personnel must manually input the database address and relevant account information to perform the synchronization, making the process cumbersome. Furthermore, current synchronization methods either use offline methods, like Alibaba's open-source DataX tools, which require extensive configuration before batch synchronization and cannot achieve real-time synchronization; or, while FlinkCDC can achieve real-time data synchronization, it only implements a codebase capable of real-time synchronization. To implement the actual synchronization functionality, developers need to write code specifically for the database to be synchronized, making it impossible to dynamically and automatically create tenant databases and synchronize them to the data platform in real-time based on newly created tenants.

[0004] Therefore, existing technologies still need to be improved and developed. Summary of the Invention

[0005] The main objective of this invention is to provide a method, system, terminal, and computer-readable storage medium for automatic remote data synchronization in a multi-tenant environment, aiming to solve the problem that tenant data cannot be automatically synchronized to the data platform remotely in the prior art.

[0006] To achieve the above objectives, the present invention provides a method for automatic remote data synchronization in a multi-tenant environment, the method comprising the following steps:

[0007] After the SaaS platform creates the tenant database, the data synchronization server receives the data synchronization request sent by the SaaS platform and establishes connections with the tenant database and the data middleware database respectively.

[0008] After the data synchronization server establishes connections with the tenant database and the data platform database respectively, the data synchronization server obtains the log change data of the tenant database, converts the log change data into a general JSON format statement, and saves it to the local database.

[0009] The data synchronization server converts the general JSON format statement into an SQL statement supported by the data platform database, and sends the SQL statement to the data platform database for real-time reading and saving, so as to complete the remote data synchronization between the tenant database and the data platform database.

[0010] Optionally, in the method for automatic remote data synchronization in a multi-tenant environment, after the SaaS platform creates a tenant database, the data synchronization server receives the data synchronization request sent by the SaaS platform and establishes connections with the tenant database and the data platform database respectively.

[0011] When the SaaS platform creates a tenant database, the data synchronization server receives the data synchronization request sent by the SaaS platform and establishes connections with both the tenant database and the data platform database, specifically including:

[0012] When it is detected that a tenant has completed the registration of a tenant account on the SaaS platform and the SaaS platform has created the tenant database, the data synchronization server obtains the initialization success information of the tenant database.

[0013] The data synchronization server receives a data synchronization request sent by the SaaS platform, and establishes connections with the tenant database and the data middleware database respectively according to the data synchronization request.

[0014] Optionally, in the method for automatic remote data synchronization in a multi-tenant environment, after the data synchronization server establishes connections with the tenant database and the data platform database respectively, the data synchronization server obtains the log change data of the tenant database, converts the log change data into a general JSON format statement, and saves it to the local database.

[0015] After the data synchronization server establishes connections with both the tenant database and the data platform database, the data synchronization server obtains the log change data from the tenant database, converts the log change data into a general JSON format statement, and saves it to the local database. Specifically, this includes:

[0016] Once the data synchronization server establishes connections with the tenant database and the data platform database respectively, a data synchronization task is created.

[0017] After the data synchronization task is created by the data synchronization server, the data synchronization server listens for log changes in the tenant database and obtains the log change data of the tenant database.

[0018] Once the data synchronization server obtains the log change data, it converts the log change data into a general JSON format statement.

[0019] The data synchronization server saves the general JSON format statement to its local database.

[0020] Optionally, in the method for automatic remote data synchronization in a multi-tenant environment, the data synchronization server converts the general JSON format statement into an SQL statement supported by the data platform database, and sends the SQL statement to the data platform database for real-time reading and saving, so as to complete the remote data synchronization between the tenant database and the data platform database.

[0021] The data synchronization server converts the general JSON format statement into an SQL statement supported by the data platform database, and sends the SQL statement to the data platform database for real-time reading and saving, thereby completing the remote data synchronization between the tenant database and the data platform database, specifically including:

[0022] The data synchronization server converts the general JSON format statements saved in the local database into SQL statements supported by the data platform database, and sends the SQL statements to the data platform database for real-time reading and saving.

[0023] After the data synchronization server receives the information that the data middleware server has successfully read and saved the SQL statement, the remote data synchronization between the tenant database and the data middleware database is completed. The data synchronization server then deletes the SQL statement that was successfully read and saved by the data middleware database from the local database.

[0024] The data synchronization server converts the general JSON format statement into an SQL statement supported by the data platform database, and sends the SQL statement to the data platform database for real-time reading and saving. This process also includes:

[0025] When the data synchronization server receives information from the data middleware server that the SQL statement failed to be read and saved, it will retry.

[0026] If multiple retries still fail, synchronization is terminated, and the data synchronization server receives the synchronization error information returned by the data middleware server.

[0027] When the data synchronization server receives information from the data middleware server indicating that reading and saving the SQL statement failed, it will retry, specifically as follows:

[0028] When the data synchronization server receives information that the data middleware server failed to read and save the SQL statement, the data synchronization server resends the SQL statement to the data middleware database for real-time reading and saving.

[0029] Optionally, in the method for automatic remote data synchronization in a multi-tenant environment, the log change data is binary log change information of database table structure changes or table data changes in the tenant database.

[0030] Furthermore, to achieve the above objectives, the present invention also provides a system for automatic remote data synchronization in a multi-tenant environment, wherein the system for automatic remote data synchronization in a multi-tenant environment includes:

[0031] A synchronization module is created. After the SaaS platform creates a tenant database, the data synchronization server receives the data synchronization request sent by the SaaS platform and establishes connections with the tenant database and the data platform database respectively.

[0032] The data conversion module, after the data synchronization server establishes connections with the tenant database and the data platform database respectively, obtains the log change data of the tenant database, converts the log change data into a general JSON format statement, and saves it to the local database;

[0033] The data synchronization module, wherein the data synchronization server converts the general JSON format statement into an SQL statement supported by the data platform database, and sends the SQL statement to the data platform database for real-time reading and saving, so as to complete the remote data synchronization between the tenant database and the data platform database.

[0034] In addition, to achieve the above objectives, the present invention also provides a terminal, wherein the terminal includes: a data synchronization server, a memory, a processor, and a program for automatic remote data synchronization in a multi-tenant environment stored on the memory and executable on the processor. When the program for automatic remote data synchronization in a multi-tenant environment is executed by the processor, it implements the steps of the method for automatic remote data synchronization in a multi-tenant environment as described above.

[0035] In addition, to achieve the above objectives, the present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a program for automatic remote data synchronization in a multi-tenant environment, and when the program for automatic remote data synchronization in a multi-tenant environment is executed by a processor, it implements the steps of the method for automatic remote data synchronization in a multi-tenant environment as described above.

[0036] In this invention, after the SaaS platform creates a tenant database, the data synchronization server receives a data synchronization request sent by the SaaS platform and establishes connections with both the tenant database and the data platform database. Once connected to both databases, the server obtains log change data from the tenant database, converts it into a generic JSON format statement, and saves it to its local database. The server then converts the JSON statement into an SQL statement supported by the data platform database and sends it to the database for real-time reading and saving, thus completing the remote data synchronization between the tenant database and the data platform database. This invention establishes a generic data synchronization server based on a data synchronization service to provide external data synchronization services, synchronizing tenant database data to the data platform database. Tenants only need to send connection information between their tenant database and the data platform database to the data synchronization server to establish batch and real-time data synchronization between the tenant database and the data platform database. Initial batch synchronization is performed, followed by real-time synchronization. Attached Figure Description

[0037] Figure 1 This is a flowchart of a preferred embodiment of the method for automatic remote data synchronization in a multi-tenant environment according to the present invention;

[0038] Figure 2 This is an overall system framework diagram of the automatic remote data synchronization method in a multi-tenant environment according to the present invention;

[0039] Figure 3 This is a synchronization flowchart of the automatic remote data synchronization method in a multi-tenant environment according to the present invention;

[0040] Figure 4 This is a schematic diagram of a preferred embodiment of the system for automatic remote data synchronization in a multi-tenant environment according to the present invention;

[0041] Figure 5 This is a schematic diagram of a preferred embodiment of the terminal of the present invention. Detailed Implementation

[0042] To make the objectives, technical solutions, and advantages of this invention clearer and more explicit, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.

[0043] A preferred embodiment of the present invention describes a method for automatic remote data synchronization in a multi-tenant environment, such as... Figure 1 , Figure 2 and Figure 3 As shown, the method for automatic remote data synchronization in a multi-tenant environment includes the following steps:

[0044] Step S10: After the SAAS platform creates the tenant database, the data synchronization server receives the data synchronization request sent by the SAAS platform and establishes connections with the tenant database and the data platform database respectively.

[0045] Among them, such as Figure 2 As shown, the data synchronization server is a standalone server that can receive external data synchronization requests. When data synchronization is required, you only need to send a synchronization request carrying the account information of the tenant database and the data middleware database to the data synchronization server to establish a synchronization link between the tenant database and the data middleware database, without having to manually operate the database synchronization tool to perform data synchronization operations.

[0046] In a multi-tenant platform of a SaaS system, when a tenant database is dynamically created, the data synchronization between the tenant database and the data middleware database can be automatically created by sending an HTTP request to the data synchronization server, without the need for additional operations such as manual data synchronization using tools.

[0047] Specifically, such as Figure 3 As shown, when it is detected that a tenant has completed the registration of a tenant account on the SaaS platform and the SaaS platform has created the tenant database, the data synchronization server obtains the initialization success information of the tenant database; the data synchronization server receives the data synchronization request sent by the SaaS platform, and the data synchronization server establishes connections with the tenant database and the data platform database respectively according to the data synchronization request.

[0048] Step S20: After the data synchronization server establishes connections with the tenant database and the data platform database respectively, the data synchronization server obtains the log change data of the tenant database, converts the log change data into a general JSON format statement, and saves it to the local database.

[0049] The log change data refers to binary log change information of database table structure changes or table data changes in the tenant database.

[0050] Specifically, all databases that support data backup have logs recording database table changes and data changes. The data synchronization server can obtain the database type from the connection information of the tenant database, then determine the data change log record type of the tenant database based on the database type, parse it into JSON format statements according to the characteristics of different log types, and then convert it into SQL format statements supported by the data platform database.

[0051] Once the data synchronization server establishes connections with both the tenant database and the data platform database, a data synchronization task is created (e.g., ...). Figure 3 ).

[0052] After the data synchronization task is created by the data synchronization server, the data synchronization server listens for log changes in the tenant database (such as...). Figure 3 ), and obtain the log change data of the tenant database.

[0053] Once the data synchronization server obtains the log change data, it converts the log change data into a general JSON format statement. For MySQL, this is the binlog log, and for PostgreSQL, it is the WAL log. For example, the original binlog log is: "database name|table name|operation type|operation statement", which, when converted to JSON format, would be: {"database": "database name", "table": "table name", "operation type": ""create", "ddl": "operation statement"}.

[0054] Binlog is a binary log that records all database table structure changes (such as CREATE, ALTER TABLE, etc.) and table data changes (INSERT, UPDATE, DELETE). Its synchronization principle is to use the function of binlog to record database operations or data changes, and convert binlog into SQL statements that the data middle platform database can execute, and execute them on the data middle platform database in real time to achieve the purpose of data synchronization.

[0055] The reason for parsing and converting the data change log into JSON format is to avoid having to start parsing from the tenant database's data change log for each data platform database and convert it into executable SQL statements for the data platform database. Instead, it can be directly converted into SQL statements for the data platform database after parsing the intermediate JSON format.

[0056] The data synchronization server saves the general JSON format statement to its local database. The reason for saving the general JSON format statement to the local database (which is a database installed on the same machine as the data synchronization server) is to prevent synchronization failure due to network interruption, data platform server crash, or data synchronization server crash before the data platform database executes the synchronization SQL. After the data synchronization server restarts or the network is reconnected, the latest synchronized JSON data can be read from the local database, parsed into the SQL format supported by the data platform database, and sent to the data platform database.

[0057] Step S30: The data synchronization server converts the general JSON format statement into an SQL statement supported by the data platform database, and sends the SQL statement to the data platform database for real-time reading and saving, so as to complete the remote data synchronization between the tenant database and the data platform database.

[0058] Specifically, the data synchronization server converts the common JSON format statements saved in the local database into SQL statements supported by the data platform database, and sends the SQL statements to the data platform database for real-time reading and saving (e.g., ...). Figure 3 ).

[0059] For example, converting JSON data into SQL statements supported by the data platform database can be done as follows: {"database": "database name", "table": "table name", "operation type": ""create", "ddl": "operation statement"} into delete fromtest where a = 1.

[0060] After the data synchronization server receives the information that the data middleware server has successfully read and saved the SQL statement, the remote data synchronization between the tenant database and the data middleware database is completed. The data synchronization server then deletes the SQL statement that was successfully read and saved by the data middleware database from the local database.

[0061] The SQL statements deleted from the local database are log change data obtained from the tenant database.

[0062] This includes protection of the data processing flow, such as handling system fault tolerance. Synchronized data is stored locally on the data synchronization server and is only deleted from the local database after successful synchronization. Data loss will not occur when synchronization is interrupted, and the local database can be queried to retrieve the data that was not successfully synchronized when the next synchronization starts.

[0063] When the data synchronization server receives information from the data middleware server indicating that reading and saving the SQL statement failed, it will retry; specifically:

[0064] When the data synchronization server receives information from the data platform server that the SQL statement failed to be read and saved, the data synchronization server resends the SQL statement to the data platform database for real-time reading and saving. Since the data synchronization database does not receive feedback on whether the SQL statement was executed successfully, it needs to be resent, that is, the SQL statement for executing data operations is repeatedly sent to the data platform database.

[0065] If multiple retries still fail, synchronization is terminated. The data synchronization server receives synchronization error information returned by the data platform server. The reason for the synchronization error may be that the data platform database is a database type that is not currently supported, resulting in SQL syntax incompatibility or abnormalities in the data platform database, such as network interruption or database stoppage.

[0066] In addition, when sending a request message to the data synchronization server to establish a data synchronization task, this invention can use either an HTTP request or a long-lived connection established via WebSocket or a socket. Establishing a long-lived connection via WebSocket or a socket refers to a communication method. Using an HTTP request for data synchronization means that after the party needing data synchronization sends the request to the synchronization server, the connection is closed. When other requests for data synchronization arise, a new connection needs to be established with the synchronization server, and the data synchronization request is sent. A long-lived connection, however, maintains the connection continuously; the connection with the data synchronization server is not closed after the data synchronization request is sent.

[0067] Furthermore, in order to achieve database data synchronization between different SQL syntaxes, the data operation logs recorded in the database will be converted into a common intermediate data format statement, namely JSON format statement, and then the JSON will be converted into SQL statements that can be executed by the data middle platform database. The intermediate format JSON format used here can also be any parsable and recognizable format, such as XML format.

[0068] In addition, different databases in this invention may correspond to different log formats. For example, PostgreSQL uses WAL logs and MySQL uses binlog logs. Both are records of database operation changes or data changes. The data platform database in this invention can also be located in any other relational or non-relational database that can establish a network connection.

[0069] Furthermore, such as Figure 4As shown, based on the above-described method for automatic remote data synchronization in a multi-tenant environment, the present invention also provides a system for automatic remote data synchronization in a multi-tenant environment, wherein the system for automatic remote data synchronization in a multi-tenant environment includes:

[0070] Create synchronization module 51. After the SaaS platform creates the tenant database, the data synchronization server receives the data synchronization request sent by the SaaS platform and establishes connections with the tenant database and the data middleware database respectively.

[0071] The data conversion module 52, after the data synchronization server establishes connections with the tenant database and the data platform database respectively, obtains the log change data of the tenant database, converts the log change data into a general JSON format statement, and saves it to the local database.

[0072] The data synchronization module 53, the data synchronization server, converts the general JSON format statement into an SQL statement supported by the data platform database, and sends the SQL statement to the data platform database for real-time reading and saving, so as to complete the remote data synchronization between the tenant database and the data platform database.

[0073] Furthermore, such as Figure 5 As shown, based on the above-mentioned method and system for automatic remote data synchronization in a multi-tenant environment, the present invention also provides a terminal, which includes a data synchronization server 10, a processor 20, a memory 30, and a display 40. Figure 5 Only some of the terminal components are shown; however, it should be understood that it is not required to implement all of the components shown, and more or fewer components may be implemented instead.

[0074] In some embodiments, the memory 30 may be an internal storage unit of the terminal, such as a hard disk or memory. In other embodiments, the memory 30 may be an external storage device of the terminal, such as a plug-in hard disk, smart media card (SMC), secure digital card (SD), flash card, etc. Further, the memory 30 may include both internal and external storage devices. The memory 30 is used to store application software and various types of data installed on the terminal, such as program code installed on the terminal. The memory 30 can also be used to temporarily store data that has been output or will be output. In one embodiment, the memory 30 stores a program 50 for automatic remote data synchronization in a multi-tenant environment. This program 50 can be executed by the processor 20 to implement the method for automatic remote data synchronization in a multi-tenant environment as described in this application.

[0075] In some embodiments, the processor 20 may be a central processing unit (CPU), a microprocessor, or other data processing chip, used to run program code stored in the memory 30 or process data, such as executing the method for automatic remote data synchronization in a multi-tenant environment.

[0076] In some embodiments, the display 40 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, or an OLED (Organic Light-Emitting Diode) touchscreen. The display 40 is used to display information on the terminal and to display a visual user interface. The components 10-40 of the terminal communicate with each other via a system bus.

[0077] In one embodiment, when processor 20 executes program 50 for automatic remote data synchronization in a multi-tenant environment in memory 30, the following steps are performed:

[0078] After the SaaS platform creates the tenant database, the data synchronization server receives the data synchronization request sent by the SaaS platform and establishes connections with the tenant database and the data middleware database respectively.

[0079] After the data synchronization server establishes connections with the tenant database and the data platform database respectively, the data synchronization server obtains the log change data of the tenant database, converts the log change data into a general JSON format statement, and saves it to the local database.

[0080] The data synchronization server converts the general JSON format statement into an SQL statement supported by the data platform database, and sends the SQL statement to the data platform database for real-time reading and saving, so as to complete the remote data synchronization between the tenant database and the data platform database.

[0081] Specifically, after the SaaS platform creates a tenant database, the data synchronization server receives the data synchronization request sent by the SaaS platform and establishes connections with both the tenant database and the data platform database.

[0082] When it is detected that a tenant has completed the registration of a tenant account on the SaaS platform and the SaaS platform has created the tenant database, the data synchronization server obtains the initialization success information of the tenant database.

[0083] The data synchronization server receives a data synchronization request sent by the SaaS platform, and establishes connections with the tenant database and the data middleware database respectively according to the data synchronization request.

[0084] Specifically, after the data synchronization server establishes connections with both the tenant database and the data platform database, the data synchronization server obtains the log change data from the tenant database, converts the log change data into a general JSON format statement, and saves it to the local database. This includes:

[0085] Once the data synchronization server establishes connections with the tenant database and the data platform database respectively, a data synchronization task is created.

[0086] After the data synchronization task is created by the data synchronization server, the data synchronization server listens for log changes in the tenant database and obtains the log change data of the tenant database.

[0087] Once the data synchronization server obtains the log change data, it converts the log change data into a general JSON format statement.

[0088] The data synchronization server saves the general JSON format statement to its local database.

[0089] Specifically, the data synchronization server converts the general JSON format statement into an SQL statement supported by the data platform database, and sends the SQL statement to the data platform database for real-time reading and saving, thereby completing the remote data synchronization between the tenant database and the data platform database, including:

[0090] The data synchronization server converts the general JSON format statements saved in the local database into SQL statements supported by the data platform database, and sends the SQL statements to the data platform database for real-time reading and saving.

[0091] After the data synchronization server receives the information that the data middleware server has successfully read and saved the SQL statement, the remote data synchronization between the tenant database and the data middleware database is completed. The data synchronization server then deletes the SQL statement that was successfully read and saved by the data middleware database from the local database.

[0092] The data synchronization server converts the general JSON format statement into an SQL statement supported by the data platform database, and sends the SQL statement to the data platform database for real-time reading and saving. The process also includes:

[0093] When the data synchronization server receives information from the data middleware server that the SQL statement failed to be read and saved, it will retry.

[0094] If multiple retries still fail, synchronization is terminated, and the data synchronization server receives the synchronization error information returned by the data middleware server.

[0095] Specifically, when the data synchronization server receives information from the data middleware server indicating a failure to read and save the SQL statement, it will retry, as follows:

[0096] When the data synchronization server receives information that the data middleware server failed to read and save the SQL statement, the data synchronization server resends the SQL statement to the data middleware database for real-time reading and saving.

[0097] The log change data refers to binary log change information of database table structure changes or table data changes in the tenant database.

[0098] The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a program for automatic remote data synchronization in a multi-tenant environment, and when the program for automatic remote data synchronization in a multi-tenant environment is executed by a processor, it implements the steps of the method for automatic remote data synchronization in a multi-tenant environment as described above.

[0099] In summary, this invention provides a method and related equipment for automatic remote data synchronization in a multi-tenant environment. The method includes: after a SaaS platform creates a tenant database, a data synchronization server receives a data synchronization request sent by the SaaS platform and establishes connections with both the tenant database and the data platform database; after establishing connections with both the tenant database and the data platform database, the data synchronization server obtains log change data from the tenant database, converts the log change data into a general JSON format statement, and saves it to a local database; the data synchronization server converts the general JSON format statement into an SQL statement supported by the data platform database, and sends the SQL statement to the data platform database for real-time reading and saving, thereby completing the remote data synchronization between the tenant database and the data platform database. This invention establishes a general data synchronization server based on a data synchronization service to provide external data synchronization services, synchronizing tenant database data to the data platform database. Tenants only need to send connection information between their tenant database and the data platform database to the data synchronization server to establish batch and real-time data synchronization between the tenant database and the data platform database, with initial batch synchronization followed by real-time synchronization.

[0100] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal that includes that element.

[0101] Of course, those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware (such as a processor, controller, etc.). The program can be stored in a computer-readable storage medium, and when executed, it can include the processes described in the above method embodiments. The computer-readable storage medium can be a memory, magnetic disk, optical disk, etc.

[0102] It should be understood that the application of the present invention is not limited to the examples above. Those skilled in the art can make improvements or modifications based on the above description, and all such improvements and modifications should fall within the protection scope of the appended claims.

Claims

1. A method for automatic remote data synchronization in a multi-tenant environment, characterized in that, The method for automatic remote data synchronization in a multi-tenant environment includes: After the SaaS platform creates the tenant database, the data synchronization server receives the data synchronization request sent by the SaaS platform and establishes connections with the tenant database and the data platform database respectively. After the data synchronization server establishes connections with the tenant database and the data platform database respectively, the data synchronization server obtains the log change data of the tenant database, converts the log change data into a general JSON format statement, and saves it to the local database. The data synchronization server converts the general JSON format statement into an SQL statement supported by the data platform database, and sends the SQL statement to the data platform database for real-time reading and saving, so as to complete the remote data synchronization between the tenant database and the data platform database. After the data synchronization server establishes connections with both the tenant database and the data platform database, the data synchronization server obtains the log change data from the tenant database, converts the log change data into a general JSON format statement, and saves it to the local database. Specifically, this includes: Once the data synchronization server establishes connections with the tenant database and the data platform database respectively, a data synchronization task is created. After the data synchronization task is created by the data synchronization server, the data synchronization server listens for log changes in the tenant database and obtains the log change data of the tenant database. Once the data synchronization server obtains the log change data, it converts the log change data into a general JSON format statement. The data synchronization server saves the general JSON format statement to its local database.

2. The method for automatic remote data synchronization in a multi-tenant environment according to claim 1, characterized in that, When the SaaS platform creates a tenant database, the data synchronization server receives the data synchronization request sent by the SaaS platform and establishes connections with both the tenant database and the data platform database, specifically including: When it is detected that a tenant has completed the registration of a tenant account on the SaaS platform and the SaaS platform has created the tenant database, the data synchronization server obtains the initialization success information of the tenant database. The data synchronization server receives a data synchronization request sent by the SaaS platform, and establishes connections with the tenant database and the data middleware database respectively according to the data synchronization request.

3. The method for automatic remote data synchronization in a multi-tenant environment according to claim 1, characterized in that, The data synchronization server converts the general JSON format statement into an SQL statement supported by the data platform database, and sends the SQL statement to the data platform database for real-time reading and saving, thereby completing the remote data synchronization between the tenant database and the data platform database, specifically including: The data synchronization server converts the general JSON format statements saved in the local database into SQL statements supported by the data platform database, and sends the SQL statements to the data platform database for real-time reading and saving. After the data synchronization server receives the information that the data middleware server has successfully read and saved the SQL statement, the remote data synchronization between the tenant database and the data middleware database is completed. The data synchronization server then deletes the SQL statement that was successfully read and saved by the data middleware database from the local database.

4. The method for automatic remote data synchronization in a multi-tenant environment according to claim 3, characterized in that, The data synchronization server converts the general JSON format statement into an SQL statement supported by the data platform database, and sends the SQL statement to the data platform database for real-time reading and saving. This process also includes: When the data synchronization server receives information from the data middleware server that the SQL statement failed to be read and saved, it will retry. If multiple retries still fail, synchronization is terminated, and the data synchronization server receives the synchronization error information returned by the data middleware server.

5. The method for automatic remote data synchronization in a multi-tenant environment according to claim 4, characterized in that, When the data synchronization server receives information from the data middleware server indicating that reading and saving the SQL statement failed, it will retry, specifically as follows: When the data synchronization server receives information that the data middleware server failed to read and save the SQL statement, the data synchronization server resends the SQL statement to the data middleware database for real-time reading and saving.

6. The method for automatic remote data synchronization in a multi-tenant environment according to claim 1, characterized in that, The log change data refers to binary log change information of database table structure changes or table data changes in the tenant database.

7. A system for automatic remote data synchronization in a multi-tenant environment, characterized in that, The system for automatic remote data synchronization in a multi-tenant environment is applied to the method for automatic remote data synchronization in a multi-tenant environment as described in any one of claims 1-6, wherein the system for automatic remote data synchronization in a multi-tenant environment comprises: A synchronization module is created. After the SaaS platform creates a tenant database, the data synchronization server receives the data synchronization request sent by the SaaS platform and establishes connections with the tenant database and the data platform database respectively. The data conversion module, after the data synchronization server establishes connections with the tenant database and the data platform database respectively, obtains the log change data of the tenant database, converts the log change data into a general JSON format statement, and saves it to the local database; The data synchronization module, wherein the data synchronization server converts the general JSON format statement into an SQL statement supported by the data platform database, and sends the SQL statement to the data platform database for real-time reading and saving, so as to complete the remote data synchronization between the tenant database and the data platform database.

8. A terminal, characterized in that, The terminal includes: a data synchronization server, a memory, a processor, and a program for automatic remote data synchronization in a multi-tenant environment stored in the memory and executable on the processor. When the program for automatic remote data synchronization in a multi-tenant environment is executed by the processor, it implements the steps of the method for automatic remote data synchronization in a multi-tenant environment as described in any one of claims 1-6.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a program for automatic remote data synchronization in a multi-tenant environment, which, when executed by a processor, implements the steps of the method for automatic remote data synchronization in a multi-tenant environment as described in any one of claims 1-6.