A data synchronization method, device and medium for a MySQL database
By using event signal tables and event windows in a MySQL database, alternating synchronization of full and incremental data was achieved, solving the real-time and availability issues of data synchronization in existing technologies and improving data processing efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HANGZHOU WOQU NETWORK TECH
- Filing Date
- 2022-11-29
- Publication Date
- 2026-06-30
Smart Images

Figure CN115757357B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing, and in particular to a data synchronization method, device, and medium for MySQL databases. Background Technology
[0002] Due to the need for servers and large amounts of data, and to prevent damage to the server's single database and loss of user data due to unforeseen events, it is necessary to set up two databases: a primary database and a backup database. The data in the primary database and the data in the backup database must be synchronized in real time. When the primary database becomes unavailable, the server can continue to operate by calling the data in the backup database.
[0003] Currently, when synchronizing data between two MySQL databases, change data capture technology is used. This technology can capture committed incremental data from the database transaction log in real time. However, in real-world database usage scenarios, not all transaction logs are typically retained, meaning it's impossible to obtain complete full data (historical data) from the transaction logs. Generally, a two-step process of full data migration and incremental data synchronization is used to obtain the complete set of data for a specific table in the database. However, this approach has the following problems: During full data transmission, the transmission of incremental data needs to be completely stopped. When there is a large amount of full data to be transmitted, it will cause a long delay in incremental data transmission until the complete full data synchronization is finished, which cannot meet the requirements for real-time data synchronization. Summary of the Invention
[0004] To address the aforementioned technical problems, this invention provides a data synchronization method, device, and medium for MySQL databases, which at least partially solves the technical problems existing in the prior art. The technical solution adopted by this invention is as follows:
[0005] According to one aspect of this application, a data synchronization method for a MySQL database is provided, applied to a data server. The data server is connected to a database to be migrated and a target database, both of which are MySQL databases. The database to be migrated includes several events to be migrated, several events to be updated, and an event signal table. Each event to be migrated includes several pieces of data to be migrated; each event to be updated includes several pieces of data to be updated; the data to be updated is the update data corresponding to the data to be migrated during the migration to the target database; the target database obtains all the data in the database to be migrated according to the event signal table; the event signal table includes several rows of data tables, and the event signal table has several event windows, each event window having a length of m, so that m rows of data tables are assigned to the same event window; each event window includes a window start marker and a window end marker, so that the data server processes the data tables within the window start marker to the window end marker sequentially;
[0006] The data synchronization method for MySQL databases includes the following steps:
[0007] S100, Responding to the data synchronization request issued by the database to be migrated;
[0008] S200. Based on the data synchronization request, obtain the event set to be migrated J = (J1, J2, ..., J...). i ,...,J n ); where i = 1, 2, ..., n; n is the number of events to be migrated in the database to be migrated; J i This refers to the i-th event to be migrated in the database to be migrated.
[0009] S300, J i Stored in the Gth event signal table i1 In the event window; among them, G i1 For J i The event window number, G i1 =Ceiling(i / m), where Ceiling() is the floor function;
[0010] S400, according to J1, J2, ..., J i ,...,J n Get the event set to be updated E = (E1, E2, ..., E i ,...,E n ); where E i For J i The corresponding events to be updated;
[0011] S500, if E i If E ≠ 0, then E i Stored in the Gth event signal table i1 Each event window;
[0012] S600, sequentially traverse all event windows of the event signal table, if E i =J i Then J in the event signal table i Replace with E i ;
[0013] S700: Send the event signal table to the target database.
[0014] In one exemplary embodiment of this application, the length m of the event window satisfies the following condition:
[0015] m = H / (Q / P); where H is the maximum storage capacity of the data server's memory, Q is the total amount of data to be migrated in the database to be migrated, and P is the number of data to be migrated in the database to be migrated.
[0016] In one exemplary embodiment of this application, step S300 includes:
[0017] S310. If m > r, then J i Stored in the Gth event signal table i1 In the event window; where r is the Gth event... i1 The number of data tables currently storing data in each event window;
[0018] S320. If m≤r, then J i Stored in the Gth event signal table i1 +1 event window.
[0019] In one exemplary embodiment of this application, step S500 further includes:
[0020] If E i =0, then E i delete.
[0021] In one exemplary embodiment of this application, step S600 includes:
[0022] S610. Using the window start marker of each event window as the starting point of the traversal of the corresponding event window, and the window end marker of each event window as the ending point of the traversal of the corresponding event window, traverse all event windows in turn to obtain the events to be migrated and the corresponding events to be updated in each event window.
[0023] S620, if E i =J i Then J in the event signal table i Replace with E i And delete J from the event signal table. i Otherwise, E i Move to the last row of the data table in its corresponding event window.
[0024] In one exemplary embodiment of this application, after step S700, the method further includes:
[0025] S810. If a data addition request is received from the database to be migrated, then proceed to step S820.
[0026] S820. Based on the data addition request, obtain the event set to be added S = (S1, S2, ..., S...). t ,...,Su ); where t = 1, 2, ..., u; u is the number of events to be added in the database to be migrated, corresponding to the data addition request; S t This refers to the t-th event to be added in the database to be migrated, corresponding to the data addition request.
[0027] S830, Y t2 Store it in the W+Ceiling(t / m)-1 event window of the event signal table, and set Y t1 Send to the target database; where Y t1 For S t The corresponding data to be added, Y t2 For S t The position number in the database to be migrated; W is the empty event window corresponding to the smallest position number in the current event signal table. The empty event window is the event window that does not store data.
[0028] In one exemplary embodiment of this application, step S200 further includes:
[0029] S210. If n / m > α, then determine m = α * m; where α is the preset weight.
[0030] In one exemplary embodiment of this application, the target database executes the following method after receiving the event signal table:
[0031] Based on the events to be migrated and the events to be updated in the event signal table, obtain the corresponding data to be migrated and the data to be updated in the database to be migrated.
[0032] According to one aspect of this application, a non-transitory computer-readable storage medium is provided, the storage medium storing at least one instruction or at least one program segment, the at least one instruction or the at least one program segment being loaded and executed by a processor to implement the data synchronization method for a MySQL database.
[0033] According to one aspect of this application, an electronic device is provided, including a processor and the non-transitory computer-readable storage medium.
[0034] The present invention has at least the following beneficial effects:
[0035] The data server of this invention acquires events to be migrated and events to be updated from the database to be migrated, and stores these events in the corresponding event windows of the event signal table. It then iterates through each event window, comparing the events to be migrated with their corresponding events to be updated to determine whether the events to be migrated need to be synchronized to the target database. The data server only traverses one event window at a time, achieving alternating data synchronization. Furthermore, the events to be migrated and events to be updated stored in the event signal table only include the location of their corresponding data in the database, not the data itself, reducing the amount of data processing, shortening data processing time, and meeting the requirements for real-time data synchronization. Attached Figure Description
[0036] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0037] Figure 1 A connection block diagram of a data server provided in an embodiment of the present invention;
[0038] Figure 2 A flowchart illustrating a data synchronization method for a MySQL database provided in an embodiment of the present invention. Detailed Implementation
[0039] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0040] Due to the demands of server capacity and large data volumes, and to prevent data loss due to damage to a single database caused by unforeseen events, two databases are required: a primary database and a backup database. Data in the primary and backup databases must be synchronized in real-time. If the primary database becomes unavailable, data from the backup database can be used to maintain server operation. Currently, data synchronization between the two MySQL databases is achieved using Change Data Capture (CDC) technology. This technology captures committed incremental data from the database transaction log in real-time and propagates this incremental data to downstream consumers. However, in real-world database usage scenarios, not all transaction logs are typically retained, meaning it's impossible to obtain complete historical data from the transaction logs. Generally, a two-step process—full data migration and incremental data synchronization—is used to obtain the complete set of data for a specific table. However, this approach has the following problems: during full data transfer, incremental data transfer must be completely stopped. When there is a large amount of full data to be transferred, incremental data transfer will be disrupted. The prolonged pauses until the complete full data synchronization is finished fail to meet the real-time requirements of data synchronization. Furthermore, existing data synchronization technologies lack the ability to transmit full data on demand. That is, full data transmission is performed in batches during the initial phase, but once incremental data transmission begins after the full data transmission is complete, it is impossible to re-transmit the full data on demand, failing to meet the requirements for data repair of partial tables and transmission of newly added tables. Moreover, existing data synchronization technologies lock the transmitted data tables during full data transmission to prevent the generation of incremental data. Locking the transmitted data tables ensures that no incremental data is generated during full data synchronization, which affects the availability of data synchronization services.
[0041] Therefore, based on the shortcomings of existing MySQL data table synchronization technologies, a data processing method is provided that can alternately synchronize full data and incremental data.
[0042] According to one aspect of this application, a data synchronization method for a MySQL database is provided, such as... Figure 1As shown, this is applied to a data server. The data server is connected to a database to be migrated and a target database. Both the database to be migrated and the target database are MySQL databases. The database to be migrated includes several events to be migrated, several events to be updated, and an event signal table. Each event to be migrated includes several pieces of data to be migrated; each event to be updated includes several pieces of data to be updated; the data to be updated is the updated data corresponding to the data to be migrated during the migration to the target database; the target database obtains the full data from the database to be migrated according to the event signal table; the event signal table includes several rows of data tables, and the event signal table has several event windows, each event window having a length of m, so that m rows of data tables are assigned to the same event window; each event window includes a window start marker and a window end marker, so that the data server processes the data tables within the window start marker to the window end marker sequentially.
[0043] The database to be migrated can be the primary database, and the target database can be the backup database. The database to be migrated synchronizes the data to be migrated to the target database in real time to ensure that the data in the database to be migrated and the target database remain synchronized. Whenever there is a change or addition of data to be migrated in the database to be migrated, a data synchronization request is sent to the data server. The data server processes the data according to the data synchronization request. The target database then obtains the changed data to be migrated and the added data from the database to be migrated through the data processing results of the data server. The added data is the data to be updated, which is also the incremental data, thus achieving the purpose of data synchronization. The data server is the server that performs the data changes.
[0044] The event signal table serves as the data processing carrier for events to be migrated and events to be updated. By establishing the event signal table in the database to be migrated, and then obtaining the data from the database to be migrated based on the event signal table, the data change results are obtained. The target database obtains the full data and incremental data from the database to be migrated through the data change results recorded in the event signal table.
[0045] The event signal table contains several event windows, each containing several rows of data tables. The number of rows in each event window's data table is the same, i.e., m rows. Each event window has a start marker and an end marker. The start marker is located at the first row of the corresponding event window, and the end marker is located at the last row. The start marker indicates the beginning of the corresponding event window, and the end marker indicates its end. The target database sequentially retrieves the data corresponding to each event window in the event signal table of the database to be migrated based on the data change results.
[0046] The data synchronization method for MySQL databases, such as Figure 2As shown, it includes the following steps:
[0047] S100, Responding to the data synchronization request issued by the database to be migrated;
[0048] A data synchronization request is a request sent by the database to be migrated to the data server. It indicates that the data in the database to be migrated needs to be synchronized to the target database. The synchronized data is the data to be migrated, which is also the data that the target database needs to obtain, so that the data in the target database and the data in the database to be migrated are kept in sync.
[0049] S200. Based on the data synchronization request, obtain the event set to be migrated J = (J1, J2, ..., J...). i ,...,J n ); where i = 1, 2, ..., n; n is the number of events to be migrated in the database to be migrated; J i This refers to the i-th event to be migrated in the database to be migrated.
[0050] A migration event is an event containing data to be migrated. Since the database to be migrated is a MySQL database, it contains several rows of data to be migrated. Each row of data to be migrated constitutes a migration event. The migration event includes the location of the corresponding data to be migrated in the database to be migrated, so that the target database can obtain the data to be migrated in the database to be migrated based on the migration event.
[0051] S300, J i Stored in the Gth event signal table i1 In the event window; among them, G i1 For J i The event window number, G i1 =Ceiling(i / m), where Ceiling() is the floor function;
[0052] Each event to be migrated from the database is sequentially placed into an event signal table. For example, the first event to be migrated from the database is placed in the first row of the event signal table, the second event is placed in the second row, and so on, with the nth event placed in the nth row. Every m data tables form an event window, so every m events to be migrated are in the same event window. The sequence number of the event window for each event to be migrated is G. i1 For example, G corresponding to the first event to be migrated i1 The value is 1, and the G corresponding to the (m+1)th event to be migrated is... i1 The value is 2.
[0053] Further, step S300 includes:
[0054] S310. If m > r, then J i Stored in the Gth event signal table i1 In the event window; where r is the Gth event... i1 The number of data tables currently storing data in each event window;
[0055] S320. If m≤r, then J i Stored in the Gth event signal table i1 +1 more event windows;
[0056] To avoid an excessive number of events to be migrated in an event window, it is necessary to check whether the event window to be migrated is full before each event enters the event signal table. If it is full and there are no empty data tables in the event window to be migrated, then the event to be migrated is placed in the next event window. This ensures that each data table in each event window contains only one event to be migrated, which facilitates the subsequent comparison steps with the update events in the target database.
[0057] S400, according to J1, J2, ..., J i ,...,J n Get the event set to be updated E = (E1, E2, ..., E i ,...,E n ); where E i For J i The corresponding events to be updated;
[0058] Each event to be migrated corresponds to an update event, which represents the update event that changes during the synchronization process of the event to be migrated. Each update event includes the location of the corresponding data to be updated in the database to be migrated. The corresponding data to be updated can be found in the database to be migrated through each update event.
[0059] The data to be updated can be obtained by processing the update log using a binlog parser. Since the database to be migrated is a MySQL database, any additions or updates to the data to be migrated will be recorded in the corresponding log, which is the update log. The update log exists in the database to be migrated. Therefore, by analyzing the update log using a binlog parser, the corresponding data to be updated can be obtained, such as a certain piece of data A to be migrated. 00 During the data synchronization process, a change occurred, changing to A. 11 A 11 That is, A 00 The corresponding data to be updated.
[0060] S500, if E iIf E ≠ 0, then E i Stored in the Gth event signal table i1 In an event window; if E i =0, then E i delete;
[0061] Place each event to be updated and its corresponding event to be migrated into the same event window in the event signal table. If E i A value of 0, or an empty value, indicates that the corresponding event to be migrated did not undergo data changes during the data synchronization process. If E i If the value is not 0, it means that the corresponding event to be migrated has undergone data changes during the data synchronization process. The event to be migrated and its corresponding event to be updated are placed in the same event window to facilitate subsequent data comparison and processing.
[0062] Further, step S500 includes:
[0063] S510. If m > r, then E i Stored in the Gth event signal table i1 Each event window;
[0064] S520. If m≤r, then E i Stored in the Gth event signal table i1 +1 more event windows;
[0065] Each data table in each event window stores only one event to be migrated and its corresponding event to be updated. In steps S300 and S500, the full state of the event window refers to whether the corresponding data table already contains the corresponding event information. That is, when the event to be migrated enters the event window, does the corresponding event window have a data table that does not contain the event to be migrated? When the event to be updated enters the event window, does the corresponding event window have a data table that does not contain the event to be updated? If, when the event to be updated enters the event window, all data tables in the corresponding event window store one event to be migrated, but there is at least one data table that does not contain the event to be updated, then the corresponding event window is not in a full state, and the event to be updated can be placed into the data table in this event window that does not contain the event to be updated in turn.
[0066] S600, sequentially traverse all event windows of the event signal table, if E i =J i Then J in the event signal table i Replace with E i .
[0067] Since each data table in each event window stores one event to be migrated and one event to be updated, and these events are stored sequentially in the event window according to their positions in the corresponding databases, and since the target database is a backup database for the database to be migrated, the data stored in both databases should be identical except for the initial synchronization data. Therefore, if the data in the database to be migrated has not changed, its position in the database to be migrated should be the same as its position in the target database, and the data should also be identical. If the data to be migrated in the database to be migrated changes during the synchronization process, then the data to be migrated will have corresponding data to be updated. Since the data to be updated and the data to be migrated are corresponding, meaning that the updated data represents the updated data for the data to be migrated, their data events are identical. In this case, since the data event to be updated is the latest data event, it is necessary to replace the data to be migrated with the data event to be updated.
[0068] Further, step S600 includes:
[0069] S610. Using the window start marker of each event window as the starting point of the traversal of the corresponding event window, and the window end marker of each event window as the ending point of the traversal of the corresponding event window, traverse all event windows in turn to obtain the events to be migrated and the corresponding events to be updated in each event window.
[0070] S620, if E i =J i Then J in the event signal table i Replace with E i And delete J from the event signal table. i Otherwise, E i Move to the last row of the data table in its corresponding event window.
[0071] If the event to be migrated is the same as the event to be updated, it means that they are in an update relationship, and the event to be updated replaces the event to be migrated. If they are different, it means that they are not in an update relationship, and it means that they are new data events added during the data synchronization process. In this case, they are placed in the last line of the event window to facilitate the subsequent data acquisition and synchronization of the target database.
[0072] If the events to be migrated are r1, r2, r4, r6, and r7, the binlog parser analyzes their corresponding change logs and obtains the events to be updated as r1, r2, and r3. This means that r1 and r2 changed during data synchronization, and r3 is an event added during data synchronization. Therefore, the events to be updated, r1 and r2, need to replace the events to be migrated with r1 and r2, and then the events to be updated, r3, need to be placed at the last line of its event window. So, after processing, the event window contains r1 (event to be updated), r2 (event to be updated), r3 (event to be updated), r4 (event to be migrated), r6 (event to be migrated), and r7 (event to be migrated). The target database can then obtain the data corresponding to these events from the database to be migrated to complete the alternating synchronization of full data and incremental data.
[0073] After step S700, the data synchronization method for the MySQL database further includes:
[0074] S810. If a data addition request is received from the database to be migrated, then proceed to step S820.
[0075] S820. Based on the data addition request, obtain the event set to be added S = (S1, S2, ..., S...). t ,...,S u ); where t = 1, 2, ..., u; u is the number of events to be added in the database to be migrated, corresponding to the data addition request; S t This refers to the t-th event to be added in the database to be migrated, corresponding to the data addition request.
[0076] S830, Y t2 Store it in the W+Ceiling(t / m)-1 event window of the event signal table, and set Y t1 Send to the target database; where Y t1 For S t The corresponding data to be added, Y t2 For S t The position number in the database to be migrated; W is the empty event window corresponding to the smallest position number in the current event signal table. The empty event window is the event window that does not store data.
[0077] Steps S810 to S830 are the data processing method for data addition requests. The data addition request is for new data to be added to the database to be migrated, i.e., data to be added. The data to be added does not exist in the target database. Therefore, it is necessary to synchronize each data to be added to the target database. The data to be added corresponding to each data to be added is placed in the data table of the empty event window with the smallest current position sequence number in the event signal table. Since there is no target data at the corresponding position in the target database, the data to be added is also transferred to the target database for storage while the event to be added is recorded in the event signal table.
[0078] Upon receiving the event signal table, the target database executes the following method:
[0079] Based on the events to be migrated and the events to be updated in the event signal table, obtain the corresponding data to be migrated and the data to be updated in the database to be migrated.
[0080] The target database retrieves the corresponding data from the database to be migrated based on the events in the event signal table.
[0081] Specifically, the length m of the event window must meet the following conditions:
[0082] m = H / (Q / P); where H is the maximum storage capacity of the data server's memory, Q is the total amount of data to be migrated in the database to be migrated, and P is the number of data to be migrated in the database to be migrated.
[0083] The initial value of the event window length m is determined by the memory capacity of the data server and the average amount of data to be migrated. This ensures that the data server can be traversed multiple data tables at once without causing any operational burden. The larger m is, the more data tables the data server can traverse in a single session, and the overall traversal time will be shortened accordingly.
[0084] Furthermore, step S200 also includes:
[0085] S210. If n / m > α, then determine m = α*m; where α is the preset weight.
[0086] Step S210 ensures the correspondence between the length of each event window and the total number of events to be migrated. If the length m of the event window is a fixed value, the applicable range is too small. For example, when m is 10 and n is 100, at least 10 event windows need to be set. When the data server traverses all event windows, it must traverse at least 10 event windows. However, if n is 1000 and m is still 10, at least 100 event windows need to be set. Correspondingly, the data server also needs to traverse at least 100 event windows. In this case, the traversal time will increase, and the data processing time will also increase, which does not meet the requirement of short data processing time and few processes. Therefore, the length of the event window needs to be set as a variable, corresponding to the total number of events to be migrated. m has an initial minimum value. When the ratio of n to m is within a certain threshold, that is, less than or equal to α, it means that m does not need to be adjusted at this time, and the entire data processing time is within the required range. When the ratio of n to m is greater than α, m is dynamically adjusted so that m also increases to meet the data processing time requirements of a large number of events to be migrated, so that the number of generated event windows is reduced as much as possible, and then the data server traverses a moderate number of event windows, so that the overall data processing time is shortened as much as possible when processing a large number of events to be migrated.
[0087] The data server of this invention acquires events to be migrated and events to be updated from the database to be migrated, and stores these events in the corresponding event windows of the event signal table. It then iterates through each event window, comparing the events to be migrated with their corresponding events to be updated to determine whether the events to be migrated need to be synchronized to the target database. The data server only traverses one event window at a time, achieving alternating data synchronization. Furthermore, the events to be migrated and events to be updated stored in the event signal table only include the location of their corresponding data in the database, not the data itself, reducing the amount of data processing, shortening data processing time, and meeting the requirements for real-time data synchronization.
[0088] Embodiments of the present invention also provide a non-transitory computer-readable storage medium that can be disposed in an electronic device to store at least one instruction or at least one program related to implementing a method in the method embodiments, wherein the at least one instruction or the at least one program is loaded and executed by the processor to implement the method provided in the above embodiments.
[0089] Embodiments of the present invention also provide an electronic device, including a processor and the aforementioned non-transitory computer-readable storage medium.
[0090] Embodiments of the present invention also provide a computer program product including program code, which, when the program product is run on an electronic device, causes the electronic device to perform the steps of the methods described above in various exemplary embodiments of the present invention.
[0091] While specific embodiments of the invention have been described in detail by way of example, those skilled in the art should understand that the above examples are for illustrative purposes only and are not intended to limit the scope of the invention. Those skilled in the art should also understand that various modifications can be made to the embodiments without departing from the scope and spirit of the invention. The scope of the invention is defined by the appended claims.
Claims
1. A data synchronization method for a MySQL database, characterized in that, This system is applied to a data server connected to a database to be migrated and a target database, both of which are MySQL databases. The database to be migrated includes several migration events, several update events, and an event signal table. Each migration event includes several pieces of data to be migrated; each update event includes several pieces of data to be updated; the update data is the updated data corresponding to the migration data during the migration to the target database. The target database obtains all data from the database to be migrated based on the event signal table. The event signal table includes several rows of data tables and has several event windows, each event window having a length of m, so that m rows of data tables are allocated to the same event window. Each event window includes a window start marker and a window end marker, so that the data server processes the data tables within the window start marker to the window end marker sequentially. The method includes the following steps: S100, responding to the data synchronization request issued by the database to be migrated; S200. Based on the data synchronization request, obtain the event set to be migrated J=(J1,J2,...,J...). i ,...,J n ); where i = 1, 2, ..., n; n is the number of events to be migrated in the database to be migrated; J i This refers to the i-th event to be migrated in the database to be migrated. S300, J i The Gth event signal stored in the event signal table i1 In the event window; among them, G i1 For J i The event window number, G i1 =Ceiling(i / m), where Ceiling() is the floor function; S400, according to J1, J2, ..., J i ,...,J n Get the event set to be updated E=(E1,E2,...,E) i ,...,E n ); where E i For J i The corresponding events to be updated; S500, if E i If E ≠ 0, then E i The Gth event signal stored in the event signal table i1 Each event window; S600, sequentially traverse all event windows of the event signal table, if E i =J i Then, J in the event signal table i Replace with E i ; S700, Send the event signal table to the target database; Step S500 further includes: if E i =0, then E i delete; Step S600 includes S610-S620: S610. Using the window start marker of each event window as the traversal start point of the corresponding event window and the window end marker of each event window as the traversal end point of the corresponding event window, traverse all the event windows in sequence to obtain the event to be migrated and the corresponding event to be updated in each event window. S620, if E i =J i Then, J in the event signal table i Replace with E i And delete J from the event signal table. i Otherwise, E i Move to the last row of the data table in its corresponding event window.
2. The method according to claim 1, characterized in that, The length m of the event window meets the following condition: m = H / (Q / P); where H is the maximum storage capacity of the data server's memory, Q is the total amount of data to be migrated in the database to be migrated, and P is the number of data to be migrated in the database to be migrated.
3. The method according to claim 1, characterized in that, Step S300 includes: S310. If m > r, then J i The Gth event signal stored in the event signal table i1 In the event window; where r is the Gth event... i1 The number of data tables currently storing data in each event window; S320. If m≤r, then J i The Gth event signal stored in the event signal table i1 +1 event window.
4. The method according to claim 1, characterized in that, After step S700, the method further includes: S810. If a data addition request is received from the database to be migrated, then step S820 is executed. S820. Based on the data addition request, obtain the event set to be added S=(S1,S2,...,S...). t ,...,S u ); where t=1,2,...,u; u is the number of events to be added in the database to be migrated corresponding to the data addition request; S t This refers to the t-th event to be added in the database to be migrated, corresponding to the data addition request. S830, Y t2 Stored in the W+Ceiling(t / m)-1 event window of the event signal table, and Y t1 Send to the target database; wherein, Y t1 For S t The corresponding data to be added, Y t2 For S t The position number in the database to be migrated; W is the empty event window corresponding to the smallest position number in the current event signal table, and the empty event window is an event window that does not store data.
5. The method according to claim 1, characterized in that, Step S200 further includes: If n / m > α, then determine m = α * m; where α is the preset weight.
6. The method according to claim 1, characterized in that, Upon receiving the event signal table, the target database executes the following method: Based on the events to be migrated and the events to be updated in the event signal table, obtain the corresponding data to be migrated and the data to be updated in the database to be migrated.
7. A non-transitory computer-readable storage medium, wherein the storage medium stores at least one instruction or at least one program segment, characterized in that, The at least one instruction or the at least one program segment is loaded and executed by the processor to implement the method as described in any one of claims 1-6.
8. An electronic device, characterized in that, Includes a processor and the non-transitory computer-readable storage medium as described in claim 7.