Data disaster recovery method, system and device based on message-oriented middleware and storage medium

By writing the same message in real time in the cross-data center dual-active disaster recovery architecture of message middleware and correcting consumption offsets, the loss or repeated consumption caused by manual confirmation of data backtracking and consumption offset delays in the prior art is solved. Problem, achieving faster and more reliable failover and data consistency.

CN118897756APending Publication Date: 2024-11-05CHINA EVERBRIGHT BANK
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410944153.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-15
Publication Date
2024-11-05

AI Technical Summary

Technical Problem

The existing message middleware cross-data center dual-active disaster recovery architecture requires manual participation in confirming data backtracking during failover, resulting in an increase in recovery time targets. Due to the delay in synchronous delay in consumption offsets, it is easy to cause messages loss or repeated consumption.

Method used

By writing the same message to the same partitions of the same topics of the source cluster and the target cluster in real time on the acquisition side, the consumer side provides the latest consumption offset and consumption metadata in real time, and the offset synchronization server calculates and corrects the consumption of the target cluster in real time. Offset to ensure seamless switching and continue consuming messages when source cluster exceptions.

Benefits of technology

Reduces the recovery time target during message middleware cluster switching, reduces or avoids message loss and repeated consumption, and improves the high availability and data integrity of message middleware clusters.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118897756A_ABST
    Figure CN118897756A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of data disaster recovery, and provides a data disaster recovery method, system and device and a storage medium, and the method comprises the steps: enabling a collection end to write the same message into the same partitions of the same subject of a source cluster and a target cluster in real time; the source cluster is a message-oriented middleware cluster of a first data center, and the target cluster is a message-oriented middleware cluster of a second data center; the consumption end provides the latest consumption offset for the source cluster in real time and provides the latest consumption metadata for the target cluster in real time; the offset synchronization server calculates a consumption offset difference value between the target cluster and the source cluster in real time according to the latest consumption metadata, and corrects the consumption offset of the target cluster in real time according to the consumption offset difference value; and when the source cluster is abnormal, switching the consumer to the target cluster and continuing to consume the message according to the corrected consumption offset. According to the embodiment of the invention, RTO during cluster switching can be reduced, and lost messages and repeated consumption messages during cluster switching can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data disaster recovery, and in particular to a data disaster recovery method, system, device and storage medium based on message middleware. Background Art

[0002] In order to ensure the high availability and high reliability of the message middleware cluster, it is necessary to build a cross-center active-active disaster recovery architecture to ensure that the consumers of the message middleware can switch seamlessly between clusters and that the message middleware messages are not lost or duplicated, thereby improving the high availability and data integrity of the streaming data service and further improving the level of business continuity.

[0003] Generally speaking, the deployment of message middleware across data centers is roughly divided into two forms: stretched cluster and connected cluster. Most active-active architectures on the market are based on the latter, such as commercial solutions: Confluent's Replicator and CDP's SRM, community solutions: MirrorMaker2, open source solutions: Uber's uReplicator, etc. There are still various problems with the above solutions in actual applications. For example, during failover, in order to ensure that data is not lost, the collection end needs to trace back data, and these tasks require manual participation and confirmation, which will greatly increase the recovery time objective (RTO). In addition, due to the delay in the synchronization of consumption offsets, the offset submitted by the target message middleware cluster will lag behind the source cluster. Once a cluster switch occurs, it is easy to lose messages or consume messages repeatedly. Summary of the invention

[0004] The purpose of the embodiments of this specification is to provide a data disaster recovery method, system, device and storage medium based on message middleware to reduce the RTO when the message middleware cluster switches, and reduce or avoid message loss and repeated consumption of messages when the message middleware cluster switches.

[0005] To achieve the above objectives, on the one hand, an embodiment of this specification provides a data disaster recovery method based on a message middleware, including:

[0006] The collection end writes the same message to the same partition of the same topic of the source cluster and the target cluster in real time; the source cluster is the message middleware cluster of the first data center, and the target cluster is the message middleware cluster of the second data center;

[0007] The consumer end provides the latest consumption offset to the source cluster in real time, and provides the latest consumption metadata to the target cluster in real time;

[0008] The offset synchronization server calculates the consumption offset difference between the target cluster and the source cluster in real time according to the latest consumption metadata, and corrects the consumption offset of the target cluster in real time according to the consumption offset difference;

[0009] When the source cluster is abnormal, the consumer end is switched to the target cluster and continues to consume messages according to the corrected consumption offset.

[0010] In the data disaster recovery method based on message middleware in the embodiment of this specification, the consumption metadata includes a consumption group ID, a topic, a partition ID, a record timestamp, a business ID and a consumption offset.

[0011] In the data disaster recovery method based on message middleware of the embodiment of the present specification, before the offset synchronization server is caused to calculate the consumption offset difference between the target cluster and the source cluster in real time according to the latest consumption metadata, it also includes:

[0012] The offset synchronization server obtains the latest consumption metadata from the target cluster in real time, generates and saves a key-value pair with the consumer group ID, topic and partition ID in the latest consumption metadata as the primary key and the latest consumption metadata as the value.

[0013] In the data disaster recovery method based on message middleware of the embodiment of this specification, the real-time calculation of the consumption offset difference between the target cluster and the source cluster according to the latest consumption metadata includes:

[0014] Real-time query of whether there is a consumption offset difference corresponding to the latest primary key in the consumption offset difference table;

[0015] If the consumption offset difference corresponding to the latest primary key does not exist in the consumption offset difference table, matching the corresponding message from the target cluster according to the topic, partition ID and business ID in the latest consumption metadata;

[0016] Obtaining the consumption offset of the source cluster from the latest consumption metadata as the first consumption offset; and using the offset of the message matched from the target cluster as the second consumption offset;

[0017] The difference between the first consumption offset and the second consumption offset is calculated, and the difference is used as the consumption offset difference between the target cluster and the source cluster for the message corresponding to the latest primary key.

[0018] In the data disaster recovery method based on message middleware of the embodiment of this specification, the real-time correction of the consumption offset of the target cluster according to the consumption offset difference includes:

[0019] The first consumption offset is added to the consumption offset difference in real time.

[0020] On the other hand, the embodiment of this specification also provides a data disaster recovery system based on message middleware, including:

[0021] A source cluster, where the source cluster is a message middleware cluster of the first data center;

[0022] A target cluster, wherein the target cluster is a message middleware cluster of the second data center;

[0023] The collection end is used to write the same message to the same partition of the same topic of the source cluster and the target cluster in real time;

[0024] The consumer end is used to provide the latest consumption offset to the source cluster in real time, and provide the latest consumption metadata to the target cluster in real time; when the source cluster is abnormal, it switches to the target cluster and continues to consume messages according to the corrected consumption offset;

[0025] The offset synchronization server is used to calculate the consumption offset difference between the target cluster and the source cluster in real time according to the latest consumption metadata, and to correct the consumption offset of the target cluster in real time according to the consumption offset difference.

[0026] In the data disaster recovery system based on message middleware in the embodiment of this specification, the consumption metadata includes a consumption group ID, a topic, a partition ID, a record timestamp, a business ID and a consumption offset.

[0027] In the data disaster recovery system based on message middleware in the embodiment of this specification, the offset synchronization server is also used for:

[0028] The offset synchronization server obtains the latest consumption metadata from the target cluster in real time, generates and saves a key-value pair with the consumer group ID, topic and partition ID in the latest consumption metadata as the primary key and the latest consumption metadata as the value.

[0029] In the data disaster recovery system based on the message middleware in the embodiment of the present specification, the real-time calculation of the consumption offset difference between the target cluster and the source cluster according to the latest consumption metadata includes:

[0030] Real-time query of whether there is a consumption offset difference corresponding to the latest primary key in the consumption offset difference table;

[0031] If the consumption offset difference corresponding to the latest primary key does not exist in the consumption offset difference table, matching the corresponding message from the target cluster according to the topic, partition ID and business ID in the latest consumption metadata;

[0032] Obtaining the consumption offset of the source cluster from the latest consumption metadata as the first consumption offset; and using the offset of the message matched from the target cluster as the second consumption offset;

[0033] The difference between the first consumption offset and the second consumption offset is calculated, and the difference is used as the consumption offset difference between the target cluster and the source cluster for the message corresponding to the latest primary key.

[0034] In the data disaster recovery system based on message middleware in the embodiment of this specification, the real-time correction of the consumption offset of the target cluster according to the consumption offset difference includes:

[0035] The first consumption offset is added to the consumption offset difference in real time.

[0036] On the other hand, an embodiment of the present specification further provides a computer device, including a memory, a processor, and a computer program stored in the memory, wherein when the computer program is executed by the processor, the instructions of the above method are executed.

[0037] On the other hand, an embodiment of the present specification further provides a computer storage medium on which a computer program is stored. When the computer program is executed by a processor of a computer device, the instructions of the above method are executed.

[0038] On the other hand, an embodiment of the present specification further provides a computer program product, wherein the computer program product includes a computer program, and when the computer program is executed by a processor of a computer device, the computer program executes instructions of the above method.

[0039] It can be seen from the technical solutions provided by the above embodiments of this specification that in the embodiments of this specification, since the collection end can write the same message to the same partition of the same topic of the source cluster and the target cluster respectively, this data double-writing method eliminates the data replication link when switching clusters, that is, eliminates the cluster switching, data backtracking and configuration modification links, thereby greatly reducing RTO. In addition, since the offset synchronization server can calculate the consumption offset difference between the target cluster and the source cluster based on the consumption metadata, and correct the consumption offset of the target cluster based on the consumption offset difference to keep it consistent with the consumption offset of the source cluster; in this way, when the source cluster is abnormal and the consumer end switches to the target cluster, the consumer end can directly continue to consume messages from the corrected consumption offset position of the target cluster, thereby reducing or avoiding the loss of messages and repeated consumption messages during cluster switching. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] In order to more clearly illustrate the technical solutions in the embodiments of this specification or the prior art, the following briefly introduces the drawings required for use in the embodiments or the prior art description. Obviously, the drawings described below are only some embodiments recorded in this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative labor. In the drawings:

[0041] Figure 1 A schematic diagram of a data disaster recovery system based on a message middleware in some embodiments of this specification is shown;

[0042] Figure 2 A flowchart of a data disaster recovery method based on a message middleware in some embodiments of this specification is shown;

[0043] Figure 3 Shows Figure 2 A flowchart of calculating the difference in consumption offset of a message in the target cluster and the source cluster according to consumption metadata in the method shown;

[0044] Figure 4 Shows Figure 2 Schematic diagram of correcting the consumption offset of the target cluster in the method shown;

[0045] Figure 5 The structure block diagram of the computer device in some embodiments of the present specification is shown.

[0046] [Description of Reference Numerals]

[0047] 10. Collection terminal;

[0048] 20. Source cluster;

[0049] 30. Target cluster;

[0050] 40. Offset synchronization server;

[0051] 50. Consumer side;

[0052] 502. Computer equipment;

[0053] 504, processor;

[0054] 506. Memory;

[0055] 508, driving mechanism;

[0056] 510, input / output interface;

[0057] 512. Input devices;

[0058] 514. Output device;

[0059] 516. Presentation equipment;

[0060] 518. Graphical user interface;

[0061] 520, network interface;

[0062] 522, communication link;

[0063] 524. Communication bus. DETAILED DESCRIPTION

[0064] In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this specification.

[0065] Figure 1 A schematic diagram of a data disaster recovery system based on a message middleware in some embodiments of this specification is shown in FIG; the system includes a collection terminal 10, a source cluster 20, a target cluster 30, an offset synchronization service terminal 40, and a consumer terminal 50. The source cluster 20 is a message middleware cluster of the first data center; the target cluster 30 is a message middleware cluster of the second data center (it should be noted that in the embodiments of this specification, unless otherwise specified, a cluster generally refers to a message middleware cluster). The collection terminal 10 is used to write the same message to the same partition of the same topic of the source cluster 20 and the target cluster 30 in real time. The consumer terminal 50 is used to provide the latest consumption offset to the source cluster 20 in real time, and to provide the latest consumption metadata to the target cluster 30 in real time; when the source cluster 20 is abnormal, it switches to the target cluster 30 and continues to consume messages according to the corrected consumption offset. The offset synchronization service terminal 40 is used to calculate the consumption offset difference between the target cluster 30 and the source cluster 20 in real time according to the latest consumption metadata, and to correct the consumption offset of the target cluster 30 in real time according to the consumption offset difference to keep it consistent with the consumption offset of the source cluster 20. The embodiments of this specification can reduce the data delay between the target cluster 30 and the source cluster 20, reduce the RTO during cluster switching, and reduce or avoid message loss and repeated consumption of messages during cluster switching.

[0066] In an embodiment of the present specification, the acquisition end 10 is a message producer, which is a terminal or service that converts business data into a message stream and publishes the same message to the same partition of the same topic of the source cluster 20 and the target cluster 30 in real time. The source cluster 20 and the target cluster 30 can be configured with the same hardware and software; for example, the source cluster 20 and the target cluster 30 are both kafka clusters with the same hardware and software configuration. The offset synchronization server 40 can be an electronic device with computing and network interaction functions; it can also be software running in the electronic device to provide business logic for data processing and network interaction. The consumer end 50 is a message consumer, which is a terminal or service that consumes messages from the source cluster 20.

[0067] The embodiment of this specification provides a data disaster recovery method based on message middleware, which can be applied to the data disaster recovery system based on message middleware mentioned above, referring to Figure 2 As shown, in some embodiments of this specification, a data disaster recovery method based on a message middleware may include the following steps:

[0068] Step 201, the collection end writes the same message to the same partition of the same topic of the source cluster and the target cluster in real time; the source cluster is the message middleware cluster of the first data center, and the target cluster is the message middleware cluster of the second data center.

[0069] Step 202: The consumer end provides the latest consumption offset to the source cluster in real time, and provides the latest consumption metadata to the target cluster in real time.

[0070] Step 203: Enable the offset synchronization server to calculate the consumption offset difference between the target cluster and the source cluster in real time according to the latest consumption metadata, and correct the consumption offset of the target cluster in real time according to the consumption offset difference.

[0071] Step 204: When the source cluster is abnormal, the consumer end is switched to the target cluster and continues to consume messages according to the corrected consumption offset.

[0072] In the embodiments of this specification, since the collection end can write the same message to the same partition of the same topic of the source cluster and the target cluster respectively, this data double-write method eliminates the data replication link when switching clusters, that is, eliminates the cluster switching, data backtracking and configuration modification links, thereby significantly reducing RTO. In addition, since the offset synchronization server can calculate the consumption offset difference between the target cluster and the source cluster based on the consumption metadata, and correct the consumption offset of the target cluster based on the consumption offset difference; in this way, when the source cluster is abnormal and the consumer end switches to the target cluster, the consumer end can directly continue to consume messages from the corrected target cluster's consumption offset position, thereby reducing or avoiding lost messages and repeated consumption messages during cluster switching. Furthermore, the high availability of the message middleware cluster can also be improved through this cluster switching.

[0073] In an embodiment of the present specification, the consumer end is connected to the source cluster by default, that is, the consumer end consumes messages from the source cluster by default; after the consumption offset of the target cluster is corrected according to the consumption offset difference in real time, when the source cluster is abnormal, the consumer end can be switched from the source cluster to the target cluster and continue to consume messages; because the consumption offset of the target cluster can be corrected in real time.

[0074] In addition, load balancing can be achieved through this cluster switching. For example, the clusters connected to the consumer end can be dynamically balanced according to the load of the two clusters, and the granularity can be fine to the topic level under the consumer group, thereby balancing the storage capacity and throughput of the cluster. Among them, the consumer group can refer to a group formed by multiple consumers who have subscribed to the same consumer topic message.

[0075] In some embodiments of this specification, there can be multiple collection terminals and consumer terminals; all messages published by each collection terminal can be divided into multiple categories according to different topics, and each category can be divided into multiple partitions. The messages in each partition are ordered, that is, each partition can be a first-in-first-out message queue. For example, a collection terminal can publish message M1 to topic 1→partition 2 in the source cluster, and simultaneously publish message M1 to topic 1→partition 2 in the target cluster. It should be noted that multiple consumer groups can consume a message at the same time, but a message of the same topic can only be consumed by one consumer terminal in the same consumer group.

[0076] In the embodiments of the present specification, the source cluster is the primary cluster by default, that is, the consumer consumes messages from the source cluster by default; therefore, the consumer can provide a consumption offset to the source cluster so that the source cluster can perceive the consumer's consumption progress of various messages cached in this cluster. Among them, the consumption offset is also called consumption displacement or consumption position, which records the progress of the consumer's consumption of messages. In the embodiments of the present specification, the consumer not only provides a consumption offset to the source cluster, but also provides consumption metadata to the target cluster; in this way, it is convenient for the offset synchronization server to calculate the consumption offset of the target cluster based on the consumption metadata. Among them, the consumption metadata may include consumption group ID, topic, partition ID, record timestamp, business ID and consumption offset.

[0077] In some embodiments of the present specification, before the offset synchronization server calculates the difference in consumption offset between the target cluster and the source cluster in real time according to the latest consumption metadata, the data disaster recovery method based on the message middleware may also include: enabling the offset synchronization server to obtain the latest consumption metadata from the target cluster in real time, generating a key-value pair with the consumer group ID, subject (i.e., consumption subject) and partition ID in the latest consumption metadata as the primary key and the latest consumption metadata as the value, and saving it. For example, in one embodiment of the present specification, the above key-value pair may be expressed as follows:

[0078] {

[0079] "groupID_topic_partitionID":{

[0080] "posID":10001,

[0081] "offset":5

[0082] }

[0083] }

[0084] Among them, groupID is the consumer group identifier, topic is the consumer topic, partitionID is the partition identifier, posID is the business ID, and offset is the consumer offset.

[0085] In other embodiments of the present specification, the above-mentioned key-value pair may also include a record timestamp for subsequent fuzzy search when matching the corresponding message from the target cluster according to the latest consumption metadata, and on this basis, perform precise search according to posID, thereby improving the matching efficiency of matching messages from the target cluster.

[0086] For example, in an exemplary embodiment of the present specification, a key-value pair containing a record timestamp may be as follows:

[0087] {

[0088] "groupID_topic_partitionID":{

[0089] "posID":10001,

[0090] "offset":5,

[0091] "timestamp":1720417340

[0092] }

[0093] }

[0094] refer to Figure 3 As shown, in some embodiments of the present specification, the real-time calculation of the consumption offset difference between the target cluster and the source cluster according to the latest consumption metadata may include the following steps:

[0095] Step 301: Query in real time whether there is a consumption offset difference corresponding to the latest primary key in the consumption offset difference table.

[0096] The latest primary key can be determined according to the storage time of the key-value pair. The primary key corresponding to the key-value pair with the latest storage time is the latest primary key. By querying the consumption offset difference table in real time, it can be confirmed whether the consumption offset corresponding to the latest primary key has been corrected. If the consumption offset difference corresponding to the latest primary key does not exist in the consumption offset difference table, continue to obtain the latest primary key and continue to query.

[0097] Step 302: If the consumption offset difference corresponding to the latest primary key does not exist in the consumption offset difference table, the corresponding message is matched from the target cluster according to the topic, partition ID and business ID in the latest consumption metadata.

[0098] When the consumption offset difference corresponding to the latest primary key does not exist in the consumption offset difference table, it indicates that the consumption offset difference corresponding to the current latest primary key has not been calculated. Therefore, it is necessary to match the corresponding message from the target cluster according to the topic, partition ID, and business ID in the latest consumption metadata to facilitate subsequent consumption offset difference calculation.

[0099] Step 303: Acquire the consumption offset of the source cluster from the latest consumption metadata as the first consumption offset; and use the offset of the message matched from the target cluster as the second consumption offset.

[0100] The consumer end will write the consumption metadata of the consumption source cluster to a specific topic in the target cluster, and the consumption offset in the consumption metadata is the consumption offset of the source cluster; therefore, the consumption offset of the source cluster can be obtained from the latest consumption metadata as the first consumption offset.

[0101] Since the messages cached in the target cluster all have corresponding offsets, after matching the corresponding message from the target cluster, the offset of the message can be obtained; therefore, the offset of the message matched from the target cluster can be used as the second consumption offset.

[0102] Step 304: Calculate the difference between the first consumption offset and the second consumption offset, and use the difference as the consumption offset difference between the target cluster and the source cluster for the message corresponding to the latest primary key.

[0103] Due to various reasons, there may be a deviation between the latest consumption offset (i.e., the second consumption offset) and the first consumption offset in the target cluster (generally, the latest consumption offset in the source cluster is ahead of the latest consumption offset in the target cluster); if no correction is made, once the source cluster is abnormal, when the consumer switches to the target cluster and continues to consume messages, it is easy to lose messages or repeat consumption messages. Therefore, it is necessary to correct the consumption offset of the target cluster in real time according to the consumption offset difference.

[0104] In some embodiments of the present specification, the real-time correction of the consumption offset of the target cluster according to the consumption offset difference may include: adding the first consumption offset to the consumption offset difference in real time; in this way, the consumption offset in the latest consumption metadata in the target cluster can be kept consistent with the latest consumption offset in the source cluster in real time, thereby providing a favorable basis for the target cluster to take over the source cluster at any time.

[0105] In some embodiments of this specification, the cluster monitoring program can monitor the status of the source cluster in real time. Once the source cluster has an abnormality, it will push cluster switching information to the configuration service, and the configuration service will notify the consumer end integrated with the custom SDK; the consumer end integrated with the SDK will automatically switch to the target cluster after receiving the notification. Since the consumption offset has been synchronized to the target cluster, the consumer will continue to consume data in the target cluster. Among them, the custom SDK can sense the changes in the connected cluster and switch, eliminating the work of manually modifying the configuration.

[0106] For example, in Figure 4 In the embodiment shown, for partition 1 of topic 1, if the first consumption offset is 2 (such as Figure 4The second consumption offset is 4, and the difference between the two consumption offsets is 4-2=2. Then the corrected consumption offset in the latest consumption metadata in the target cluster is 2+2=4 (as shown in Figure 4 ).

[0107] Although the process flows described above include multiple operations that occur in a particular order, it should be clearly understood that the processes may include more or fewer operations, which may be performed sequentially or in parallel (eg, using parallel processors or a multi-threaded environment).

[0108] For the convenience of description, the above system is described by dividing it into various units according to its functions. Of course, when implementing this specification, the functions of each unit can be implemented in the same or multiple software and / or hardware.

[0109] It should be noted that in the embodiments of this specification, the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved are all information and data authorized by the user and fully authorized by all parties, that is, the acquisition, transmission, storage, use, and processing of data in the technical solution of this application comply with the relevant provisions of national laws and regulations.

[0110] The embodiments of this specification also provide a computer device. Figure 5As shown, in some embodiments of the present specification, the computer device 502 may include one or more processors 504, such as one or more central processing units (CPUs) or graphics processing units (GPUs), and each processing unit may implement one or more hardware threads. The computer device 502 may also include any memory 506, which is used to store any kind of information such as code, settings, data, etc. In a specific embodiment, the computer program on the memory 506 and can be run on the processor 504, when the computer program is run by the processor 504, can execute the instructions of the data disaster recovery method based on the message middleware described in any of the above embodiments. Non-limiting, for example, the memory 506 may include any one or more combinations of the following: any type of RAM, any type of ROM, flash memory device, hard disk, optical disk, etc. More generally, any memory can use any technology to store information. Further, any memory can provide volatile or non-volatile retention of information. Further, any memory can represent a fixed or removable component of the computer device 502. In one case, when the processor 504 executes an associated instruction stored in any memory or a combination of memories, the computer device 502 can perform any operation of the associated instruction. The computer device 502 also includes one or more drive mechanisms 508 for interacting with any storage, such as a hard disk drive mechanism, an optical disk drive mechanism, etc.

[0111] The computer device 502 may also include an input / output interface 510 (I / O) for receiving various inputs (via input devices 512) and for providing various outputs (via output devices 514). A specific output mechanism may include a presentation device 516 and an associated graphical user interface 518 (GUI). In other embodiments, the input / output interface 510 (I / O), input device 512, and output device 514 may not be included, and the computer device 502 may be used as a computer device in a network. The computer device 502 may also include one or more network interfaces 520 for exchanging data with other devices via one or more communication links 522. One or more communication buses 524 couple the components described above together.

[0112] The communication link 522 may be implemented in any manner, for example, through a local area network, a wide area network (e.g., the Internet), a point-to-point connection, etc., or any combination thereof. The communication link 522 may include any combination of hardwired links, wireless links, routers, gateway functions, name servers, etc. governed by any protocol or combination of protocols.

[0113] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), computer-readable storage media, and computer program products of some embodiments of the present specification. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processor to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processor generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0114] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processor to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0115] These computer program instructions can also be loaded onto a computer or other programmable data processor so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0116] In a typical configuration, a computer device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0117] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0118] Computer-readable media include permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computer device. As defined in this specification, computer-readable media does not include temporary computer-readable media (transitory media), such as modulated data signals and carrier waves.

[0119] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems or computer program products. Therefore, the embodiments of this specification may take the form of complete hardware embodiments, complete software embodiments or embodiments combining software and hardware. Moreover, the embodiments of this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0120] The present specification embodiments may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present specification embodiments may also be practiced in distributed computing environments where tasks are performed by remote processors connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.

[0121] It should also be understood that in the embodiments of this specification, the term "and / or" is only a description of the association relationship of the associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.

[0122] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0123] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the embodiments of this specification. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.

[0124] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims

1. A data disaster recovery method based on message middleware, characterized in that: include: The collection end writes the same message to the same partition of the same topic in the source cluster and the target cluster in real time; The source cluster is a message middleware cluster of the first data center, and the target cluster is a message middleware cluster of the second data center; The consumer end provides the latest consumption offset to the source cluster in real time, and provides the latest consumption metadata to the target cluster in real time; The offset synchronization server calculates the consumption offset difference between the target cluster and the source cluster in real time according to the latest consumption metadata, and corrects the consumption offset of the target cluster in real time according to the consumption offset difference; When the source cluster is abnormal, the consumer is switched to the target cluster and continues to consume messages according to the corrected consumption offset.

2. The data disaster recovery method based on message middleware according to claim 1, characterized in that: The consumption metadata includes consumption group ID, topic, partition ID, record timestamp, business ID and consumption offset.

3. The data disaster recovery method based on message middleware according to claim 2, characterized in that: Before causing the offset synchronization server to calculate the consumption offset difference between the target cluster and the source cluster in real time according to the latest consumption metadata, the method further includes: The offset synchronization server obtains the latest consumption metadata from the target cluster in real time, generates and saves a key-value pair with the consumer group ID, topic and partition ID in the latest consumption metadata as the primary key and the latest consumption metadata as the value.

4. The data disaster recovery method based on message middleware according to claim 3, characterized in that: The real-time calculation of the consumption offset difference between the target cluster and the source cluster based on the latest consumption metadata includes: Real-time query of the consumption offset difference table to see whether the consumption offset difference corresponding to the latest primary key exists; If the consumption offset difference corresponding to the latest primary key does not exist in the consumption offset difference table, then the corresponding message is matched from the target cluster according to the topic, partition ID and business ID in the latest consumption metadata; Obtaining the consumption offset of the source cluster from the latest consumption metadata as the first consumption offset; and using the offset of the message matched from the target cluster as the second consumption offset; A difference between the first consumption offset and the second consumption offset is calculated, and the difference is used as a consumption offset difference between the target cluster and the source cluster for the message corresponding to the latest primary key.

5. The data disaster recovery method based on message middleware according to claim 4, characterized in that: The real-time correction of the consumption offset of the target cluster according to the consumption offset difference includes: The first consumption offset is added to the consumption offset difference in real time.

6. A data disaster recovery system based on message middleware, characterized in that: include: A source cluster, where the source cluster is a message middleware cluster of the first data center; A target cluster, where the target cluster is a message middleware cluster in the second data center; The collection end is used to write the same message to the same partition of the same topic of the source cluster and the target cluster in real time; The consumer side is used to provide the latest consumption offset to the source cluster in real time, and provide the latest consumption metadata to the target cluster in real time; when the source cluster is abnormal, it switches to the target cluster and continues to consume messages according to the corrected consumption offset; The offset synchronization server is used to calculate the consumption offset difference between the target cluster and the source cluster in real time based on the latest consumption metadata, and to correct the consumption offset of the target cluster in real time based on the consumption offset difference.

7. The data disaster recovery system based on message middleware according to claim 6, characterized in that: The consumption metadata includes consumption group ID, topic, partition ID, record timestamp, business ID and consumption offset.

8. The data disaster recovery system based on message middleware according to claim 7, characterized in that: The offset synchronization server is further configured to: The offset synchronization server obtains the latest consumption metadata from the target cluster in real time, generates and saves a key-value pair with the consumer group ID, topic and partition ID in the latest consumption metadata as the primary key and the latest consumption metadata as the value.

9. The data disaster recovery system based on message middleware according to claim 8, characterized in that: The real-time calculation of the consumption offset difference between the target cluster and the source cluster based on the latest consumption metadata includes: Real-time query of the consumption offset difference table to see whether the consumption offset difference corresponding to the latest primary key exists; If the consumption offset difference corresponding to the latest primary key does not exist in the consumption offset difference table, then the corresponding message is matched from the target cluster according to the topic, partition ID and business ID in the latest consumption metadata; Obtaining the consumption offset of the source cluster from the latest consumption metadata as the first consumption offset; and using the offset of the message matched from the target cluster as the second consumption offset; A difference between the first consumption offset and the second consumption offset is calculated, and the difference is used as a consumption offset difference between the target cluster and the source cluster for the message corresponding to the latest primary key.

10. The data disaster recovery system based on message middleware according to claim 9, characterized in that: The real-time correction of the consumption offset of the target cluster according to the consumption offset difference includes: The first consumption offset is added to the consumption offset difference in real time.

11. A computer device comprising a memory, a processor, and a computer program stored in the memory, characterized in that: When the computer program is executed by the processor, the computer program executes the instructions of the method according to any one of claims 1 to 5.

12. A computer storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor of a computer device, the computer program executes the instructions of the method according to any one of claims 1 to 5.

13. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor of a computer device, the computer program executes instructions of the method according to any one of claims 1 to 5.