SQL Server-based instance object synchronous disaster recovery method and apparatus, and computer device

By obtaining and comparing the asset configuration information of the SQL Server source and target instances and synchronizing the different instance objects, the problem of lack of global system-level server object synchronization in the existing technology is solved, and efficient and reliable SQL Server instance objects are realized. Synchronous disaster recovery.

CN119356950AInactive Publication Date: 2025-01-24HANGZHOU MEICHUANG DIGITAL INTELLIGENCE TECHNOLOGY CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411940385.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-26
Publication Date
2025-01-24
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing SQL Server high availability scheme lacks synchronization of the global system-level server objects of SQL Server instances during disaster recovery, resulting in manual checking whether the configuration information in the main and backup instances is consistent before disaster recovery switching, which is time-consuming and easy. An error occurred.

Method used

By obtaining the asset allocation information of the SQL Server source and the target -side instance, matching the relationship between disaster recovery, select an instance object that needs to be synchronized and configures synchronization strategies, collects and compare data, and synchronizes differently. Provide abnormal warning.

Benefits of technology

It realizes efficient, reliable and customizable synchronous disaster recovery of SQL Server instance objects, reduces manual intervention, improves data consistency and recovery speed, and reduces the risk of data loss.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119356950A_ABST
    Figure CN119356950A_ABST
Patent Text Reader

Abstract

The invention discloses an instance object synchronous disaster recovery method and device based on an SQL Server and computer equipment. The method comprises the following steps: acquiring asset configuration information of an SQL Server source end instance and an SQL Server target end instance, and matching a disaster recovery pair relationship to obtain a source end and a target end; an instance object needing to be synchronized is selected, and a synchronization strategy is configured; respectively collecting data of instance objects needing to be synchronized from the source end instance and the target end instance according to a synchronization strategy, and comparing to obtain a comparison result; according to the comparison result, synchronizing different instance objects into target end instances in batches by adopting a synchronization strategy to obtain a synchronization result; and the synchronization result is displayed, and when an abnormal condition occurs in the synchronization process, early warning of the abnormal condition is carried out. By implementing the method provided by the invention, more efficient, reliable and customizable disaster recovery of SQL Server instance object synchronization can be realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a disaster recovery method for an IT system, and more specifically to an instance object synchronization disaster recovery method, device and computer equipment based on SQL Server. Background Art

[0002] SQL Server provides a variety of high availability and disaster recovery solutions to ensure that the database can be quickly recovered and maintained in the event of a failure or disaster. The following are some common SQL Server high availability solutions: Database mirroring is a real-time synchronization technology that keeps data synchronized by transferring logs between the primary database and the mirror database. The mirror database can quickly take over the work of the primary database to achieve high availability. Its advantages are simple configuration and support for fast failover, but its disadvantages are that it cannot achieve read-write separation and the business of the mirror database is unreadable.

[0003] AlwaysOn Availability Groups, a high availability and disaster recovery solution introduced in SQL Server 2012, achieves high availability by performing synchronous replication between multiple databases, and supports read-write separation and multi-site deployment. Its advantages include support for read-write separation and multi-site deployment, while providing fast failover, but the configuration is relatively complex and requires the support of Windows Server Failover Cluster.

[0004] AlwaysOn Failover Cluster Instance, a SQLServer instance-level high availability solution based on Windows Server Failover Cluster, implements failover by sharing storage between multiple nodes. Its advantages are that it can provide instance-level high availability and support multiple nodes, but its disadvantages are that it requires shared storage and is relatively complex to configure.

[0005] Backup and recovery, although not a strictly high availability solution, is an important means of disaster recovery. By backing up the database regularly and restoring it when a disaster occurs, data loss can be minimized. Its advantages are that it is simple and easy to use and supports multiple backup strategies.

[0006] Although the existing SQL Server high availability solutions meet the disaster recovery needs of business systems to a certain extent, there are still some shortcomings. For example, the recovery time of the backup and recovery methods is long, and there is a risk of data loss. Although database mirroring and AlwaysOn availability groups provide data synchronization and disaster recovery switching capabilities for user databases, they lack synchronization of global system-level server objects of SQL Server instances, such as login accounts, server configuration information, credentials, linked servers, jobs, Service Broker applications, and server-level triggers. This deficiency requires database administrators to manually check whether the above configuration information in the primary and standby instances is consistent before performing disaster recovery switching when some applications rely on information, entities, or objects outside the scope of a single user database. This process is time-consuming and error-prone.

[0007] Therefore, it is necessary to design a new method to achieve more efficient, reliable and customizable disaster recovery for SQL Server instance object synchronization. Summary of the invention

[0008] The purpose of the present invention is to overcome the defects of the prior art and provide a method, device and computer equipment for instance object synchronization disaster recovery based on SQL Server.

[0009] To achieve the above object, the present invention adopts the following technical solution: a method for synchronizing disaster recovery of instance objects based on SQL Server, comprising: Obtain the asset configuration information of the SQL Server source and target instances, and match the disaster recovery pair relationship to obtain the source and target. Select the instance object that needs to be synchronized and configure the synchronization strategy; Collecting data of instance objects to be synchronized from the source and target instances according to the synchronization strategy, and comparing them to obtain a comparison result; According to the comparison result, a synchronization strategy is adopted to batch synchronize instance objects with differences to the target end instance to obtain a synchronization result; The synchronization results are displayed, and an abnormal situation warning is issued when an abnormal situation occurs during the synchronization process.

[0010] A further technical solution is: the asset configuration information of the SQL Server source and target instances is obtained, and the disaster recovery pair relationship is matched to obtain the source and target instances, including: Add the asset configuration information of the SQL Server source and target instances; the asset configuration information includes the access address, port, user name, and password; When the host and the instance are connected normally, the primary and secondary detection logic is used to identify and match the disaster recovery pair relationship of the asset configuration information to determine the source end and the target end.

[0011] Its further technical solution is: the instance objects that need to be synchronized include server configuration, linked servers, jobs, login names, permissions, Service Broker applications, and server-level triggers, and the synchronization strategy includes a strategy for setting the collection frequency by minutes, hours, days, or weeks.

[0012] A further technical solution is: collecting data of instance objects to be synchronized from the source and target end instances according to the synchronization strategy, and comparing them to obtain a comparison result, including: Extracting the view or stored procedure of the corresponding instance object from the instances of the source and target ends according to the synchronization strategy to obtain the data of the instance object that needs to be synchronized on the source end and the data of all instance objects on the target end; The data of the instance objects that need to be synchronized on the source side are traversed in a loop, and the data of the instance objects that need to be synchronized on the source side are comprehensively compared with the data of all instance objects on the target side to obtain a comparison result.

[0013] A further technical solution is: the loop traverses the data of the instance objects that need to be synchronized on the source side, and comprehensively compares the data of the instance objects that need to be synchronized on the source side with the data of all instance objects on the target side to obtain a comparison result, including: Traverse the source end instance object, extract the metadata of the source end instance object, and then traverse the target end instance object to extract the metadata of the target end instance object; The identifier and object name of the instance object to be synchronized on the source side and the identifier and object name of all instance objects on the target side are used as key values ​​to obtain the source side key value and the target side key value; Using the source end key value as a comparison basis, filtering out the key value corresponding to the instance object in the target end that has the same name as the instance object corresponding to the source end key value; Determine whether the corresponding target key value is the same as the source key value; If the corresponding target end key value is the same as the source end key value, then when the details of the data of the corresponding instance object on the source end are different from the details of the data of the corresponding instance object on the target end, the two instance objects are marked as object modification to obtain a comparison result; If the corresponding target-side key value is different from the source-side key value, the corresponding instance object on the source side is marked as newly added object to obtain the comparison result.

[0014] A further technical solution is: batch synchronizing instance objects with differences to the target end instance according to the comparison result to obtain the synchronization result, including: According to the instance objects marked as object modification in the comparison results, the corresponding data is deleted from the target end; Select instance objects marked as object addition and object modification in batches from the source end, and write a DDL script to generate metadata definitions of CREATE objects; Use the script to connect to the target end, and batch import the script to synchronize instance object data that does not exist or has inconsistent metadata information to obtain synchronization results.

[0015] A further technical solution is: the synchronization result is displayed, and when an abnormal situation occurs during the synchronization process, an abnormal situation is warned, including: Display the synchronization results and provide alarm reminders when synchronization is abnormal. Specifically record the time and result status of the most recent synchronization, including the object name and quantity on the source and target ends. If the synchronization result is unsuccessful, or the most recent synchronization time exceeds the preset alarm threshold, or there are objects on the source end that are missing on the target end or the metadata is inconsistent, an alarm is triggered.

[0016] The present invention also provides an instance object synchronization disaster recovery device based on SQL Server, comprising: An acquisition unit is used to acquire asset configuration information of the SQL Server source and target instances, and match the disaster recovery pair relationship to obtain the source and target instances; A selection unit is used to select the instance object to be synchronized and configure the synchronization strategy; A comparison unit, used to collect data of instance objects to be synchronized from the source end and the target end instances according to the synchronization strategy, and compare them to obtain a comparison result; A synchronization unit, used to synchronize instance objects with differences to the target end instance in batches by adopting a synchronization strategy according to the comparison result, so as to obtain a synchronization result; The display unit is used to display the synchronization result and issue an early warning of abnormal situation when an abnormal situation occurs during the synchronization process.

[0017] The present invention further provides a computer device, which includes a memory and a processor. The memory stores a computer program, and the processor implements the above method when executing the computer program.

[0018] The present invention also provides a storage medium, wherein the storage medium stores a computer program, and the computer program implements the above method when executed by a processor.

[0019] Compared with the prior art, the beneficial effects of the present invention are as follows: the present invention obtains the asset configuration information of the SQL Server instances at the source and target ends, matches the disaster recovery relationship, and clarifies the synchronization object; the user can select the instance object to be synchronized and configure the corresponding synchronization strategy; then, the system collects and compares the data at the source and target ends according to the synchronization strategy to identify the difference; finally, the difference objects are synchronized in batches according to the comparison results, and abnormal warnings are provided during the synchronization process, ensuring that the entire process is efficient, reliable and customizable.

[0020] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying any creative work.

[0022] Figure 1 A schematic diagram of an application scenario of a SQL Server-based instance object synchronization disaster recovery method provided in an embodiment of the present invention; Figure 2 A flowchart of a SQL Server-based instance object synchronization disaster recovery method provided in an embodiment of the present invention; Figure 3 A schematic diagram of a sub-process of a SQL Server-based instance object synchronization disaster recovery method provided in an embodiment of the present invention; Figure 4 A schematic diagram of a sub-process of a SQL Server-based instance object synchronization disaster recovery method provided in an embodiment of the present invention; Figure 5 A schematic diagram of a sub-process of a SQL Server-based instance object synchronization disaster recovery method provided in an embodiment of the present invention; Figure 6 A schematic diagram of a sub-process of a SQL Server-based instance object synchronization disaster recovery method provided in an embodiment of the present invention; Figure 7 A schematic block diagram of an instance object synchronization disaster recovery device based on SQL Server provided in an embodiment of the present invention; Figure 8 A schematic block diagram of a computer device provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0023] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0024] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.

[0025] It should also be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.

[0026] It should be further understood that the term "and / or" used in the present description and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.

[0027] See also Figure 1 and Figure 2 , Figure 1 A schematic diagram of an application scenario of a SQL Server-based instance object synchronization disaster recovery method provided in an embodiment of the present invention. Figure 2 A schematic flow chart of a SQL Server-based instance object synchronization disaster recovery method provided in an embodiment of the present invention. The SQL Server-based instance object synchronization disaster recovery method is applied to a server. The server interacts with the SQL Server system, obtains asset configuration information from the SQL Server source and target instances, matches the disaster recovery relationship, and selects synchronized instance objects and policies. Data is collected and compared according to the synchronization policy, and then the difference objects are synchronized to the target end in batches. The synchronization results are displayed and an early warning is issued when an abnormality occurs. A more efficient, reliable, and customizable SQL Server instance object synchronization disaster recovery is achieved.

[0028] Figure 2 FIG. 1 is a flow chart of a method for synchronizing and recovering an instance object based on SQL Server provided in an embodiment of the present invention. Figure 2 As shown, the method includes the following steps S110 to S150.

[0029] S110. Obtain asset configuration information of the SQL Server source and target instances, and match the disaster recovery pair relationship to obtain the source and target instances.

[0030] In this embodiment, the source end refers to the original location of the data or the database instance, and the target end is the database instance to which the data is to be synchronized or backed up.

[0031] In one embodiment, see Figure 3 , the above-mentioned step S110 may include steps S111~S112.

[0032] S111. Add asset configuration information of the SQL Server source and target instances; wherein the asset configuration information includes access address, port, user name, and password.

[0033] In this embodiment, the asset configuration information of the source and target instances of SQL Server is entered respectively, and the normality of the host and instance connection is first verified using the entered configuration information. This step is the basis for ensuring the smooth progress of subsequent operations; Specifically, the content of asset allocation information: Access address: The network address used to connect to the database.

[0034] Instance port: The port number that the database service listens on.

[0035] Username and Password: Database user credentials for authentication.

[0036] S112: When the host and the instance are connected normally, the primary and secondary detection logic is used to identify and match the disaster recovery pair relationship of the asset configuration information to determine the source end and the target end.

[0037] In this embodiment, once the connection verification is passed, the system will identify the disaster recovery pair relationship between the source and target ends based on the master-slave detection logic. This logic usually includes: AlwaysOn Availability Groups: A SQL Server feature for high availability and disaster recovery that enables multiple databases to be managed and failed over as a unit.

[0038] Database mirroring: Another disaster recovery technology that allows data to be replicated between a primary database and a standby database.

[0039] The following database objects are queried for information about availability groups, availability replicas, availability databases, and mirror databases: Availability group: includes the defined relationship between the primary database and the standby database.

[0040] Availability replicas: Displays the replica status of the database in different instances.

[0041] Mirror database: provides the mirroring status of the primary database and the standby database.

[0042] Based on the collected information, the system will confirm the relationship between the source asset and the target asset: Source asset: Select the instance where the primary database in the disaster recovery pair is located as the synchronization source.

[0043] Target assets: Select the instance where the backup database in the disaster recovery pair is located as the synchronization target.

[0044] In addition, user permissions are set, and the provided database users need to have access permissions to query related tables and views to ensure that the synchronization system can successfully perform query operations and accurately obtain data.

[0045] In this way, the system can ensure that the database asset information on the source and target ends is accurately matched, and achieve efficient data synchronization and management in disaster recovery scenarios. This approach not only improves data availability and security, but also provides a strong guarantee for business continuity.

[0046] S120: Select the instance object to be synchronized and configure the synchronization strategy.

[0047] In this embodiment, the instance objects that need to be synchronized include server configuration, linked servers, jobs, login names, permissions, Service Broker applications, and server-level triggers, and the synchronization strategy includes a strategy for setting the collection frequency by minutes, hours, days, or weeks.

[0048] This step selects the type of instance object. For example, users can customize and select only certain types of objects to be synchronized, such as selecting login names, linked servers, and jobs.

[0049] The subsequent actual synchronization is for the specific object data of the specified instance object type. At this time, the target end only needs to synchronize the difference object data of the three types of objects selected by the source end.

[0050] Of course, by default, all difference data of all object types are supported for synchronization.

[0051] Specifically, after identifying the disaster recovery pair, the system will provide an interactive operation interface so that users can select the instance objects to be synchronized and their synchronization strategies. Specifically, users can select the instance objects of the source and target ends in the drop-down menu. The configuration information of each instance (such as access address and status) will be clearly displayed on the interface for users to confirm.

[0052] The interface provides a checkbox to allow users to select the specific object type that needs to be synchronized. The optional instance objects that need to be synchronized include: Server configuration settings: such as memory allocation, maximum number of connections, database compatibility level, etc.

[0053] Linked Server: Contains connection information for external data sources.

[0054] Job: SQL Server Agent job configuration, such as scheduled backup, data import, and other tasks.

[0055] Login name and permissions: users and their corresponding access permissions.

[0056] Service Broker applications: Configuration for messaging and asynchronous processing.

[0057] Trigger (Server Level): Trigger logic defined at the server level.

[0058] In addition, users can select the synchronization frequency based on actual business needs to ensure that data synchronization is completed without affecting system performance. The synchronization policy options include: Minute level: Suitable for scenarios with high real-time requirements. Data is synchronized once every minute.

[0059] Hourly level: Suitable for businesses that require regular updates but have lower real-time requirements. Data is synchronized once an hour.

[0060] Daily: Suitable for daily operation scenarios, data is synchronized at a fixed time every day.

[0061] Weekly: Suitable for long-term monitoring and occasional updates, synchronized once a week.

[0062] Once the user selects the object and synchronization strategy, the system will automatically generate synchronization tasks and execute them regularly according to the configured frequency. The system also provides real-time monitoring functions, and users can view: Synchronization Status: Displays the execution status of the current task (successful, failed, or in progress).

[0063] Error log: If synchronization fails, the system will record error information to facilitate users to find the cause.

[0064] History: Users can view past synchronization records, including execution time, selected objects, and results.

[0065] During the synchronization process, the system will ensure that only users with sufficient permissions can configure and execute synchronization tasks. Permission management includes: Authenticate the user to ensure that the user has access to the selected objects and configurations.

[0066] Restrict access to sensitive operations (such as changing permissions, deleting jobs) to protect system security.

[0067] Through this interactive operation interface, users can flexibly select and configure instance objects that need to be synchronized and the corresponding synchronization strategy. This design not only improves the availability and flexibility of the system, but also ensures data consistency and security under different business requirements. The overall process provides users with an efficient and intuitive management method, making database synchronization and disaster recovery management more convenient.

[0068] S130 , collecting data of instance objects that need to be synchronized from the source and target instances respectively according to the synchronization strategy, and performing comparison to obtain a comparison result.

[0069] In this embodiment, the comparison result refers to the content that needs to be updated after the data of the instance object that needs to be synchronized on the source side is compared with the data of all instance objects on the target side.

[0070] Specifically, after configuring the instance objects to be synchronized and their synchronization strategies, the system will extract the relevant views or stored procedures from the source and target instances to obtain the instance object data of each. Then, the system will go through the instance object information of the source end one by one and perform a comprehensive comparison with the data of the target end. In order to improve the efficiency of the comparison and reduce resource consumption, the system will use optimized algorithms and strategies for data comparison.

[0071] In one embodiment, see Figure 4 , the above-mentioned step S130 may include steps S131~S132.

[0072] S131. Extracting views or stored procedures of corresponding instance objects from the instances of the source and target ends according to the synchronization strategy to obtain data of instance objects that need to be synchronized on the source end and data of all instance objects on the target end.

[0073] In this embodiment, according to the synchronization strategy, corresponding views or stored procedures are extracted from the source and target ends to obtain the data of the instance objects that need to be synchronized on the source end and the data of all instance objects on the target end.

[0074] According to the preset synchronization strategy, that is, the set synchronization frequency, etc., the corresponding views or stored procedures are extracted from the source and target ends according to the strategy.

[0075] Ensure that the data obtained from both ends is consistent to avoid synchronization errors caused by inconsistent data; through views or stored procedures, data can be flexibly extracted according to different needs to improve the adaptability of the system.

[0076] S132: loop through the data of the instance objects that need to be synchronized on the source side, and comprehensively compare the data of the instance objects that need to be synchronized on the source side with the data of all instance objects on the target side to obtain a comparison result.

[0077] In this embodiment, the data of the instance objects that need to be synchronized on the source side are traversed in a loop, and a comprehensive comparison is performed with the data of all instance objects on the target side.

[0078] Comprehensive comparison can ensure that all data that needs to be synchronized is checked to avoid missing important data; through looping and comparison, it can clearly identify which data needs to be synchronized and which data is already the latest.

[0079] In one embodiment, see Figure 5 , the above-mentioned step S132 may include steps S1321~S1326.

[0080] S1321, traverse the source end instance object, extract the metadata of the source end instance object, and then traverse the target end instance object to extract the metadata of the target end instance object; S1322. Use the identifier and object name of the instance object that needs to be synchronized on the source side and the identifiers and object names of all instance objects on the target side as key values ​​to obtain the source side key value and the target side key value.

[0081] In this embodiment, the identifier and object name of the instance object that needs to be synchronized on the source side and the identifiers and object names of all instance objects on the target side are combined into a key value.

[0082] The generation of key values ​​ensures that each object has a unique identifier during comparison, which helps to accurately locate the object; through the combination of key values, the objects that need to be compared can be quickly screened out to improve efficiency.

[0083] S1323. Using the source-side key value as a comparison basis, filter out the key values ​​corresponding to the instance objects in the target side that have the same name as the instance object corresponding to the source-side key value.

[0084] In this embodiment, the key values ​​of the objects on the target side having the same name as the instance object corresponding to the source side are screened out based on the key values ​​on the source side.

[0085] By screening, we only focus on objects with the same name, reducing unnecessary comparisons and improving processing speed; the scope of comparison objects is simplified, making subsequent judgments and comparisons clearer.

[0086] S1324. Determine whether the corresponding target end key value is the same as the source end key value.

[0087] In this embodiment, by comparing the key values, it is possible to quickly confirm whether the objects are the same, thereby reducing the complexity of comparing data; if the key values ​​are different, the object processing method can be quickly determined, thereby optimizing the synchronization process.

[0088] S1325. If the corresponding target-side key value is the same as the source-side key value, then when the details of the data of the corresponding instance object on the source side are different from the details of the data of the corresponding instance object on the target side, the two instance objects are marked as object modifications to obtain a comparison result.

[0089] In this embodiment, if the key value of the target end is the same as that of the source end, the detailed contents of the two instance objects are compared to see if they are consistent; it can effectively identify which objects have been modified to ensure that the data on the target end is the latest; ensure the accuracy of synchronization and prevent data inconsistency caused by omissions or erroneous modifications.

[0090] If the details of the two instance objects are consistent, no synchronization operation is performed.

[0091] S1326. If the corresponding target-side key value is different from the source-side key value, the corresponding instance object of the source side is marked as a newly added object to obtain a comparison result.

[0092] In this embodiment, if the key value of the target end is different from that of the source end, it means that the current instance object data of the source end does not exist in the target end, and the object of the source end is marked as "object added".

[0093] It can identify new instance objects in a timely manner to ensure the integrity of the target end data; the marking processing of new objects can reflect data changes in a timely manner and support rapid response to business needs.

[0094] Through the above steps, the system can synchronize data efficiently and accurately. Each step improves the accuracy and efficiency of the synchronization process while ensuring the consistency and integrity of the data. This structured approach can effectively cope with complex data management needs and provide strong support for business operations.

[0095] S140: According to the comparison result, a synchronization strategy is adopted to batch synchronize instance objects with differences to the target end instance to obtain a synchronization result.

[0096] In this embodiment, the synchronization result includes synchronization success or synchronization exception.

[0097] In one embodiment, see Figure 6 , the above-mentioned step S140 may include steps S141~S143.

[0098] S141. According to the instance object marked as object modification in the comparison result, the corresponding data is deleted from the target end; S142, batch-selecting instance objects marked as object addition and object modification from the source end, and writing a DDL script to generate metadata definition of CREATE objects; S143. Use the script to connect to the target end, and batch import the script to synchronize instance object data that does not exist or has inconsistent metadata information to obtain synchronization results.

[0099] In this embodiment, during the data synchronization process, when the comparison results show that some instance objects do not exist on the target end, or the metadata details of these instance objects are inconsistent, the system needs to take corresponding measures to ensure the consistency and integrity of the data. The specific operation steps are as follows: Based on the comparison results in the previous step, determine whether the instance object exists on the target end and whether its metadata is consistent. Identify the objects that need to be synchronized, including newly added and modified objects.

[0100] For objects that exist on the target side but have inconsistent metadata, you first need to delete the relevant metadata on the target side. This usually involves removing objects that no longer match from the target side.

[0101] Ensure that only the latest and correct metadata is retained on the target side to prevent old data from interfering with subsequent operations.

[0102] On the source side, batch select instance objects marked as "newly added objects" and "modified objects". Then, write a data definition language (DDL) script to generate a script to create object metadata definitions.

[0103] Through DDL scripts, you can clearly define the object structure and properties that need to be created on the target side, improving the automation and repeatability of the synchronization process.

[0104] Use the generated DDL script to connect to the target instance client through the synchronization system and import the script in batches to synchronize instance object data that does not exist on the target side or has inconsistent metadata information.

[0105] Achieve efficient and accurate data synchronization, completely import the latest data and structure from the source end to the target end, and ensure data consistency between the two ends.

[0106] By checking the existence of objects and metadata consistency, errors and confusion caused by data asynchrony can be avoided, ensuring that the target data is consistent with the source data; by deleting inconsistent objects and adding new objects, the system can dynamically respond to data changes and support rapid adjustment of business needs; batch operations and the generation and import of DDL scripts can significantly reduce the time and error risks of manual operations and improve synchronization efficiency; through clear scripts and operation steps, the data management process is simplified, making system maintenance and operation clearer and easier to understand; regular synchronization and updates can improve the overall stability of the system and reduce potential risks caused by data inconsistencies.

[0107] Through the implementation of the above steps, the data synchronization process not only achieves efficient data management, but also ensures the stability and flexibility of the system, providing solid support for business operations. This structured synchronization process is an indispensable part of modern data management and can effectively respond to complex data needs and changes.

[0108] S150: Display the synchronization result, and issue an early warning of abnormal situation when an abnormal situation occurs during the synchronization process.

[0109] In this embodiment, the synchronization results are displayed, and an alarm reminder is provided when the synchronization is abnormal. The time and result status of the most recent synchronization are specifically recorded, including the object name and quantity on the source and target ends. If the synchronization result is unsuccessful, or the most recent synchronization time exceeds the preset alarm threshold or there are objects on the source end that are missing on the target end or the metadata is inconsistent, an alarm is triggered.

[0110] Specifically, the system should record the time of the most recent synchronization, the status of the synchronization result, the name and number of the source object, and the name and number of the target object, to provide a transparent synchronization history for administrators to track and analyze the synchronization status.

[0111] The synchronization result status is "unsuccessful"; or the most recent synchronization time exceeds the set synchronization interval threshold; or there are instance objects on the source side that do not exist on the target side or whose metadata is inconsistent; when any of the above conditions is triggered, the system will automatically generate an alarm message to remind the administrator to check the running status.

[0112] The system configuration options provide a consistency comparison function for the source and target instance objects; the source and target instance objects are read in real time and displayed on the left and right sides respectively; if different content is found, the system will highlight it to facilitate administrators to quickly identify and handle the differences.

[0113] Through the systematic synchronization status display and abnormal alarm mechanism, administrators can more effectively monitor the synchronization progress and promptly discover and solve potential problems. At the same time, through the intuitive comparison function, the consistency of source and target data is ensured, improving the efficiency and accuracy of overall data management.

[0114] The method of this embodiment is used to solve the problem of application dependence on information, entities and objects outside the user database when implementing high availability and disaster recovery in the SQL Server database. Specifically, the changes of object information stored outside the user database on the source and target ends are monitored in real time and automatically processed, including additions and modifications. This ensures that the information on both the primary and standby ends is always consistent, and allows the synchronization strategy to be adjusted dynamically according to business needs, thereby significantly reducing the workload of maintenance personnel, improving the efficiency of object change management, and ensuring the immediacy and accuracy of changes.

[0115] Although most user data is stored in a highly available user database, the method of this embodiment can intelligently identify and handle the synchronization of information and objects stored outside the database for special reasons, ensuring that when the primary and standby databases switch, applications that rely on these entity or object metadata can still connect and run normally.

[0116] Traditional AlwaysOn or mirror disaster recovery modes usually only focus on data synchronization of user databases, while ignoring the synchronization requirements of server-level instance objects. The method of this embodiment fills this gap, not only ensuring the consistency of database data, but also realizing real-time updates of server configurations, entities, and objects. This feature is particularly important in disaster recovery and switching drills, ensuring that services can be seamlessly connected and run stably.

[0117] In summary, the method of this embodiment shows great potential in improving the high availability and disaster recovery capabilities of business systems, and provides strong technical support for enterprises to ensure business continuity and data security in complex IT environments.

[0118] In summary, the method of this embodiment introduces a dynamic real-time synchronization mechanism that can monitor and automatically process changes to information, entities, and objects outside the user database in real time. This mechanism ensures that whether it is new or modified object data, the object information on both the primary and standby ends can remain highly consistent, thereby reducing manual intervention, reducing error rates, and significantly improving the efficiency and accuracy of object change management. It has the ability to intelligently identify and process information, entities, or objects that are beyond the scope of the user database. This innovation solves the application compatibility problem caused by ignoring dependencies in traditional high-availability solutions, ensuring that related applications can run normally as expected after high-availability switching.

[0119] Different from the traditional AlwaysOn or mirror disaster recovery mode, the method of this embodiment realizes the instant update of server-level configuration, entities and objects. This full-instance-level synchronization capability provides a more comprehensive and reliable guarantee for the business system, ensuring that the business can be seamlessly connected and run stably during planned switching drills and disaster recovery.

[0120] The method of this embodiment supports dynamic adjustment of synchronization strategies according to business needs, providing higher flexibility and configurability. This innovation enables technical users to customize the most suitable synchronization solution according to specific business scenarios and needs, thereby further optimizing the high availability and disaster recovery capabilities of the business system.

[0121] The above-mentioned SQL Server-based instance object synchronization disaster recovery method obtains the asset configuration information of the source and target SQLServer instances and matches the disaster recovery relationship to clarify the synchronization object; the user can select the instance object to be synchronized and configure the corresponding synchronization strategy; then, the system collects and compares the data of the source and target ends according to the synchronization strategy to identify the differences; finally, the difference objects are synchronized in batches according to the comparison results, and abnormal warnings are provided during the synchronization process to ensure that the entire process is efficient, reliable and customizable.

[0122] Figure 7 FIG. 3 is a schematic block diagram of an instance object synchronization disaster recovery device 300 based on SQL Server provided in an embodiment of the present invention. Figure 7 As shown, corresponding to the above instance object synchronization disaster recovery method based on SQL Server, the present invention also provides an instance object synchronization disaster recovery device based on SQL Server. The instance object synchronization disaster recovery device based on SQL Server includes a unit for executing the above instance object synchronization disaster recovery method based on SQL Server, and the device can be configured in a terminal such as a desktop computer, a tablet computer, a laptop computer, etc. Specifically, please refer to Figure 7 The SQL Server-based instance object synchronization disaster recovery device 300 includes an acquisition unit 301 , a selection unit 302 , a comparison unit 303 , a synchronization unit 304 and a display unit 305 .

[0123] An acquisition unit 301 is used to acquire the asset configuration information of the SQL Server source and target instances, and match the disaster recovery pair relationship to obtain the source and target ends; a selection unit 302 is used to select the instance objects that need to be synchronized and configure the synchronization strategy; a comparison unit 303 is used to collect the data of the instance objects that need to be synchronized from the source and target instances according to the synchronization strategy, and compare them to obtain the comparison result; a synchronization unit 304 is used to batch synchronize the instance objects with differences to the target instance according to the synchronization strategy according to the comparison result to obtain the synchronization result; a display unit 305 is used to display the synchronization result and issue an abnormal warning when an abnormal situation occurs in the synchronization process.

[0124] In one embodiment, the acquisition unit 301 includes: The adding subunit is used to add the asset configuration information of the SQL Server source and target instances; wherein the asset configuration information includes the access address, port, user name, and password; the matching subunit is used to use the master-slave detection logic to identify and match the disaster recovery pair relationship of the asset configuration information when the host and the instance are connected normally, so as to determine the source and the target.

[0125] In one embodiment, the comparison unit 303 includes: The data acquisition subunit is used to extract the views or stored procedures of the corresponding instance objects from the instances of the source and target ends according to the synchronization strategy to obtain the data of the instance objects that need to be synchronized on the source end and the data of all instance objects in the target end; the comprehensive comparison subunit is used to loop through the data of the instance objects that need to be synchronized on the source end, and comprehensively compare the data of the instance objects that need to be synchronized on the source end with the data of all instance objects in the target end to obtain the comparison result.

[0126] In one embodiment, the comprehensive comparison subunit includes: A traversal module is used to traverse the source end instance objects, extract the metadata of the source end instance objects, and then traverse the target end instance objects to extract the metadata of the target end instance objects; a value generation module is used to use the identifier and object name of the instance object that needs to be synchronized on the source end, and the identifier and object name of all instance objects on the target end as key values ​​to obtain the source end key value and the target end key value; a screening module is used to use the source end key value as a comparison basis to screen out the key values ​​corresponding to the instance objects in the target end that have the same name as the instance object corresponding to the source end key value; a judgment module is used to judge whether the corresponding target end key value is the same as the source end key value; a modification marking module is used to, if the corresponding target end key value is the same as the source end key value, then when the detailed content of the data of the corresponding instance object on the source end is different from the detailed content of the data of the corresponding instance object on the target end, mark the two instance objects as object modification to obtain a comparison result; a new addition marking module is used to, if the corresponding target end key value is different from the source end key value, mark the corresponding instance object on the source end as object addition to obtain a comparison result.

[0127] In one embodiment, the synchronization unit 304 includes: The data deletion subunit is used to delete the corresponding data from the target end according to the instance objects marked as object modification in the comparison results; the script writing subunit is used to batch select instance objects marked as object addition and object modification from the source end, and write DDL scripts to generate metadata definitions of CREATE objects; the data synchronization subunit is used to use scripts to connect to the target end, and batch import scripts to synchronize instance object data that does not exist or has inconsistent metadata information to obtain synchronization results.

[0128] In one embodiment, the display unit 305 is used to display the synchronization results and provide an alarm reminder when the synchronization is abnormal. It specifically records the time and result status of the most recent synchronization, including the object name and quantity on the source and target ends. If the synchronization result is unsuccessful, or the most recent synchronization time exceeds the preset alarm threshold or there are objects on the source end that are missing on the target end or the metadata is inconsistent, an alarm is triggered.

[0129] It should be noted that technicians in the relevant field can clearly understand that the specific implementation process of the above-mentioned SQL Server-based instance object synchronization disaster recovery device 300 and each unit can refer to the corresponding description in the aforementioned method embodiment, and for the convenience and brevity of description, it will not be repeated here.

[0130] The above-mentioned SQL Server-based instance object synchronization disaster recovery device 300 can be implemented in the form of a computer program. The computer program can be used in a computer program such as Figure 8 Runs on the computer device shown.

[0131] See also Figure 8 , Figure 8 5 is a schematic block diagram of a computer device provided in an embodiment of the present application. The computer device 500 may be a server, wherein the server may be an independent server or a server cluster composed of multiple servers.

[0132] See also Figure 8 The computer device 500 includes a processor 502 , a memory and a network interface 505 connected via a system bus 501 , wherein the memory may include a non-volatile storage medium 503 and an internal memory 504 .

[0133] The non-volatile storage medium 503 can store an operating system 5031 and a computer program 5032. The computer program 5032 includes program instructions, and when the program instructions are executed, the processor 502 can execute a SQL Server-based instance object synchronization disaster recovery method.

[0134] The processor 502 is used to provide computing and control capabilities to support the operation of the entire computer device 500 .

[0135] The internal memory 504 provides an environment for the operation of the computer program 5032 in the non-volatile storage medium 503. When the computer program 5032 is executed by the processor 502, the processor 502 can execute a SQL Server-based instance object synchronization disaster recovery method.

[0136] The network interface 505 is used to communicate with other devices over the network. Figure 8 The structure shown in the figure is merely a block diagram of a portion of the structure related to the solution of the present application, and does not constitute a limitation on the computer device 500 to which the solution of the present application is applied. The specific computer device 500 may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0137] The processor 502 is used to run the computer program 5032 stored in the memory to implement the following steps: The asset configuration information of the SQL Server source and target instances is obtained, and the disaster recovery pair relationship is matched to obtain the source and target ends; the instance objects to be synchronized are selected and the synchronization strategy is configured; the data of the instance objects to be synchronized are respectively collected from the source and target instances according to the synchronization strategy, and compared to obtain the comparison result; according to the comparison result, the instance objects with differences are synchronized in batches to the target instance using the synchronization strategy to obtain the synchronization result; the synchronization result is displayed, and an abnormal situation warning is issued when an abnormal situation occurs in the synchronization process.

[0138] The instance objects that need to be synchronized include server configuration, linked servers, jobs, login names, permissions, Service Broker applications, and server-level triggers. The synchronization strategy includes a strategy for setting the collection frequency by minute, hour, day, or week.

[0139] In one embodiment, the processor 502 specifically implements the following steps when implementing the step of obtaining the asset configuration information of the SQL Server source and target instances and matching the disaster recovery pair relationship to obtain the source and target instances: Add the asset configuration information of the SQL Server source and target instances; wherein the asset configuration information includes the access address, port, user name, and password; when the host and instance are connected normally, use the master-slave detection logic to identify and match the disaster recovery pair relationship of the asset configuration information to determine the source and target ends.

[0140] In one embodiment, when the processor 502 implements the step of respectively collecting data of instance objects to be synchronized from the source and target instances according to the synchronization strategy and performing comparison to obtain a comparison result, the processor 502 specifically implements the following steps: Extract the view or stored procedure of the corresponding instance object from the instances of the source and target ends according to the synchronization strategy to obtain the data of the instance objects that need to be synchronized on the source end and the data of all instance objects in the target end; loop through the data of the instance objects that need to be synchronized on the source end, and comprehensively compare the data of the instance objects that need to be synchronized on the source end with the data of all instance objects in the target end to obtain the comparison result.

[0141] In one embodiment, when the processor 502 implements the step of looping through the data of the instance objects that need to be synchronized on the source end and comprehensively comparing the data of the instance objects that need to be synchronized on the source end with the data of all instance objects on the target end to obtain a comparison result, the processor 502 specifically implements the following steps: Traverse the source-side instance objects, extract the metadata of the source-side instance objects, and then traverse the target-side instance objects, extract the metadata of the target-side instance objects; use the identifier and object name of the instance object that needs to be synchronized on the source side, and the identifier and object name of all instance objects on the target side as key values ​​to obtain the source-side key value and the target-side key value; use the source-side key value as a comparison basis to filter out the key values ​​corresponding to the instance objects on the target side that have the same name as the instance object corresponding to the source-side key value; determine whether the corresponding target-side key value is the same as the source-side key value; if the corresponding target-side key value is the same as the source-side key value, then when the detailed content of the data of the corresponding instance object on the source side is different from the detailed content of the data of the corresponding instance object on the target side, mark the two instance objects as object modifications to obtain a comparison result; if the corresponding target-side key value is different from the source-side key value, mark the corresponding instance object on the source side as object addition to obtain a comparison result.

[0142] In one embodiment, when the processor 502 implements the step of batch synchronizing instance objects with differences to the target end instance according to the comparison result to obtain the synchronization result, the processor 502 specifically implements the following steps: According to the instance objects marked as object modification in the comparison results, the corresponding data is deleted from the target end; instance objects marked as object addition and object modification are batch selected from the source end, and a DDL script is written to generate a metadata definition of the CREATE object; the script is used to connect to the target end, and the script is batch imported to synchronize instance object data that does not exist or has inconsistent metadata information to obtain a synchronization result.

[0143] In one embodiment, the processor 502 implements the following steps when implementing the step of displaying the synchronization result and performing an abnormal warning step when an abnormal situation occurs in the synchronization process: Display the synchronization results and provide alarm reminders when synchronization is abnormal. Specifically record the time and result status of the most recent synchronization, including the object name and quantity on the source and target ends. If the synchronization result is unsuccessful, or the most recent synchronization time exceeds the preset alarm threshold, or there are objects on the source end that are missing on the target end or the metadata is inconsistent, an alarm is triggered.

[0144] It should be understood that in the embodiment of the present application, the processor 502 may be a central processing unit (CPU), and the processor 502 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0145] It can be understood by those skilled in the art that all or part of the processes in the method for implementing the above embodiment can be completed by instructing the relevant hardware through a computer program. The computer program includes program instructions, and the computer program can be stored in a storage medium, which is a computer-readable storage medium. The program instructions are executed by at least one processor in the computer system to implement the process steps of the embodiment of the above method.

[0146] Therefore, the present invention also provides a storage medium. The storage medium may be a computer-readable storage medium. The storage medium stores a computer program, wherein when the computer program is executed by a processor, the processor executes the following steps: The asset configuration information of the SQL Server source and target instances is obtained, and the disaster recovery pair relationship is matched to obtain the source and target ends; the instance objects to be synchronized are selected and the synchronization strategy is configured; the data of the instance objects to be synchronized are respectively collected from the source and target instances according to the synchronization strategy, and compared to obtain the comparison result; according to the comparison result, the instance objects with differences are synchronized in batches to the target instance using the synchronization strategy to obtain the synchronization result; the synchronization result is displayed, and an abnormal situation warning is issued when an abnormal situation occurs in the synchronization process.

[0147] The instance objects that need to be synchronized include server configuration, linked servers, jobs, login names, permissions, Service Broker applications, and server-level triggers. The synchronization strategy includes a strategy for setting the collection frequency by minute, hour, day, or week.

[0148] In one embodiment, when the processor executes the computer program to implement the steps of obtaining the asset configuration information of the SQL Server source and target instances and matching the disaster recovery pair relationship to obtain the source and target instances, the processor specifically implements the following steps: Add the asset configuration information of the SQL Server source and target instances; wherein the asset configuration information includes the access address, port, user name, and password; when the host and instance are connected normally, use the master-slave detection logic to identify and match the disaster recovery pair relationship of the asset configuration information to determine the source and target ends.

[0149] In one embodiment, when the processor executes the computer program to implement the step of respectively collecting data of instance objects to be synchronized from the source and target instances according to the synchronization strategy and performing comparison to obtain a comparison result, the processor specifically implements the following steps: Extract the view or stored procedure of the corresponding instance object from the instances of the source and target ends according to the synchronization strategy to obtain the data of the instance objects that need to be synchronized on the source end and the data of all instance objects in the target end; loop through the data of the instance objects that need to be synchronized on the source end, and comprehensively compare the data of the instance objects that need to be synchronized on the source end with the data of all instance objects in the target end to obtain the comparison result.

[0150] In one embodiment, when the processor executes the computer program to implement the step of looping through the data of the instance objects that need to be synchronized on the source end, and comprehensively comparing the data of the instance objects that need to be synchronized on the source end with the data of all instance objects on the target end to obtain a comparison result, the processor specifically implements the following steps: Traverse the source-side instance objects, extract the metadata of the source-side instance objects, and then traverse the target-side instance objects, extract the metadata of the target-side instance objects; use the identifier and object name of the instance object that needs to be synchronized on the source side, and the identifier and object name of all instance objects on the target side as key values ​​to obtain the source-side key value and the target-side key value; use the source-side key value as a comparison basis to filter out the key values ​​corresponding to the instance objects on the target side that have the same name as the instance object corresponding to the source-side key value; determine whether the corresponding target-side key value is the same as the source-side key value; if the corresponding target-side key value is the same as the source-side key value, then when the detailed content of the data of the corresponding instance object on the source side is different from the detailed content of the data of the corresponding instance object on the target side, mark the two instance objects as object modifications to obtain a comparison result; if the corresponding target-side key value is different from the source-side key value, mark the corresponding instance object on the source side as object addition to obtain a comparison result.

[0151] In one embodiment, when the processor executes the computer program to implement the step of batch synchronizing instance objects with differences to the target end instance according to the comparison result to obtain the synchronization result, the processor specifically implements the following steps: According to the instance objects marked as object modification in the comparison results, the corresponding data is deleted from the target end; instance objects marked as object addition and object modification are batch selected from the source end, and a DDL script is written to generate a metadata definition of the CREATE object; the script is used to connect to the target end, and the script is batch imported to synchronize instance object data that does not exist or has inconsistent metadata information to obtain a synchronization result.

[0152] In one embodiment, the processor implements the following steps when executing the computer program to display the synchronization result and performing an abnormal situation warning step when an abnormal situation occurs in the synchronization process: Display the synchronization results and provide alarm reminders when synchronization is abnormal. Specifically record the time and result status of the most recent synchronization, including the object name and quantity on the source and target ends. If the synchronization result is unsuccessful, or the most recent synchronization time exceeds the preset alarm threshold, or there are objects on the source end that are missing on the target end or the metadata is inconsistent, an alarm is triggered.

[0153] The storage medium may be a USB flash drive, a mobile hard disk, a read-only memory (ROM), a magnetic disk, or an optical disk, etc., which are computer-readable storage media that can store program codes.

[0154] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0155] In the several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of each unit is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.

[0156] The steps in the method of the embodiment of the present invention can be adjusted in order, combined and deleted according to actual needs. The units in the device of the embodiment of the present invention can be combined, divided and deleted according to actual needs. In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0157] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, terminal, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention.

[0158] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.

Claims

1. An instance object synchronization disaster recovery method based on SQL Server, characterized in that: include: Obtain the asset configuration information of the SQL Server source and target instances, and match the disaster recovery pair relationship to obtain the source and target. Select the instance object that needs to be synchronized and configure the synchronization strategy; Collecting data of instance objects to be synchronized from the source and target instances according to the synchronization strategy, and comparing them to obtain a comparison result; According to the comparison result, a synchronization strategy is adopted to batch synchronize instance objects with differences to the target end instance to obtain a synchronization result; The synchronization results are displayed, and an early warning of abnormal situations is issued when abnormal situations occur during the synchronization process.

2. The SQL Server-based instance object synchronization disaster recovery method according to claim 1, characterized in that: The acquiring of the asset configuration information of the SQL Server source and target instances and matching the disaster recovery pair relationship to obtain the source and target instances includes: Add the asset configuration information of the SQL Server source and target instances; the asset configuration information includes the access address, port, user name, and password; When the host and the instance are connected normally, the primary and secondary detection logic is used to identify and match the disaster recovery pair relationship of the asset configuration information to determine the source end and the target end.

3. The SQL Server-based instance object synchronization disaster recovery method according to claim 1, characterized in that: The instance objects that need to be synchronized include server configuration, linked servers, jobs, login names, permissions, Service Broker applications, and server-level triggers. The synchronization strategy includes a strategy for setting the collection frequency by minute, hour, day, or week.

4. The SQL Server-based instance object synchronization disaster recovery method according to claim 1, characterized in that: The collecting data of the instance objects to be synchronized from the source and target instances according to the synchronization strategy and comparing them to obtain the comparison results includes: Extracting the view or stored procedure of the corresponding instance object from the instances of the source and target ends according to the synchronization strategy to obtain the data of the instance object that needs to be synchronized on the source end and the data of all instance objects on the target end; The data of the instance objects that need to be synchronized on the source side are traversed in a loop, and the data of the instance objects that need to be synchronized on the source side are comprehensively compared with the data of all instance objects on the target side to obtain a comparison result.

5. The SQL Server-based instance object synchronization disaster recovery method according to claim 4, characterized in that: The loop traverses the data of the instance objects that need to be synchronized on the source side, and comprehensively compares the data of the instance objects that need to be synchronized on the source side with the data of all instance objects on the target side to obtain a comparison result, including: Traverse the source end instance object, extract the metadata of the source end instance object, and then traverse the target end instance object to extract the metadata of the target end instance object; The identifier and object name of the instance object to be synchronized on the source side and the identifier and object name of all instance objects on the target side are used as key values ​​to obtain the source side key value and the target side key value; Using the source end key value as a comparison reference, filter out the key value corresponding to the instance object in the target end that has the same name as the instance object corresponding to the source end key value; Determine whether the corresponding target key value is the same as the source key value; If the corresponding target end key value is the same as the source end key value, then when the details of the data of the corresponding instance object on the source end are different from the details of the data of the corresponding instance object on the target end, the two instance objects are marked as object modification to obtain a comparison result; If the corresponding target-side key value is different from the source-side key value, the corresponding instance object on the source side is marked as newly added object to obtain the comparison result.

6. The SQL Server-based instance object synchronization disaster recovery method according to claim 5, characterized in that: The step of batch synchronizing different instance objects to the target end instance according to the comparison result to obtain the synchronization result includes: According to the instance objects marked as object modification in the comparison results, the corresponding data is deleted from the target end; Select instance objects marked as object addition and object modification in batches from the source end, and write a DDL script to generate metadata definitions of CREATE objects; Use the script to connect to the target end, and batch import the script to synchronize instance object data that does not exist or has inconsistent metadata information to obtain synchronization results.

7. The SQL Server-based instance object synchronization disaster recovery method according to claim 1, characterized in that: The display of the synchronization result and the early warning of abnormal situation when an abnormal situation occurs during the synchronization process include: Display the synchronization results and provide alarm reminders when synchronization is abnormal. Specifically record the time and result status of the most recent synchronization, including the object name and quantity on the source and target ends. If the synchronization result is unsuccessful, or the most recent synchronization time exceeds the preset alarm threshold, or there are objects on the source end that are missing on the target end or the metadata is inconsistent, an alarm is triggered.

8. An instance object synchronization disaster recovery device based on SQL Server, characterized in that: include: An acquisition unit is used to acquire asset configuration information of the SQL Server source and target instances, and match the disaster recovery pair relationship to obtain the source and target instances; A selection unit is used to select the instance object to be synchronized and configure the synchronization strategy; A comparison unit, used to collect data of instance objects to be synchronized from the source end and the target end instances according to the synchronization strategy, and compare them to obtain a comparison result; A synchronization unit, used to synchronize instance objects with differences to the target end instance in batches by adopting a synchronization strategy according to the comparison result, so as to obtain a synchronization result; The display unit is used to display the synchronization result and issue an early warning of abnormal situation when an abnormal situation occurs during the synchronization process.

9. A computer device, characterized in that: The computer device comprises a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the method according to any one of claims 1 to 7 is implemented.

10. A storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Database disaster recovery switching drilling method and device, computer equipment and storage medium

    CN116185723A

  • System and method for realizing MinIO real-time disaster recovery

    CN117851116A

  • Data synchronization method and device, computer equipment and computer readable storage medium

    CN117971983A

  • Main and standby configuration information synchronization method and device, computer equipment and storage medium

    CN118312230A

  • Acceptance method and device of disaster recovery system, storage medium and electronic device

    CN118445160A