A cross-environment data synchronization method and device
By building a cross-environment database and built-in data channel, calculating the data synchronization priority index, determining the synchronization strategy and monitoring it in real time, it solves the problem of differences between different systems affecting data synchronization, and achieves efficient and accurate cross-environment data synchronization.
Patent Information
- Application Number
- CN202411034503.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-31
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2044-07-31
AI Technical Summary
Differences between different systems in the prior art affect the compatibility of data synchronization, leading to problems of low efficiency and low accuracy.
By building a cross-environment database and built-in data channels, we can obtain real-time data sets, calculate the data synchronization priority index, determine the data synchronization strategy and synchronization level strategy, and monitor and adjust in real time during the synchronization process to ensure data consistency in different database environments. sex and accuracy.
It achieves fast and direct data transmission, reduces data synchronization time and resource consumption, improves synchronization efficiency, ensures data accuracy and real-time, avoids data redundancy and conflicts, and optimizes the use of network resources.
Smart Images

Figure CN118568181B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data management technology, and in particular to a cross-environment data synchronization method and device. Background Art
[0002] From the late 1990s to the early 21st century, the implementation of ERP systems required seamless synchronization of data between different departments and business units, which promoted the development of cross-environment data synchronization technology.
[0003] The advent of cloud computing technology allows data and applications to be stored and run on remote servers. This brings new data synchronization challenges, as data may need to be synchronized between cloud services and local systems.
[0004] With the popularity of mobile devices and the development of the Internet of Things, data synchronization issues have become more complicated. The data generated by smartphones, tablets, and various sensors need to be synchronized with central servers or other devices.
[0005] The patent document with publication number CN110532275A discloses a method for implementing cross-domain data and file update synchronization. The method saves the SQL statement operation log when updating the data on the source database side, and mirrors the SQL statement operation log to the target database; the target database executes the SQL statement operation log to synchronize the data; the file update is to configure the file synchronization server, set the source file library and the target file library, the source file directory and the target file directory that need to be synchronized, and when the file system of the source file library changes, the changed files in the source file library are updated to the target file library at a regular time.
[0006] It can be seen that the following problems exist: the differences between different systems in the prior art may affect the compatibility of the synchronization process, thereby causing problems of low efficiency and low accuracy. Summary of the invention
[0007] To this end, the present invention provides a cross-environment data synchronization method and device to overcome the problem in the prior art that differences between different systems may affect the compatibility of the synchronization process, thereby resulting in low efficiency and low accuracy.
[0008] To achieve the above object, the present invention provides a cross-environment data synchronization method, comprising:
[0009] Step S1, obtaining initial data sets of several environments, constructing several initial databases according to each of the initial data sets, and constructing a cross-environment database according to each of the initial databases, wherein the cross-environment database has a built-in data channel;
[0010] Step S2, acquiring a newly added data set in any of the initial databases to obtain a real-time data set, and querying, based on the fields of the real-time data set, whether there is a data set with the same field in the remaining initial databases;
[0011] Step S3, obtaining the data size, storage time, update frequency and network delay of the real-time data set, calculating a data synchronization priority index according to the data size, the storage time and the update frequency, and determining a data synchronization strategy and a synchronization level strategy according to the data synchronization priority index and the network delay;
[0012] Step S4, synchronizing the data sets of the same field to each initial database in the cross-environment database through the data channel according to the data synchronization strategy and the synchronization level strategy;
[0013] Step S5: During the data synchronization process, the real-time synchronization efficiency of each of the initial databases is monitored in real time, the real-time synchronization efficiency is compared with a preset target synchronization efficiency, and the data synchronization strategy and the synchronization level strategy are adjusted according to the comparison result.
[0014] Furthermore, the process of acquiring any newly added data set in the initial database to obtain a real-time data set includes:
[0015] Determine any one of the initial databases as a source database;
[0016] Identifying a newly added data set by comparing the timestamp of the source database to obtain a real-time data set;
[0017] Extracting the field name, data type and length of the real-time data set to obtain feature results;
[0018] A mapping table is created to map the feature results to the cross-environment database.
[0019] Furthermore, the process of checking whether there are data sets with the same fields in other initial databases according to the fields of the real-time data set includes:
[0020] Through the mapping table, it is queried in the remaining initial databases whether there is a data set with the same field as the real-time data set in the source database, wherein:
[0021] If the initial database and the source database have data sets with the same fields, then a data set matching the real-time data set in the source database is identified;
[0022] If there are no data sets with the same fields in the initial database and the source database, the content of the real-time data set is inserted into the data sets of the remaining initial databases.
[0023] Furthermore, the process of step S3 includes:
[0024] quantify the data size, the storage time and the update frequency respectively to obtain a data size value, a storage time value and an update frequency value correspondingly;
[0025] Assigning a weight to each of the data size value, the storage time value and the update frequency value;
[0026] Calculate the data synchronization priority index according to the data size value and the corresponding weight, the storage time value and the corresponding weight, and the update frequency value and the corresponding weight;
[0027] The data synchronization strategy and the synchronization level strategy are determined according to the calculated data synchronization priority index and the network delay.
[0028] Further, the process of determining the data synchronization strategy and the synchronization level strategy according to the calculated data synchronization priority index and the network delay includes:
[0029] The data synchronization strategy is divided into full synchronization, incremental synchronization and differential synchronization according to the data synchronization priority index and a preset threshold;
[0030] The synchronization level strategy is divided into a first synchronization level, a second synchronization level and a third synchronization level according to the data synchronization strategy and the network delay.
[0031] Furthermore, the process of step S4 includes:
[0032] Identify a data set to be synchronized according to the data synchronization strategy and the synchronization level strategy;
[0033] Determine the synchronization method based on the data set to be synchronized.
[0034] Furthermore, the process of determining the synchronization mode according to the data set to be synchronized includes:
[0035] Using the preset connection parameters, the data set to be synchronized is transferred to each initial database in the cross-environment database through the data channel;
[0036] After synchronization is completed, verify whether the data sets in each initial database are consistent with the real-time data sets;
[0037] If verification fails, the error handling mechanism is triggered.
[0038] Furthermore, the process of step S5 includes:
[0039] Collect and monitor the synchronization status of each initial database in real time;
[0040] Compare the real-time synchronization efficiency with the preset target synchronization efficiency to obtain a comparison result;
[0041] Determine whether to adjust the data synchronization strategy and the synchronization level strategy according to the comparison result.
[0042] Further, the process of determining whether to adjust the data synchronization strategy and the synchronization level strategy according to the comparison result includes:
[0043] If the real-time synchronization efficiency is less than the target synchronization efficiency, the synchronization frequency is increased or resource allocation is improved;
[0044] If the real-time synchronization efficiency is greater than the target synchronization efficiency, the synchronization frequency is reduced or resource allocation is lowered.
[0045] On the other hand, it provides a cross-environment data synchronization device, including:
[0046] A database construction module, which obtains initial data sets of several environments, constructs several initial databases according to each of the initial data sets, and constructs a cross-environment database according to each of the initial databases, wherein the cross-environment database has a built-in data channel;
[0047] A field matching module obtains a data set in any of the newly added initial databases to obtain a real-time data set, and queries other initial databases based on the fields of the real-time data set whether there is a data set with the same field;
[0048] A strategy determination module, which obtains the data size, storage time, update frequency and network delay of the real-time data set, calculates a data synchronization priority index according to the data size, the storage time and the update frequency, and determines a data synchronization strategy and a synchronization level strategy according to the data synchronization priority index and the network delay;
[0049] A data synchronization module, which synchronizes data sets of the same field to each initial database in the cross-environment database through the data channel according to a data synchronization strategy and a synchronization level strategy;
[0050] The status monitoring module monitors the real-time synchronization efficiency of each of the initial databases in real time during the data synchronization process, compares the real-time synchronization efficiency with a preset target synchronization efficiency, and adjusts the data synchronization strategy and the synchronization level strategy according to the comparison result.
[0051] Compared with the prior art, the beneficial effect of the present invention is that, by constructing a cross-environment database and a built-in data channel, the present invention can achieve fast and direct data transmission, reducing the time and resource consumption of data synchronization. In the field inspection process of the real-time data set, it can ensure that only the fields that need to be synchronized will be transmitted, thereby reducing unnecessary data synchronization and improving the efficiency of synchronization. By calculating the data synchronization priority index, the present invention can intelligently determine the priority of synchronization according to factors such as the importance of the data, the update frequency and the storage time, ensuring that the most important data is synchronized first. Determining the data synchronization strategy and the synchronization level strategy in combination with the network delay can make the synchronization process more adaptable to network conditions and reduce the possibility of delays and failures in the synchronization process. In the process of data synchronization, the synchronization status of each initial database is monitored in real time, and compared with the target synchronization efficiency according to the actual situation, the synchronization strategy can be automatically adjusted to ensure the accuracy and real-time performance of data synchronization.
[0052] In particular, by real-time monitoring of newly added data sets in the source database, you can ensure that the data in the cross-environment database is always up to date. This is critical for application scenarios that require rapid response and decision support. Synchronizing only the newly added data sets, rather than the entire database, can significantly reduce the amount of data transmission and processing time, thereby optimizing the use of network and system resources. During the cross-environment database synchronization process, the mapping of feature results can avoid data type mismatches or field mismatches, and reduce data conflicts and errors. Creating a mapping table ensures the consistency of data in different database environments, maintaining the accuracy of the data both in structure and format.
[0053] In particular, by checking whether there are datasets with the same fields as the newly added datasets in the source database in the remaining initial databases, the consistency of all databases at the field level can be ensured. If datasets with the same fields already exist in other initial databases, datasets that match the newly added datasets in the source database can be identified to avoid repeated storage of the same information in the target database and reduce data redundancy. When matching datasets are identified, only the matching datasets can be updated instead of the entire database, which can improve the efficiency and speed of data updates.
[0054] In particular, by quantifying and assigning weights, it is possible to more scientifically determine which data requires a higher synchronization priority, thereby more effectively utilizing resources and improving the efficiency of data synchronization. By determining synchronization strategies based on the importance and update frequency of data, it is possible to ensure that critical data is synchronized in a timely and accurate manner, thereby improving data consistency and integrity. By considering network latency and data synchronization priority, organizations can optimize the use of network resources, reduce unnecessary network bandwidth usage, and reduce network congestion.
[0055] In particular, by selecting the appropriate synchronization strategy based on the importance of the data and the network status, the efficiency of the data synchronization process can be ensured. Full synchronization is used for the initial synchronization of important data or when a large amount of data changes, incremental synchronization is used for medium data changes, and differential synchronization is used for small data changes. This can reduce unnecessary data transmission and save bandwidth and computing resources. Considering the impact of network latency, combining the synchronization strategy with network latency can avoid large amounts of data transmission when the network conditions are poor, reduce network congestion, and improve the overall utilization efficiency of network resources. By combining the data synchronization strategy with the synchronization level strategy, the synchronization strategy can be flexibly adjusted according to different data characteristics and network conditions, so that the system can better adapt to complex and changing operating environments.
[0056] In particular, by identifying key data sets through data synchronization strategies and synchronization level strategies and adopting corresponding synchronization methods, data consistency between different systems can be ensured to avoid business process interruptions or decision-making errors caused by data asynchrony. According to the importance and update frequency of data, reasonable selection of synchronization methods can effectively utilize network and storage resources and avoid unnecessary data transmission and processing.
[0057] In particular, according to the importance and update frequency of the data, choose the synchronization method reasonably, effectively use network and storage resources, and avoid unnecessary data transmission and processing. Through synchronization strategy and level strategy, ensure that the data between different systems are consistent, and avoid business process interruption or decision-making errors caused by data asynchrony. Improve data quality through data verification and conversion during the synchronization process.
[0058] In particular, real-time monitoring and dynamic adjustment ensure data consistency across multiple databases, reducing the risk of data inconsistency. Automatically adjusting synchronization strategies can better adapt to dynamic conditions such as network fluctuations and load changes, maintaining optimal synchronization performance. Timely discovery and resolution of synchronization issues can reduce business interruption time caused by inconsistent data synchronization, and improve business continuity and reliability.
[0059] In particular, by dynamically adjusting the data synchronization strategy and synchronization level strategy based on the comparison results between the real-time synchronization efficiency and the target synchronization efficiency, the data synchronization efficiency can be effectively improved, ensuring data consistency and system reliability, while reducing resource waste, optimizing system performance, improving user experience, and improving system flexibility and adaptability. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] Figure 1 A schematic diagram of a process flow of a cross-environment data synchronization method provided by an embodiment of the present invention;
[0061] Figure 2A schematic diagram of a process of acquiring a newly added data set in any of the initial databases to obtain a real-time data set in the cross-environment data synchronization method provided in an embodiment of the present invention;
[0062] Figure 3 A schematic diagram of the process of step S3 in the cross-environment data synchronization method provided by an embodiment of the present invention;
[0063] Figure 4 A schematic diagram of the structure of a cross-environment data synchronization device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0064] In order to make the objects and advantages of the present invention more clearly understood, the present invention is further described below in conjunction with embodiments; it should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0065] The preferred embodiments of the present invention are described below with reference to the accompanying drawings. It should be understood by those skilled in the art that these embodiments are only used to explain the technical principles of the present invention and are not intended to limit the protection scope of the present invention.
[0066] It should be noted that, in the description of the present invention, terms such as "up", "down", "left", "right", "inside" and "outside" indicating directions or positional relationships are based on the directions or positional relationships shown in the drawings. This is merely for the convenience of description and does not indicate or imply that the device or element must have a specific orientation, be constructed and operated in a specific orientation. Therefore, it cannot be understood as a limitation on the present invention.
[0067] In addition, it should be noted that in the description of the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two components. For those skilled in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0068] See also Figure 1 As shown, the cross-environment data synchronization method provided by the embodiment of the present invention includes:
[0069] Step S1, obtaining initial data sets of several environments, constructing several initial databases according to each of the initial data sets, and constructing a cross-environment database according to each of the initial databases, wherein the cross-environment database has a built-in data channel;
[0070] Step S2, acquiring a newly added data set in any of the initial databases to obtain a real-time data set, and checking whether there is a data set with the same field in the remaining initial databases according to the field of the real-time data set;
[0071] Step S3, obtaining the data size, storage time, update frequency and network delay of the real-time data set, calculating a data synchronization priority index according to the data size, the storage time and the update frequency, and determining a data synchronization strategy and a synchronization level strategy according to the data synchronization priority index and the network delay;
[0072] Step S4, copying the data sets of the same field to each initial database in the cross-environment database through the data channel according to the data synchronization strategy and the synchronization level strategy;
[0073] Step S5: During the data synchronization process, the real-time synchronization efficiency of each of the initial databases is monitored in real time, the real-time synchronization efficiency is compared with a preset target synchronization efficiency, and the data synchronization strategy and the synchronization level strategy are adjusted according to the comparison result.
[0074] Specifically, collect initial data sets in different environments. Establish initial databases for data sets in each environment. Use these initial databases to build a cross-environment central database with built-in data channels for data transmission between different environments. Obtain newly added data sets from any initial database as real-time data sets. Check whether the fields of the real-time data sets exist in other initial databases. Obtain the data size, storage time, update frequency, and network latency of the real-time data sets. Calculate the data synchronization priority index based on the data size, storage time, and update frequency. Determine the data synchronization strategy and synchronization level strategy in combination with the network latency. Based on the calculated data synchronization priority index and synchronization level strategy, copy the data sets with the same fields to all relevant initial databases in the cross-environment database through the built-in data channel. During the data synchronization process, monitor the synchronization status of each initial database in real time. Compare the real-time synchronization efficiency with the preset target synchronization efficiency. Adjust the data synchronization strategy and synchronization level strategy based on the comparison results to ensure the efficiency and accuracy of data synchronization.
[0075] Specifically, by building a cross-environment database and a built-in data channel, the present invention can achieve fast and direct data transmission, reducing the time and resource consumption of data synchronization. In the field inspection process of the real-time data set, it can ensure that only the fields that need to be synchronized will be transmitted, thereby reducing unnecessary data synchronization and improving the efficiency of synchronization. By calculating the data synchronization priority index, the present invention can intelligently determine the priority of synchronization based on factors such as the importance of the data, update frequency, and storage time, ensuring that the most important data is synchronized first. Determining the data synchronization strategy and synchronization level strategy in combination with network delay can make the synchronization process more adaptable to network conditions and reduce the possibility of delays and failures in the synchronization process. During the data synchronization process, the synchronization status of each initial database is monitored in real time, and compared with the target synchronization efficiency based on the actual situation, the synchronization strategy can be automatically adjusted to ensure the accuracy and real-time performance of data synchronization.
[0076] Specifically, if Figure 2 As shown, the process of acquiring any newly added data set in the initial database to obtain a real-time data set includes:
[0077] Step S21, determining any of the initial databases as a source database;
[0078] Step S22, identifying a newly added data set by comparing the timestamp of the source database to obtain a real-time data set;
[0079] Step S23, extracting the field name, data type and length of the real-time data set to obtain a feature result;
[0080] Step S24: create a mapping table to map the feature results to the cross-environment database.
[0081] Specifically, one is selected from multiple initial databases as the source database. The database is marked in the database management system for easy identification and processing. The timestamps of the data sets in the source database are compared to identify the most recently added data sets. Once the newly added data sets are identified, they are marked as real-time data sets. For each real-time data set, the information of all its fields is extracted, including field name, data type, length, etc. The extracted field information is organized into feature results for subsequent mapping and synchronization operations. A mapping table is created to map the field names and data types in the source database to the corresponding fields in the target database (the remaining databases). The generated feature results are mapped to the mapping table to ensure that the fields of the source database and the target database correspond correctly.
[0082] Specifically, by real-time monitoring of newly added data sets in the source database, you can ensure that the data in the cross-environment database is always up to date. This is critical for application scenarios that require rapid response and decision support. Synchronizing only the newly added data sets, rather than the entire database, can significantly reduce the amount of data transmission and processing time, thereby optimizing the use of network and system resources. During the cross-environment database synchronization process, the mapping of feature results can avoid data type mismatches or field mismatches, and reduce data conflicts and errors. Creating a mapping table ensures the consistency of data in different database environments, maintaining the accuracy of the data both in structure and format.
[0083] Specifically, the process of checking whether there is a data set with the same field in the remaining initial databases according to the field of the real-time data set includes:
[0084] Through the mapping table, it is queried in the remaining initial databases whether there is a data set with the same field as the real-time data set in the source database, wherein:
[0085] If the initial database and the source database have data sets with the same fields, then a data set matching the real-time data set in the source database is identified;
[0086] If there are no data sets with the same fields in the initial database and the source database, the content of the real-time data set is inserted into the data sets of the remaining initial databases.
[0087] Specifically, the remaining databases are other initial databases except the source database.
[0088] Specifically, the created mapping table is used to query the remaining initial databases for data sets with the same fields as the newly added data sets in the source database. For each newly added data set in the source database, check whether the data sets in the remaining initial databases contain the same fields. Among the data sets with the same fields, identify the data sets that match the newly added data sets in the source database. For the identified matching data sets, perform an update operation to synchronize the contents of the newly added data sets in the source database to these data sets. Generate corresponding update SQL statements based on the contents of the newly added data sets in the source database. Execute these SQL statements in the target database to update the matching data sets. Among the data sets that do not have the same fields, identify the data sets that need to be added. For the identified data sets that need to be added, insert the contents of the newly added data sets in the source database into these data sets. Generate corresponding insert SQL statements based on the contents of the newly added data sets in the source database. Execute these SQL statements in the remaining initial databases to insert new data sets.
[0089] Specifically, by checking whether there are datasets with the same fields as the newly added datasets in the source database in the remaining initial databases, the consistency of all databases at the field level can be ensured. If datasets with the same fields already exist in other initial databases, datasets that match the newly added datasets in the source database can be identified to avoid repeated storage of the same information in the target database and reduce data redundancy. When matching datasets are identified, only the matching datasets can be updated instead of the entire database, which can improve the efficiency and speed of data updates.
[0090] Specifically, if Figure 3 As shown, the process of step S3 includes:
[0091] Step S31, quantifying the data size, the storage time and the update frequency respectively to obtain a data size value, a storage time value and an update frequency value correspondingly;
[0092] Step S32, assigning a weight to each of the data size value, the storage time value and the update frequency value;
[0093] Step S33, calculating the data synchronization priority index according to the data size value and the corresponding weight, the storage time value and the corresponding weight, and the update frequency value and the corresponding weight;
[0094] Step S34: determining the data synchronization strategy and the synchronization level strategy according to the calculated data synchronization priority index and the network delay.
[0095] Specifically, according to the size range of the data set, it is divided into several categories, such as less than 1GB, 1GB-10GB, 10GB-100GB, and more than 100GB, and then a value is assigned to each category. Similarly, according to the length of storage time, such as less than 1 hour, 1 hour-4 hours, 4 hours-24 hours, and more than 24 hours, a value is assigned to each interval. According to the update frequency, such as low (< daily), medium (daily), and high (hourly or more frequently), a value is assigned to each frequency. Next, a weight is assigned to each quantified value. The weight reflects the importance of the factor in the data synchronization decision. For example:
[0096] Data Size Weight (W_DS): Might be set to a higher value as it can have a greater impact on network bandwidth and storage resources.
[0097] Weight of Storage Time (W_ST): This may be set to a medium value, as it affects the freshness of the data, but is not as critical as the size of the data and the frequency of updates.
[0098] Update Frequency Weight (W_UF): This may be set to a high value, as frequently updated data requires faster synchronization and more frequent checks.
[0099] The data synchronization priority index (PD) is calculated using the following formula:
[0100] PD=(DS×W_DS)+(ST×W_ST)+(UF×W_UF), where DS is the data size value, ST is the storage time value, and UF is the update frequency value.
[0101] Finally, the data synchronization strategy and synchronization level strategy are determined according to the calculated data synchronization priority index (PD) and network delay (NL). Network delay can be a quantitative value indicating the transmission time of data from source to destination.
[0102] In this embodiment, the data size value DS is quantified: greater than 0 and less than 1GB: classified as category 1; greater than or equal to 1GB and less than 10GB: classified as category 2; greater than or equal to 10GB and less than 100GB: classified as category 3; 100GB and above: classified as category 4.
[0103] The storage time value ST is quantified: less than 1 hour: classified as category 1; greater than or equal to 1 hour and less than 4 hours: classified as category 2; greater than or equal to 4 hours and less than 24 hours: classified as category 3; 24 hours and above: classified as category 4.
[0104] The update frequency value UF is quantified as follows: low (greater than daily): classified as category 1; medium (daily): classified as category 2; high (less than daily): classified as category 3.
[0105] Assume that the values of each category are: Category 1: 1; Category 2: 2; Category 3: 3; Category 4: 4.
[0106] Now, assign weights to each factor: W_DS: 0.3; W_ST: 0.2; W_UF: 0.5.
[0107] Next, calculate PD: PD = (DS × W_DS) + (ST × W_ST) + (UF × W_UF).
[0108] Assume that the following data set attributes are available: data size DS: 500MB (category 2); storage time ST: 24 hours (category 3); update frequency UF: every day (category 2).
[0109] Substitute the category values into the calculation of PD: PD=(2×0.3)+(3×0.2)+(2×0.5)=2.2.
[0110] Considering network latency (NL), assume that the quantified value of network latency is 50 ms (this is an assumed value, and it needs to be measured according to the actual situation in practical applications).
[0111] Finally, determine the data synchronization strategy and synchronization level strategy based on the calculated data synchronization priority index (PD) and network latency (NL). For example, if PD is high, a faster synchronization speed and higher priority may be required; if NL is high, it may be necessary to consider optimizing network bandwidth or scheduling synchronization during better network conditions.
[0112] Specifically, through quantification and weight assignment, it is possible to more scientifically determine which data requires a higher synchronization priority, thereby more effectively utilizing resources and improving the efficiency of data synchronization. By determining the synchronization strategy based on the importance and update frequency of the data, it is possible to ensure that critical data is synchronized in a timely and accurate manner, thereby improving data consistency and integrity. By considering network latency and data synchronization priority, organizations can optimize the use of network resources, reduce unnecessary network bandwidth occupancy, and reduce network congestion.
[0113] Specifically, the process of determining the data synchronization strategy and the synchronization level strategy based on the calculated data synchronization priority index and the network latency includes:
[0114] Classify the data synchronization strategy into full synchronization, incremental synchronization, and differential synchronization according to the data synchronization priority index and a preset threshold;
[0115] Classify the synchronization level strategy into a first synchronization level, a second synchronization level, and a third synchronization level according to the data synchronization strategy and the network latency.
[0116] Specifically, for full synchronization: when PD exceeds a high threshold (PD > 2.5), it indicates that the data set is very important and needs to be updated frequently. Therefore, full synchronization is selected, that is, all data is transmitted each time synchronization occurs.
[0117] For incremental synchronization: when PD is between a medium threshold and a high threshold (1.5 < PD ≤ 2.5), it indicates that the data set is relatively important but not updated in real time. Therefore, incremental synchronization is selected, that is, only the data that has changed since the last synchronization is transmitted.
[0118] For differential synchronization: when PD is below the medium threshold (PD ≤ 1.5), it indicates that the data set is less important or updated infrequently. Therefore, differential synchronization is selected, that is, only the differential data, usually the data of the most recent change, is transmitted.
[0119] Next, determine the synchronization level strategy based on the selected data synchronization strategy and network latency.
[0120] First synchronization level: If full synchronization or incremental synchronization is selected and the network latency is low (latency < 100 ms), the synchronization level of the dataset is the first synchronization level, indicating that synchronization is required as soon as possible.
[0121] Second synchronization level: If full synchronization or incremental synchronization is selected but the network latency is high (100 ms ≤ latency < 500 ms), the synchronization level of the dataset is the second synchronization level, indicating that synchronization can be performed over a longer period of time.
[0122] Third synchronization level: If differential synchronization is selected, regardless of the network latency, the synchronization level of the dataset is the third synchronization level, indicating that synchronization can be performed over the longest period of time.
[0123] In this embodiment, assume there are two datasets D1 and D2, as well as their PD values and network latencies.
[0124] Dataset D1: PD = 2.8; Network latency = 50 ms.
[0125] Dataset D2: PD = 1.7; Network latency = 200 ms.
[0126] Select a synchronization strategy according to a preset threshold.
[0127] High threshold (PD > 2.5): 2.8 > 2.5, so for dataset D1, select the full synchronization strategy.
[0128] Medium threshold (1.5 < PD ≤ 2.5): 1.7 < 1.5, so for dataset D2, select the differential synchronization strategy.
[0129] For dataset D1 (full synchronization), the network latency is 50 ms, which is low latency, so the synchronization level is the first synchronization level.
[0130] For dataset D2 (differential synchronization), the network latency is 200 ms, which is medium latency, so the synchronization level is the second synchronization level.
[0131] Specifically, by selecting the appropriate synchronization strategy based on the importance of the data and the network status, the efficiency of the data synchronization process can be ensured. Full synchronization is used for the initial synchronization of important data or when a large amount of data changes, incremental synchronization is used for medium data changes, and differential synchronization is used for small data changes. This can reduce unnecessary data transmission and save bandwidth and computing resources. Considering the impact of network latency, combining the synchronization strategy with network latency can avoid large amounts of data transmission when the network conditions are poor, reduce network congestion, and improve the overall utilization efficiency of network resources. By combining the data synchronization strategy with the synchronization level strategy, the synchronization strategy can be flexibly adjusted according to different data characteristics and network conditions, so that the system can better adapt to complex and changing operating environments.
[0132] Specifically, the process of step S4 includes:
[0133] Identify a data set to be synchronized according to the data synchronization strategy and the synchronization level strategy;
[0134] Determine the synchronization method based on the data set to be synchronized.
[0135] Specifically, analyze the importance and update frequency of the data according to the data synchronization strategy. Determine the synchronization level of the data, and determine which data sets need to be synchronized according to the strategy, such as data that has been updated within the last week or data sets that are critical to business operations. For the identified data sets to be synchronized, select the appropriate synchronization method based on their characteristics and synchronization requirements. Synchronization methods may include real-time synchronization, scheduled synchronization, manual synchronization, etc. For data with high real-time requirements, real-time synchronization is used; for data with low update frequency, scheduled synchronization may be used. Execute the selected synchronization method to ensure that data is transmitted accurately between the source system and the target system. Data conversion may be required during the synchronization process to ensure data consistency between different systems.
[0136] Specifically, by identifying key data sets through data synchronization strategies and synchronization level strategies and adopting corresponding synchronization methods, we can ensure that data between different systems remain consistent and avoid business process interruptions or decision-making errors caused by data asynchrony. According to the importance and update frequency of data, reasonable selection of synchronization methods can effectively utilize network and storage resources and avoid unnecessary data transmission and processing.
[0137] Specifically, the process of determining the synchronization mode according to the data set to be synchronized includes:
[0138] Using the preset connection parameters, the data set to be synchronized is transferred to each initial database in the cross-environment database through the data channel;
[0139] After synchronization is completed, verify whether the data sets in each initial database are consistent with the real-time data sets;
[0140] If verification fails, the error handling mechanism is triggered.
[0141] Specifically, according to the preset connection parameters, configure the network connection and data channel used for data synchronization. Ensure that the connection parameters include the necessary authentication information, port number, host address, etc. to establish a secure and stable data transmission channel. Use the configured data channel to transfer the data set to be synchronized from the source system to each initial database in the cross-environment database. Monitor the data transmission process, record the start and end time of the transmission, and the problems encountered during the transmission process. After the synchronization is completed, compare the data set in each initial database with the real-time data set in the source system to ensure data consistency. You can use data checksum comparison algorithms, such as hash value comparison, data content comparison, etc., to verify data consistency. Check whether the data set in each initial database meets the predetermined data consistency requirements. If the verification fails, it means that there may be a problem in the data synchronization process, which requires further investigation and processing. If the data verification fails, the error handling mechanism is triggered immediately. The error handling mechanism may include logging errors, sending alerts, automatically trying to resynchronize data, notifying administrators, etc. Investigate the synchronization failure that triggered the error handling mechanism. Based on the investigation results, take appropriate repair measures, such as repairing data channel problems, adjusting synchronization strategies, and recovering data. Whether the synchronization succeeds or fails, the results of the synchronization should be recorded.
[0142] In this embodiment, the data synchronization strategy determines that the data set to be synchronized is all order records created in the last 24 hours. The synchronization level strategy classifies order data as high priority because order data is critical to order processing and customer service. Since order data needs to be updated in real time, the real-time synchronization method is selected. Using the preset connection parameters, the order data is transferred from the front-end system to the back-end database through a dedicated data transmission API. Through the data channel, each order data is transmitted to the back-end database within 1 second after creation. At the same time, the same order data is transmitted to the database of the analysis system through another dedicated connection parameter. After the synchronization is completed, the hash value comparison algorithm is used to verify the consistency of the order data in the back-end database and the analysis system database with the original order data. Assuming that all transmitted data has a unique hash value, the system will compare the stored hash value to ensure data consistency. The inspection results show that all transmitted order data is consistent with the original data. The verification is successful, the system records the synchronization success, and notifies the relevant system that the data has been updated. Assume that in one synchronization, due to network problems, some order data is not successfully transmitted to the back-end database. Data verification finds consistency problems and triggers an error handling mechanism. The system log records the details of the synchronization failure, including the failed order ID and the reason for the failure (network problem). The system automatically attempts to resynchronize the failed order data and notifies the administrator for manual intervention after multiple failures. The synchronization results are recorded in the synchronization log, including the start time, end time, number of orders successfully synchronized, number of orders that failed to synchronize, and the reason.
[0143] Specifically, according to the importance and update frequency of the data, choose the synchronization method reasonably, effectively use the network and storage resources, and avoid unnecessary data transmission and processing. Through synchronization strategy and level strategy, ensure that the data between different systems are consistent, and avoid business process interruption or decision-making errors caused by data asynchrony. Improve data quality through data verification and conversion during the synchronization process.
[0144] Specifically, the process of step S5 includes:
[0145] Collect and monitor the synchronization status of each initial database in real time;
[0146] Compare the real-time synchronization efficiency with the preset target synchronization efficiency to obtain a comparison result;
[0147] Determine whether to adjust the data synchronization strategy and the synchronization level strategy according to the comparison result.
[0148] Specifically, a dedicated monitoring tool or software is deployed in each initial database to collect the synchronization status data of the database in real time. The monitoring tool collects the synchronization status information of the database regularly or in real time, including data update time, difference size, data conflict, etc. The collected synchronization status data is stored in the central monitoring system for analysis and comparison. The database synchronization status is displayed in real time through a graphical interface or command line tool so that operators can find problems in time. According to business needs and acceptable data consistency levels, a preset target synchronization efficiency is set as a reference standard. The real-time synchronization efficiency data is compared with the target synchronization efficiency to calculate the difference or deviation of the synchronization status. The comparison results are presented in the form of numerical values, graphics or alarms to quickly identify whether the synchronization status meets expectations. The comparison results are analyzed to determine the gap between the synchronization status and the target status, and to identify the possible causes of the gap. Based on the analysis results, decide whether the data synchronization strategy and synchronization level strategy need to be adjusted.
[0149] Specifically, through real-time monitoring and dynamic adjustment, data consistency is ensured across multiple databases, reducing the risk of data inconsistency. By automatically adjusting synchronization strategies, it is possible to better adapt to dynamic conditions such as network fluctuations and load changes, and maintain optimal synchronization performance. Synchronization problems can be discovered and resolved in a timely manner, reducing business interruption time caused by inconsistent data synchronization, and improving business continuity and reliability.
[0150] Specifically, the process of determining whether to adjust the data synchronization strategy and the synchronization level strategy according to the comparison result includes:
[0151] If the real-time synchronization efficiency is less than the target synchronization efficiency, the synchronization frequency is increased or resource allocation is improved;
[0152] If the real-time synchronization efficiency is greater than the target synchronization efficiency, the synchronization frequency is reduced or resource allocation is lowered.
[0153] Specifically, compare the real-time synchronization efficiency with the target synchronization efficiency to determine the degree of data synchronization lag. When the real-time synchronization efficiency is lower than the target synchronization efficiency, analyze the reasons for the synchronization lag, including but not limited to network delay, database performance issues, large data volume, etc. According to the analysis results, adjust the data synchronization strategy, such as increasing the synchronization frequency, optimizing the data processing flow, or improving resource allocation. Implement the adjusted synchronization strategy, and continuously monitor the changes in the synchronization status to ensure that the adjustment measures can effectively reduce the synchronization lag and achieve the target synchronization efficiency. When the real-time synchronization efficiency is higher than the target synchronization efficiency, analyze the reasons for the synchronization advance, including but not limited to small data volume, network acceleration, etc. According to the analysis results, adjust the data synchronization strategy, such as reducing the synchronization frequency, optimizing the data processing flow, or reducing resource allocation. Implement the adjusted synchronization strategy, and continuously monitor the changes in the synchronization status to ensure that the adjustment measures can effectively avoid unnecessary synchronization advance and maintain a reasonable synchronization state.
[0154] Specifically, by dynamically adjusting the data synchronization strategy and synchronization level strategy based on the comparison results of the real-time synchronization efficiency and the target synchronization efficiency, the data synchronization efficiency can be effectively improved, ensuring data consistency and system reliability, while reducing resource waste, optimizing system performance, improving user experience, and improving system flexibility and adaptability.
[0155] Specifically, if Figure 4 As shown, the cross-environment data synchronization device provided by the embodiment of the present invention includes:
[0156] A database construction module 10, which obtains initial data sets of several environments, constructs several initial databases according to the initial data sets, and constructs a cross-environment database according to the initial databases, wherein the cross-environment database has a built-in data channel;
[0157] The field matching module 20 obtains a data set in any of the newly added initial databases to obtain a real-time data set, and queries other initial databases based on the fields of the real-time data set whether there is a data set with the same field;
[0158] A strategy determination module 30 obtains the data size, storage time, update frequency and network delay of the real-time data set, calculates a data synchronization priority index according to the data size, the storage time and the update frequency, and determines a data synchronization strategy and a synchronization level strategy according to the data synchronization priority index and the network delay;
[0159] A data synchronization module 40 synchronizes data sets of the same field to each initial database in the cross-environment database through the data channel according to a data synchronization strategy and a synchronization level strategy;
[0160] The status monitoring module 50 monitors the real-time synchronization efficiency of each of the initial databases in real time during the data synchronization process, compares the real-time synchronization efficiency with a preset target synchronization efficiency, and adjusts the data synchronization strategy and the synchronization level strategy according to the comparison result.
[0161] Specifically, the cross-environment data synchronization device provided by the embodiment of the present invention can execute the above-mentioned cross-environment data synchronization method to achieve the same technical effect, which will not be repeated here.
[0162] So far, the technical solutions of the present invention have been described in conjunction with the preferred embodiments shown in the accompanying drawings. However, it is easy for those skilled in the art to understand that the protection scope of the present invention is obviously not limited to these specific embodiments. Without departing from the principle of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after these changes or substitutions will fall within the protection scope of the present invention.
[0163] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for synchronizing data across environments. It is characterized in that include: Step S1, obtaining initial data sets of several environments, constructing several initial databases according to each of the initial data sets, and constructing a cross-environment database according to each of the initial databases, wherein the cross-environment database has a built-in data channel; Step S2, acquiring a newly added data set in any of the initial databases to obtain a real-time data set, and querying, based on the fields of the real-time data set, whether there is a data set with the same field in the remaining initial databases; Step S3, obtaining the data size, storage time, update frequency and network delay of the real-time data set, calculating a data synchronization priority index according to the data size, the storage time and the update frequency, and determining a data synchronization strategy and a synchronization level strategy according to the data synchronization priority index and the network delay; Step S4, synchronizing the data sets of the same field in the real-time data set to each initial database in the cross-environment database through the data channel according to the data synchronization strategy and the synchronization level strategy; Step S5: during the data synchronization process, monitor the real-time synchronization efficiency of each of the initial databases in real time, compare the real-time synchronization efficiency with a preset target synchronization efficiency, and adjust the data synchronization strategy and the synchronization level strategy according to the comparison result; The process of step S3 includes: quantify the data size, the storage time and the update frequency respectively to obtain a data size value, a storage time value and an update frequency value correspondingly; Assigning a weight to each of the data size value, the storage time value and the update frequency value; Calculate the data synchronization priority index according to the data size value and the corresponding weight, the storage time value and the corresponding weight, and the update frequency value and the corresponding weight; Determine the data synchronization strategy and the synchronization level strategy according to the calculated data synchronization priority index and the network delay; The process of determining the data synchronization strategy and the synchronization level strategy according to the calculated data synchronization priority index and the network delay includes: The data synchronization strategy is divided into full synchronization, incremental synchronization and differential synchronization according to the data synchronization priority index and a preset threshold; According to the data synchronization strategy and the network delay, the synchronization level strategy is divided into a first synchronization level, a second synchronization level and a third synchronization level; If full synchronization or incremental synchronization is selected and the network delay is less than 100ms, the synchronization level of the dataset is the first synchronization level, which means that synchronization is required as soon as possible; If full synchronization or incremental synchronization is selected, but the network delay is 100ms≤<500ms, the synchronization level of the dataset is the second synchronization level, which means that synchronization can be performed in a longer period of time; If differential synchronization is selected, the synchronization level of the data set is the third synchronization level, which means it can be synchronized in the longest time, regardless of the network delay.
2. The cross-environment data synchronization method according to claim 1, It is characterized in that The process of acquiring any newly added data set in the initial database to obtain a real-time data set includes: Determine any one of the initial databases as a source database; Identifying a newly added data set by comparing the timestamp of the source database to obtain a real-time data set; Extracting the field name, data type and length of the real-time data set to obtain feature results; A mapping table is created to map the feature results to the cross-environment database.
3. The cross-environment data synchronization method according to claim 2, It is characterized in that The process of checking whether there is a data set with the same field in the remaining initial databases according to the field of the real-time data set includes: Through the mapping table, it is queried in the remaining initial databases whether there is a data set with the same field as the real-time data set in the source database, wherein: If the initial database and the source database have data sets with the same fields, then a data set matching the real-time data set in the source database is identified; If there are no data sets with the same fields in the initial database and the source database, the content of the real-time data set is inserted into the data sets of the remaining initial databases.
4. The cross-environment data synchronization method according to claim 3, It is characterized in that The process of step S4 includes: Identify a data set to be synchronized according to the data synchronization strategy and the synchronization level strategy; Determine the synchronization method based on the data set to be synchronized.
5. The cross-environment data synchronization method according to claim 4, It is characterized in that The process of determining the synchronization mode according to the data set to be synchronized includes: Using the preset connection parameters, the data set to be synchronized is transferred to each initial database in the cross-environment database through the data channel; After synchronization is completed, verify whether the data sets in each initial database are consistent with the real-time data sets; If verification fails, the error handling mechanism is triggered.
6. The cross-environment data synchronization method according to claim 5, It is characterized in that The process of step S5 includes: Collect and monitor the synchronization status of each initial database in real time; Compare the real-time synchronization efficiency with the preset target synchronization efficiency to obtain a comparison result; Determine whether to adjust the data synchronization strategy and the synchronization level strategy according to the comparison result.
7. The cross-environment data synchronization method according to claim 6, It is characterized in that The process of determining whether to adjust the data synchronization strategy and the synchronization level strategy according to the comparison result includes: If the real-time synchronization efficiency is less than the target synchronization efficiency, the synchronization frequency is increased or resource allocation is improved; If the real-time synchronization efficiency is greater than the target synchronization efficiency, the synchronization frequency is reduced or resource allocation is lowered.
8. A cross-environment data synchronization device based on the cross-environment data synchronization method according to any one of claims 1 to 7, It is characterized in that include: A database construction module, which obtains initial data sets of several environments, constructs several initial databases according to each of the initial data sets, and constructs a cross-environment database according to each of the initial databases, wherein the cross-environment database has a built-in data channel; A field matching module obtains a data set in any of the newly added initial databases to obtain a real-time data set, and queries other initial databases based on the fields of the real-time data set whether there is a data set with the same field; A strategy determination module, which obtains the data size, storage time, update frequency and network delay of the real-time data set, calculates a data synchronization priority index according to the data size, the storage time and the update frequency, and determines a data synchronization strategy and a synchronization level strategy according to the data synchronization priority index and the network delay; A data synchronization module, which synchronizes data sets of the same field to each initial database in the cross-environment database through the data channel according to a data synchronization strategy and a synchronization level strategy; The status monitoring module monitors the real-time synchronization efficiency of each of the initial databases in real time during the data synchronization process, compares the real-time synchronization efficiency with a preset target synchronization efficiency, and adjusts the data synchronization strategy and the synchronization level strategy according to the comparison result.
