Data synchronization method and device, equipment and storage medium
By introducing a sub-standby database into the main-standby database architecture and using delay parameters to synchronize operation data to the sub-standby database, the problem of performance degradation of the main database and the standby database in the face of a large number of read and write operation requests is solved, and the overall performance is improved. data storage system performance and business processing efficiency.
Patent Information
- Application Number
- CN202411275668.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-12
- Publication Date
- 2024-10-18
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In an active-standby database architecture, when faced with a large number of read and write operation requests, the pressure on the primary database to synchronize data with the standby database increases, resulting in a decline in database performance and business processing efficiency.
By introducing a sub-standby database into the data storage system, the primary database synchronizes the operation data to the standby database, and the standby database synchronizes the operation data to the sub-standby database according to the delay parameters. The sub-standby database is responsible for processing the historical operation data generated earlier, thus Alleviate the data operation pressure on the primary database and standby database.
It effectively alleviates the data operation pressure on the primary database and standby database, and improves the performance and business processing efficiency of the data storage system.
Smart Images

Figure CN118796947A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of distributed databases, and in particular to a data synchronization method, device, equipment and storage medium. Background Art
[0002] In the database master-slave architecture, the master database server is responsible for processing all write operations and some read operations, and multiple standby database servers synchronize data from the master database and process most read operations. The database master-slave deployment improves the high availability of the database.
[0003] However, when faced with a large number of read and write operation requests and standby databases, the pressure on the primary database to synchronize data with the standby database will increase, which will lead to a decline in database performance and reduce business processing efficiency. Summary of the invention
[0004] In view of the above problems, the present invention provides a data synchronization method, apparatus, device and storage medium.
[0005] According to a first aspect of the present invention, a data synchronization method is provided. The data synchronization method is applied to a data storage system. The data storage system includes a primary database, a standby database, and a sub-standby database. The data synchronization method includes:
[0006] In response to a business operation request, the primary database generates operation data according to the business operation request, wherein the operation data includes a data change operation record related to the business operation request; the primary database synchronizes the operation data to the standby database; the standby database synchronizes the operation data to the sub-standby database according to a delay parameter, wherein the delay parameter represents the interval from the standby database receiving the operation data to sending the operation data, the standby database is suitable for responding to a first read operation request and sending first historical operation data, and the sub-standby database is suitable for responding to a second read operation request and sending second historical operation data, and the generation time of the first historical operation data is later than the generation time of the second historical operation data.
[0007] Optionally, the data storage system includes multiple standby databases, and the data synchronization method includes:
[0008] At least one first standby database and at least one second standby database are determined from a plurality of standby databases; a connection parameter of the second standby database is modified, and the modified second standby database is determined as a sub-standby database corresponding to the first standby database, wherein the connection parameter represents a data transmission direction of operation data from the first standby database to the second standby database.
[0009] Optionally, the standby database synchronizes the operation data to the child standby database according to the delay parameters, including:
[0010] The standby sub-database calls the first connection instruction to establish a first connection process with the standby database; the standby database synchronizes the operation data to the standby sub-database according to the first connection process, synchronization mode configuration parameters and delay parameters.
[0011] Optionally, the synchronization mode configuration parameter indicates any of the following data replication modes: logical replication mode and streaming replication mode.
[0012] Optionally, the standby database synchronizes the operation data to the child standby database according to the delay parameter, and also includes:
[0013] The sub-standby database performs operation type detection on the operation data to obtain an operation type detection result; and the sub-standby database calls an associated operation execution instruction corresponding to the operation type detection result to execute a data change operation, so as to achieve data synchronization between the sub-standby database and the standby database.
[0014] Optionally, the primary database synchronizes the operation data to the standby database, including:
[0015] The standby database calls the second connection instruction to establish a second connection process with the primary database; the primary database synchronizes the operation data to the standby database according to the second connection process and synchronization mode configuration parameters.
[0016] Optionally, the data synchronization method further includes:
[0017] Call the first monitoring program to detect the operation data and storage data in the main database, the standby database, and the sub-standby database to determine the data detection result; call the second monitoring program to detect the completion time of the data change operation of the standby database and the completion time of the data change operation of the sub-standby database to determine the interval; determine the delay comparison result based on the interval and delay parameters; determine the test result based on the data detection result and the delay comparison result.
[0018] A second aspect of the present invention provides a data synchronization device, comprising:
[0019] A generating module, configured to respond to a business operation request, and the main database generates operation data according to the business operation request, wherein the operation data includes a data change operation record related to the business operation request;
[0020] The first synchronization module is used for the primary database to synchronize the operation data to the standby database;
[0021] The second synchronization module is used for the standby database to synchronize the operation data to the sub-standby database according to the delay parameter, wherein the delay parameter represents the interval from the standby database receiving the operation data to sending the operation data, the standby database is suitable for responding to the first read operation request and sending the first historical operation data, and the sub-standby database is suitable for responding to the second read operation request and sending the second historical operation data, and the generation time of the first historical operation data is later than the generation time of the second historical operation data.
[0022] A third aspect of the present invention provides an electronic device, comprising: one or more processors; a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors execute the above-mentioned data synchronization method.
[0023] The fourth aspect of the present invention further provides a computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, causes the processor to execute the above-mentioned data synchronization method.
[0024] According to the data synchronization method, device, equipment and storage medium provided by the present invention, the main database generates operation data according to the business operation request and synchronizes the operation data to the standby database; the standby database synchronizes the operation data to the sub-standby database according to the delay parameter. Due to the setting of the main database-standby database in the data storage system, the data operation pressure of the main database is relieved. When the standby database synchronizes the operation data to the sub-standby database according to the delay parameter for a large number of read operation requests related to historical operation data with an early generation time, it can directly choose to operate in the sub-standby database, further relieving the data operation pressure of the standby database, thereby improving the performance of the data storage system and the business processing efficiency as a whole. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] The above and other objects, features and advantages of the present invention will become more apparent through the following description of the embodiments of the present invention with reference to the accompanying drawings, in which:
[0026] Figure 1 An application scenario of the data synchronization method according to an embodiment of the present invention is shown;
[0027] Figure 2 A flow chart of a data synchronization method according to an embodiment of the present invention is shown;
[0028] Figure 3 An exemplary schematic diagram of a data storage system according to an embodiment of the present invention is shown;
[0029] Figure 4 It shows a structural block diagram of a data synchronization device according to an embodiment of the present invention;
[0030] Figure 5A block diagram of an electronic device suitable for implementing a data synchronization method according to an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0031] Below, embodiments of the present invention will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present invention. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of embodiments of the present invention. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of concepts of the present invention.
[0032] The terms used herein are only for describing specific embodiments and are not intended to limit the present invention. The terms "comprise", "include", etc. used herein indicate the existence of features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.
[0033] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification and should not be interpreted in an idealized or overly rigid manner.
[0034] When using expressions such as "at least one of A, B, and C, etc.", they should generally be interpreted according to the meaning of the expression commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).
[0035] In the process of implementing the present invention, it is found that in the database master-slave architecture, the master database server is responsible for processing all write operations and a part of the read operations, and multiple standby database servers synchronize data from the master database and process most of the read operations. However, when faced with a large number of read and write operation requests and standby databases, the pressure on the master database to synchronize data with the standby database will increase, which will lead to a decrease in database performance and reduce business processing efficiency.
[0036] In view of this, an embodiment of the present invention provides a data synchronization method, device, equipment and storage medium. The method includes: in response to a business operation request, the primary database generates operation data according to the business operation request, wherein the operation data includes a data change operation record related to the business operation request; the primary database synchronizes the operation data to the standby database; the standby database synchronizes the operation data to the sub-standby database according to a delay parameter, wherein the delay parameter represents the interval from the standby database receiving the operation data to sending the operation data, the standby database is suitable for responding to a first read operation request and sending the first historical operation data, the sub-standby database is suitable for responding to a second read operation request and sending the second historical operation data, and the generation time of the first historical operation data is later than the generation time of the second historical operation data.
[0037] In the technical solution of the present invention, the user information (including but not limited to user personal information, user image information, user device information, such as location information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved are all information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of the relevant data comply with relevant laws, regulations and standards, take necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0038] Figure 1 An application scenario of the data synchronization method according to an embodiment of the present invention is shown.
[0039] like Figure 1 As shown, the business system architecture 100 according to this embodiment may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104 and a server execution system, and the server execution system includes a server 105, a server 106, and a server 107. The network 104 is used to provide a medium for a communication link between the first terminal device 101, the second terminal device 102, the third terminal device 103 and the server execution system. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0040] The user may use at least one of the first terminal device 101, the second terminal device 102, and the third terminal device 103 to interact with the server execution system through the network 104 to receive or send messages, etc. Various communication client applications may be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only for example).
[0041] The first terminal device 101, the second terminal device 102, and the third terminal device 103 may be various electronic devices having display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.
[0042] The server execution system may be a server that provides various services, such as a background management server (only as an example) that supports websites browsed by users using the first terminal device 101, the second terminal device 102, and the third terminal device 103. The main database, the standby database, and the sub-standby database in the data storage system are deployed in the server execution system. For example, the main database may be deployed in the server 105, the standby database may be deployed in the server 106, and the sub-standby database may be deployed in the server 107. The background management server may analyze and process the received data such as user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests, etc.) to the terminal device.
[0043] It should be noted that the data synchronization method provided in the embodiment of the present invention can generally be executed by the server 105, the server 106, and the server 107. Accordingly, the data synchronization device provided in the embodiment of the present invention can generally be set in the server 105, the server 106, and the server 107. The data synchronization method provided in the embodiment of the present invention can also be executed by a server or a server cluster that is different from the server 105, the server 106, and the server 107 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103, and / or the server 105. Accordingly, the data synchronization device provided in the embodiment of the present invention can also be set in a server or a server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103, and / or the server 105, the server 106, and the server 107.
[0044] Alternatively, the data synchronization method provided in the embodiment of the present invention may also be executed by the first terminal device 101, the second terminal device 102 or the third terminal device 103, or may also be executed by other terminal devices different from the first terminal device 101, the second terminal device 102 or the third terminal device 103. Accordingly, the data synchronization apparatus provided in the embodiment of the present invention may also be provided in the first terminal device 101, the second terminal device 102 or the third terminal device 103, or may be provided in other terminal devices different from the first terminal device 101, the second terminal device 102 or the third terminal device 103.
[0045] It should be understood that Figure 1The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0046] It should be noted that the sequence numbers of the operations in the following method are only used as representations of the operations for the purpose of description, and should not be regarded as representing the execution order of the operations. Unless explicitly stated, the method does not need to be executed completely in the order shown.
[0047] Figure 2 A flow chart of a data synchronization method according to an embodiment of the present invention is shown.
[0048] like Figure 2 As shown, the method 200 includes operations S210 to S230.
[0049] In operation S210 , in response to a business operation request, the primary database generates operation data according to the business operation request.
[0050] Optionally, the server performs a data modification operation on the primary database in response to receiving a business operation request from the business end. The business operation request represents a read and write request for operations such as adding, deleting, querying, and inserting stored data.
[0051] Optionally, in the process of the master database executing the relevant operation language according to the business operation request, the data change operation is recorded to generate operation data.
[0052] Optionally, the data synchronization method is applied to a data storage system, which includes a primary database, a standby database, and a sub-standby database. The primary database, the standby database, and the sub-standby database form a cascade database mode, the standby database synchronizes data from the primary database, and the sub-standby database synchronizes data from the standby database.
[0053] Optionally, the operation data includes a data change operation record related to the business operation request. For example, the operation request may be an operation log.
[0054] In operation S220 , the primary database synchronizes the operation data to the standby database.
[0055] Optionally, the primary database may send the operation data to the standby database according to the synchronization mode, thereby achieving data synchronization between the standby database and the primary database.
[0056] In operation S230 , the standby database synchronizes the operation data to the standby child database according to the delay parameter.
[0057] Optionally, the standby database may send the operation data to the sub-standby database according to the asynchronous mode and delay parameters, thereby achieving data synchronization between the sub-standby database and the standby database.
[0058] Optionally, the delay parameter represents the interval time from when the standby database receives the operation data to when it sends the operation data. In the case where the standby database is cascaded with multiple sub-standby databases, the standby database sets a corresponding delay parameter for each sub-standby database, and then sends the operation data to the multiple sub-standby databases respectively according to the delay parameter. For example, the standby database cascades the first sub-standby database and the second sub-standby database, the delay parameter is set to 30 milliseconds for the first sub-standby database, and the delay parameter is set to 100 milliseconds for the second sub-standby database. After receiving the operation data, the standby database sends the operation data to the first sub-standby database at an interval of 30 milliseconds, and sends the operation data to the second sub-standby database at an interval of 100 milliseconds.
[0059] Optionally, the standby database is adapted to respond to a first read operation request and send first historical operation data, and the sub-standby database is adapted to respond to a second read operation request and send second historical operation data, and generation time of the first historical operation data is later than generation time of the second historical operation data.
[0060] Optionally, the first historical operation data represents the historical storage data in the standby database. The second historical operation data represents the historical storage data in the sub-standby database. Due to the setting of the delay parameter, there is a delay in the data synchronization time between the standby database and the sub-standby database. For example, if the delay parameter is set to 1 hour, the operation data received at 4:00 on the same day needs to be synchronized to the sub-standby database at 5:00. Therefore, after data synchronization is achieved according to the operation data, at 4:00 on the same day, the standby database can store the first historical operation data generated at or before 4:00 on the same day, and the sub-standby database can store the second historical operation data generated at or before 3:00 on the same day.
[0061] Optionally, the first read operation request represents a request with high real-time requirements for reading historical operation data, and the second read operation request represents a request with low real-time requirements for reading historical operation data. For example, according to business requirements, it is necessary to read the first historical operation data generated at the current moment. The server responds to the first read operation request from the business end and can directly perform a read operation on the standby database on the server to obtain the first historical operation data, and send the first historical operation data to the business end; according to business requirements, it is necessary to read the second historical operation data generated before a certain moment. The server responds to the second read operation request from the business end and can directly perform a read operation on the sub-standby database on the server to obtain the second historical operation data, and send the second historical operation data to the business end.
[0062] Optionally, the setting of the master database and the standby database in the data storage system alleviates the data operation pressure of the master database. The standby database synchronizes the operation data to the sub-standby database according to the delay parameters. When there are a large number of read operation requests related to historical operation data with an early generation time, the operation can be directly performed in the sub-standby database, which further alleviates the data operation pressure of the standby database, thereby improving the overall performance of the data storage system and the business processing efficiency.
[0063] Optionally, the data storage system includes multiple standby databases.
[0064] Optionally, a master database and multiple standby databases are first built in the data storage system, and a standby sub-database is created based on the master data-standby database relationship model.
[0065] Optional data synchronization methods include:
[0066] At least one first standby database and at least one second standby database are determined from a plurality of standby databases; a connection parameter of the second standby database is modified, and the modified second standby database is determined as a sub-standby database corresponding to the first standby database, wherein the connection parameter represents a data transmission direction of operation data from the first standby database to the second standby database.
[0067] For example, the data storage system includes a primary database and two standby databases, from which a first standby database and a second standby database can be randomly determined.
[0068] Optionally, an embodiment of creating a standby sub-database is to determine the standby database after modifying the connection parameters as the standby sub-database. The connection parameters in the configuration file may include a replication slot configuration parameter, a replication slot quantity parameter, and a preset process threshold parameter. The replication slot configuration parameter records the connection information of the primary database to which the standby database is connected, such as the address, port, user name, and password. The replication slot quantity parameter represents the number of replication slots, for example, the replication slot quantity parameter is 10. The preset process threshold parameter represents the maximum number of sending processes supported between the standby database and the primary database.
[0069] For example, taking the determination of the first standby database and the second standby database as an example, modifying the connection parameters of the second standby database may include: modifying the replication user information, the number of replication slots, and the address information, port information, and other replication slot information of the first standby database to which the second standby database is to be connected in the configuration file. The second standby database after the modified connection parameters is determined as a sub-standby database corresponding to the first standby database, and the modified connection parameters can support the first standby database to send operation data to the modified second standby database.
[0070] Optionally, another embodiment of creating a standby sub-database is to use the standby database as a template, create a new database as the standby sub-database, create new connection parameters and set them to read-only mode.
[0071] Figure 3 An exemplary schematic diagram of a data storage system according to an embodiment of the present invention is shown.
[0072] like Figure 3 As shown, the data storage system may include a main database 310, a standby database 320, a standby database 330 and a standby database 340 cascaded with the main database 310, and a sub-standby database 350, a sub-standby database 360 and a sub-standby database 370 cascaded with the standby database 330. The server where the main database 310 is located can receive all write operation requests and part of the read operation requests in the business operation request sent by the business terminal 380. According to the business operation request, the main database 310 synchronizes the operation data to the standby database 320, the standby database 330 and the standby database 340 in a synchronous manner or an asynchronous manner, and the standby database 330 synchronizes in an asynchronous manner, such as synchronizing the operation data to the corresponding sub-standby database 350, the sub-standby database 360 and the sub-standby database 370 according to different delay parameters.
[0073] Optionally, the server where the standby database is located can receive some read operation requests that require high real-time performance of historical operation data. For example, the server responds to the first read operation request from the business end 380 and can directly perform a read operation on the standby database 340 on the server to obtain first historical operation data, and send the first historical operation data to the business end 380; the server where the sub-standby database is located can receive some read operation requests that require lower real-time performance of historical operation data. For example, the server responds to the second read operation request from the business end 380 and can directly perform a read operation on the sub-standby database 370 on the server to obtain second historical operation data, and send the second historical operation data to the business end 380.
[0074] Optionally, the standby database synchronizes the operation data to the child standby database according to the delay parameters, including:
[0075] The standby sub-database calls the first connection instruction to establish a first connection process with the standby database; the standby database synchronizes the operation data to the standby sub-database according to the first connection process, synchronization mode configuration parameters and delay parameters.
[0076] Optionally, the standby sub-database calls the first connection instruction to establish a first connection process with the standby database according to the connection parameters. After the standby database performs permission verification, it reads the operation data from the local. Then, according to the address of the standby sub-database, the preset synchronization mode configuration parameters and the delay parameters, the operation data is synchronized to the standby sub-database.
[0077] Optionally, during the operation data synchronization process, the operation status of the standby database can be checked through the monitoring function of the standby database, for example, the operation status of the monitoring process, the operation data write location, etc.
[0078] Optionally, different delay parameters can be set for different standby sub-databases, so that multiple standby sub-databases will not synchronize operation data from the same standby database at the same time, thereby reducing the synchronization pressure of the standby database and improving the performance of the standby database.
[0079] Optionally, the synchronization mode configuration parameter indicates any of the following data replication modes: logical replication mode and streaming replication mode.
[0080] Optionally, pre-configure synchronization mode configuration parameters in the configuration file. The streaming replication mode directly replicates the operation data; the logical replication mode implements data replication by parsing the operation data to obtain logical changes.
[0081] Optionally, the standby database may synchronize the operation data to the standby child database according to a preset data replication method, for example, synchronizing the operation data to the standby child database according to a streaming replication method.
[0082] Optionally, the standby database synchronizes the operation data to the child standby database according to the delay parameter, and also includes:
[0083] The sub-standby database performs operation type detection on the operation data to obtain an operation type detection result; and the sub-standby database calls an associated operation execution instruction corresponding to the operation type detection result to execute a data change operation, so as to achieve data synchronization between the sub-standby database and the standby database.
[0084] Optionally, the operation type detection result represents the detection result of a specific operation type such as addition, deletion, and insertion.
[0085] Optionally, after receiving the operation data, the standby sub-database performs operation type detection and analysis on the operation data, thereby determining the operation type detection result. For example, after determining the insertion type detection result, the associated operation execution instruction corresponding to the determined insertion type detection result is called to perform a data insertion operation on the standby sub-database, and the data in the standby sub-database after the data modification operation is synchronized with the data in the standby database.
[0086] Optionally, the primary database synchronizes the operation data to the standby database, including:
[0087] The standby database calls the second connection instruction to establish a second connection process with the primary database; the primary database synchronizes the operation data to the standby database according to the second connection process and synchronization mode configuration parameters.
[0088] Optionally, the standby database calls the second connection instruction to establish a second connection process with the primary database according to the connection parameters. After the primary database performs permission verification, it reads the operation data locally and then synchronizes the operation data to the standby database according to the address of the standby database and the stream replication method.
[0089] Optionally, during the operation data synchronization process, the operating status of the standby database can be checked through the monitoring function of the standby database.
[0090] Optionally, after receiving the operation data, the standby database detects and analyzes the operation type of the operation data, thereby determining the operation type detection result. The standby database calls the associated operation execution instruction corresponding to the operation type detection result to perform the data change operation, and the data in the standby database after the data change operation is synchronized with the data in the primary database.
[0091] Optionally, the data synchronization method further includes:
[0092] Call the first monitoring program to detect the operation data and storage data in the main database, the standby database, and the sub-standby database to determine the data detection result; call the second monitoring program to detect the completion time of the data change operation of the standby database and the completion time of the data change operation of the sub-standby database to determine the interval; determine the delay comparison result based on the interval and delay parameters; determine the test result based on the data detection result and the delay comparison result.
[0093] Optionally, the stored data in the primary database refers to updated data after a data modification operation is performed according to a business operation request, and the stored data in the standby database and the sub-standby database refers to updated data after a data modification operation is performed according to the operation data.
[0094] Optionally, after completing data synchronization of the main database, the standby database, and the sub-standby database, the server calls the first monitoring program to detect the operation data and storage data in the main database, the standby database, and the sub-standby database, firstly comparing whether the storage data in the main database, the standby database, and the sub-standby database are the same, and then comparing whether the operation data in the main database, the standby database, and the sub-standby database are the same, and then obtaining the data detection result. If the operation data and the storage data are the same, a data consistency detection result is obtained, otherwise a data inconsistency detection result is obtained.
[0095] Optionally, the same operation data and the same storage data can be used to check whether the data storage system can normally complete the data synchronization function. For example, the same storage data in the standby database and the sub-standby database indicates that the sub-standby database can perform data synchronization with the standby database.
[0096] Optionally, the server calls the second monitoring program to detect the completion time of the data modification operation of the standby database and the completion time of the data modification operation of the sub-standby database, and determines the interval.
[0097] Optionally, the standby database performs a data change operation after receiving the operation data, and the sub-standby database performs a data change operation after receiving the operation data. The delay comparison result is determined based on whether the interval and delay parameters between the interval and the sub-standby database are the same when the data change operation completion time of the standby database is compared. If the interval and delay parameters are the same, the delay comparison result is consistent, otherwise the delay comparison result is inconsistent. If the data detection result and the delay comparison result are consistent, the test result is determined to be passed.
[0098] Based on the above data synchronization method, the present invention also provides a data synchronization device. Figure 4 The device is described in detail.
[0099] Figure 4 A structural block diagram of a data synchronization device according to an embodiment of the present invention is shown.
[0100] like Figure 4 As shown, the data synchronization device 400 of this embodiment includes a generation module 410 , a first synchronization module 420 and a second synchronization module 430 .
[0101] The generation module 410 is used to respond to the business operation request, and the master database generates operation data according to the business operation request, wherein the operation data includes a data change operation record related to the business operation request. In one embodiment, the generation module 410 can be used to perform the operation S210 described above, which will not be repeated here.
[0102] The first synchronization module 420 is used for the primary database to synchronize the operation data with the standby database. In one embodiment, the first synchronization module 420 can be used to perform the operation S220 described above, which will not be described in detail here.
[0103] The second synchronization module 430 is used for the standby database to synchronize the operation data to the sub-standby database according to the delay parameter, wherein the delay parameter represents the interval length from the standby database receiving the operation data to sending the operation data, the standby database is suitable for responding to the first read operation request and sending the first historical operation data, and the sub-standby database is suitable for responding to the second read operation request and sending the second historical operation data, and the generation time of the first historical operation data is later than the generation time of the second historical operation data. In one embodiment, the second synchronization module 430 can be used to perform the operation S230 described above, which will not be repeated here.
[0104] Optionally, the data synchronization device 400 further includes a first determination module and a second determination module.
[0105] The first determining module is used to determine at least one first standby database and at least one second standby database from multiple standby databases.
[0106] The second determination module is used to modify the connection parameters of the second standby database, and determine the modified second standby database as a sub-standby database corresponding to the first standby database, wherein the connection parameters represent the data transmission direction of the operation data from the first standby database to the second standby database.
[0107] Optionally, the second synchronization module 430 includes a first connection submodule and a first synchronization submodule.
[0108] The first connection submodule is used for the standby database to call the first connection instruction to establish a first connection process with the standby database.
[0109] The first synchronization submodule is used for the standby database to synchronize the operation data to the standby sub-database according to the first connection process, synchronization mode configuration parameters and delay parameters.
[0110] Optionally, the second synchronization module 430 further includes an operation detection submodule and a data modification submodule.
[0111] The operation detection submodule is used for the standby database to perform operation type detection on the operation data and obtain the operation type detection result.
[0112] The data modification submodule is used for the sub-standby database to call the associated operation execution instruction corresponding to the operation type detection result to perform the data modification operation, so as to realize the data synchronization between the sub-standby database and the standby database.
[0113] Optionally, the first synchronization module includes a second connection submodule and a second synchronization submodule.
[0114] The second connection submodule is used for the standby database to call the second connection instruction to establish a second connection process with the primary database.
[0115] The second synchronization submodule is used for the primary database to synchronize the operation data to the standby database according to the second connection process and synchronization mode configuration parameters.
[0116] Optionally, the data synchronization device 400 further includes a data detection module, a time detection module, a comparison module and a third determination module.
[0117] The data detection module is used to call the first monitoring program to detect the operation data and storage data in the main database, the standby database, and the sub-standby database, and determine the data detection result.
[0118] The time detection module is used to call the second monitoring program to detect the completion time of the data modification operation of the standby database and the completion time of the data modification operation of the sub-standby database, and determine the interval.
[0119] The comparison module is used to determine the delay comparison result according to the interval and delay parameters.
[0120] The third determination module is used to determine the test result according to the data detection result and the delay comparison result.
[0121] Optionally, any multiple modules of the generation module 410, the first synchronization module 420, and the second synchronization module 430 can be combined into one module for implementation, or any one of the modules can be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules can be combined with at least part of the functions of other modules and implemented in one module. Optionally, at least one of the generation module 410, the first synchronization module 420, and the second synchronization module 430 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application-specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware, and firmware, or in any appropriate combination of any of them. Alternatively, at least one of the generation module 410, the first synchronization module 420, and the second synchronization module 430 can be at least partially implemented as a computer program module, and when the computer program module is run, the corresponding function can be executed.
[0122] Figure 5 A block diagram of an electronic device suitable for implementing a data synchronization method according to an embodiment of the present invention is shown.
[0123] Figure 5 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0124] like Figure 5As shown, the computer electronic device 500 according to an embodiment of the present invention includes a processor 501, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 502 or the program loaded from the storage part 508 to the random access memory (RAM) 503. The processor 501 may include, for example, a general-purpose microprocessor (such as a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (for example, an application-specific integrated circuit (ASIC)), etc. The processor 501 may also include an on-board memory for caching purposes. The processor 501 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present invention.
[0125] In RAM 503, various programs and data required for the operation of electronic device 500 are stored. Processor 501, ROM 502 and RAM 503 are connected to each other via bus 504. Processor 501 performs various operations of the method flow according to the embodiment of the present invention by executing the program in ROM 502 and / or RAM 503. It should be noted that the program can also be stored in one or more memories other than ROM 502 and RAM 503. Processor 501 can also perform various operations of the method flow according to the embodiment of the present invention by executing the program stored in one or more memories.
[0126] Optionally, the electronic device 500 may further include an input / output (I / O) interface 505, which is also connected to the bus 504. The electronic device 500 may further include one or more of the following components connected to the input / output (I / O) interface 505: an input portion 506 including a keyboard, a mouse, etc.; an output portion 507 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 508 including a hard disk, etc.; and a communication portion 509 including a network interface card such as a LAN card, a modem, etc. The communication portion 509 performs communication processing via a network such as the Internet. A drive 510 is also connected to the input / output (I / O) interface 505 as needed. A removable medium 511, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 510 as needed, so that a computer program read therefrom is installed into the storage portion 508 as needed.
[0127] Optionally, the method flow according to the embodiment of the present invention can be implemented as a computer software program. For example, an embodiment of the present invention includes a computer program product, which includes a computer program carried on a computer-readable storage medium, and the computer program contains a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 509, and / or installed from the removable medium 511. When the computer program is executed by the processor 501, the above-mentioned functions defined in the system of the embodiment of the present invention are executed. Optionally, the system, equipment, device, module, unit, etc. described above can be implemented by a computer program module.
[0128] The present invention also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiment; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the data synchronization method according to the embodiment of the present invention is implemented.
[0129] Optionally, the computer-readable storage medium may be a non-volatile computer-readable storage medium. For example, it may include, but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, apparatus, or device.
[0130] For example, optionally, the computer-readable storage medium may include the ROM 502 and / or the RAM 503 described above and / or one or more memories other than the ROM 502 and the RAM 503 .
[0131] An embodiment of the present invention also includes a computer program product, which includes a computer program, which contains program code for executing the method provided by the embodiment of the present invention. When the computer program product runs on an electronic device, the program code is used to enable the electronic device to implement the data synchronization method provided by the embodiment of the present invention.
[0132] When the computer program is executed by the processor 501, the above functions defined in the system / device of the embodiment of the present invention are performed. Optionally, the system, device, module, unit, etc. described above can be implemented by a computer program module.
[0133] In one embodiment, the computer program may rely on tangible storage media such as optical storage devices, magnetic storage devices, etc. In another embodiment, the computer program may also be transmitted and distributed in the form of signals on a network medium, and downloaded and installed through the communication part 509, and / or installed from the removable medium 511. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0134] Optionally, the program code for executing the computer program provided by the embodiment of the present invention can be written in any combination of one or more programming languages, specifically, these computing programs can be implemented using high-level process and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, such as Java, C++, python, "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on the remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (e.g., using an Internet service provider to connect through the Internet).
[0135] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present invention. In this regard, each box in the flowchart or block diagram may represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box may also occur in an order different from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions. It can be understood by those skilled in the art that the features recorded in the various embodiments of the present invention can be combined and / or combined in various ways, even if such a combination or combination is not explicitly recorded in the present invention. In particular, without departing from the spirit and teachings of the present invention, the features recorded in the various embodiments of the present invention can be combined and / or combined in various ways. All these combinations and / or combinations fall within the scope of the present invention.
[0136] The embodiments of the present invention are described above. However, these embodiments are only for the purpose of illustration, and are not intended to limit the scope of the present invention. Although each embodiment is described above, it does not mean that the measures in each embodiment cannot be used in combination advantageously. Without departing from the scope of the present invention, those skilled in the art may make various substitutions and modifications, which should all fall within the scope of the present invention.
Claims
1. A data synchronization method, characterized in that: The method is applied to a data storage system, the data storage system includes a primary database, a standby database, and a sub-standby database, and the method includes: In response to a business operation request, the master database generates operation data according to the business operation request, wherein the operation data includes a data change operation record related to the business operation request; The primary database synchronizes the operation data to the standby database; The standby database synchronizes the operation data to the sub-standby database according to a delay parameter, wherein the delay parameter represents an interval from when the standby database receives the operation data to when it sends the operation data, the standby database is adapted to respond to a first read operation request and send first historical operation data, and the sub-standby database is adapted to respond to a second read operation request and send second historical operation data, and a generation time of the first historical operation data is later than a generation time of the second historical operation data.
2. The method according to claim 1, characterized in that The data storage system includes a plurality of the standby databases; The method comprises: Determine at least one first standby database and at least one second standby database from the plurality of standby databases; The connection parameters of the second standby database are modified, and the modified second standby database is determined as a sub-standby database corresponding to the first standby database, wherein the connection parameters represent a data transmission direction of the operation data from the first standby database to the second standby database.
3. The method according to claim 1, characterized in that The standby database synchronizes the operation data to the sub-standby database according to the delay parameter, including: The standby child database calls a first connection instruction to establish a first connection process with the standby database; The standby database synchronizes the operation data to the sub-standby database according to the first connection process, synchronization mode configuration parameters and delay parameters.
4. The method according to claim 3, characterized in that The synchronization mode configuration parameter indicates any of the following data replication modes: Logical replication mode and streaming replication mode.
5. The method according to claim 3, characterized in that: The standby database synchronizes the operation data to the sub-standby database according to the delay parameter, further comprising: The secondary standby database performs operation type detection on the operation data to obtain an operation type detection result; and The standby sub-database calls the associated operation execution instruction corresponding to the operation type detection result to execute the data modification operation, so as to realize data synchronization between the standby sub-database and the standby database.
6. The method according to claim 4, characterized in that The primary database synchronizes the operation data to the standby database, including: The standby database calls a second connection instruction to establish a second connection process with the primary database; The primary database synchronizes the operation data to the standby database according to the second connection process and the synchronization mode configuration parameters.
7. The method according to claim 5, characterized in that The method further comprises: Calling a first monitoring program to detect the operation data and storage data in the primary database, the standby database, and the sub-standby database, and determining a data detection result; Calling a second monitoring program to detect the completion time of the data modification operation of the standby database and the completion time of the data modification operation of the sub-standby database, and determining an interval; Determining a delay comparison result according to the interval and the delay parameter; A test result is determined according to the data detection result and the delay comparison result.
8. A data synchronization device, characterized in that: include: A generating module, configured to respond to a business operation request, and the main database generates operation data according to the business operation request, wherein the operation data includes a data change operation record related to the business operation request; A first synchronization module, used for the primary database to synchronize the operation data to the standby database; A second synchronization module is used for the standby database to synchronize the operation data to the sub-standby database according to a delay parameter, wherein the delay parameter represents the interval from the standby database receiving the operation data to sending the operation data, the standby database is suitable for responding to a first read operation request and sending first historical operation data, and the sub-standby database is suitable for responding to a second read operation request and sending second historical operation data, and the generation time of the first historical operation data is later than the generation time of the second historical operation data.
9. An electronic device, characterized in that: include: one or more processors; a memory for storing one or more instructions, Wherein, when the one or more instructions are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: Executable instructions are stored thereon, and when the instructions are executed by a processor, the processor is caused to perform the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Data synchronization method and device, electronic equipment and storage medium
CN114064795A
Database migration method and device, electronic equipment and readable storage medium
CN115098469A
Integrating change tracking of storage objects of a distributed object storage database into a distributed storage system
US20240104081A1
