Data synchronization method for distributed cluster and related device thereof
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ALIBABA CLOUD COMPUTING CO LTD
- Filing Date
- 2023-05-19
- Publication Date
- 2026-08-07
AI Technical Summary
[0005]本发明实施例提供的分布式集群的数据同步方法及其相关装置,至少解决隔离的不同站点之间停机迁移导致的服务不可用的问题
[0022]本发明实施例提供的分布式集群的数据同步方法及其相关设备,通过基于分布式集群中存储管理单元组的主从状态切换,确定同步时间片;生成存储管理单元组中的主存储管理单元在同步时间片内的数据操作日志;将数据操作日志同步至存储管理单元组中的从存储管理单元,以使从存储管理单元基于数据操作日志进行数据同步,解决了隔离的不同站点之间停机迁移导致的服务不可用和增量数据同步一致性的问题,实现了隔离站点间的不停机迁移数据,实现了隔离站点之间增量数据同步。
Smart Images

Figure CN117112690B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to data synchronization methods and related devices for distributed clusters. Background Technology
[0002] This section is intended to provide background or context for the embodiments of the invention set forth in the claims. It should not be construed as an admission that the description herein is prior art.
[0003] The artifact repository requires redundant backups across different sites and artifact synchronization between these sites. This allows for master-slave failover to achieve high availability in the event of regional issues. Furthermore, network latency caused by regional factors can be mitigated through multi-site deployment. Additionally, there is a need for artifact synchronization between different deployment environments. Unverified artifacts need to be verified in the development environment first, and then synchronized to the stable production environment via site synchronization.
[0004] Since different sites within a finished goods warehouse are isolated, conventional online data synchronization methods cannot achieve data synchronization between them. Related technologies typically employ a shutdown migration method to migrate data between isolated sites; however, shutdown migration results in temporary service unavailability and cannot achieve real-time synchronization of incremental data. Summary of the Invention
[0005] The distributed cluster data synchronization method and related apparatus provided in this invention at least solve the problem of service unavailability caused by downtime migration between isolated sites.
[0006] A data synchronization method for a distributed cluster includes: The synchronization time slice is determined based on the master-slave state switching of the storage management unit group in the distributed cluster. Generate a data operation log for the primary storage management unit in the storage management unit group within the synchronization time slice; The data operation log is synchronized to the slave storage management unit in the storage management unit group, so that the slave storage management unit can perform data synchronization based on the data operation log.
[0007] In some embodiments, the method further includes: Metadata of the primary storage management unit is generated so that when the data operation log is synchronized to the secondary storage management units in the storage management unit group, the data operation log to be synchronized in the data operation log is determined based on the metadata, wherein the metadata includes the synchronization status of the data operation log; The metadata is updated based on the synchronization results of the data operation log.
[0008] In some embodiments, generating the data operation log of the primary storage management unit in the storage management unit group within the synchronization time slice includes: According to the execution order of data operations, persist the data operation information of the distributed cluster, wherein the data operation information includes the operation object, operation content and the information of the storage management unit that performs the data operation; Based on the data operation information of the cluster, the main storage management unit obtains the data operation log within the synchronization time slice, wherein the data operation log is sorted according to the execution order of the data operations.
[0009] In some embodiments, determining the synchronization time slice based on the master-slave state switching of storage management unit groups in a distributed cluster includes: Obtain the master-slave state switching logic clock of the storage management unit group, and determine the synchronization time slice and the sequence number of the synchronization time slice based on the master-slave state switching logic clock.
[0010] In some embodiments, the method further includes: When the master-slave state of the storage management unit in the distributed cluster switches, the cluster reports the master-slave state switching logic clock to the storage system, and the storage system sends the sequence number of the synchronization time slice to the distributed cluster in an ordered auto-incrementing manner according to the master-slave state switching logic clock.
[0011] In some embodiments, the method further includes: The distributed cluster periodically obtains the sequence number of the synchronization time slice from the storage system.
[0012] In some embodiments, synchronizing the data operation log to the slave storage management units in the storage management unit group includes: Based on the index number of the data operation log, the index number of the committed data operation log recorded in the metadata, and the sequence number of the synchronization time slice, the data operation log to be synchronized in the primary storage management unit is determined, and the data operation log to be synchronized is synchronized to the secondary storage management unit.
[0013] In some embodiments, if the synchronization time slice numbers of the primary storage management unit and the secondary storage management unit are the same, the data operation log to be synchronized is determined and the synchronization of the data operation log to be synchronized is performed.
[0014] In some of these embodiments, in the initial state, all storage management units in the master cluster of the distributed cluster are master storage management units, and all storage management units in the slave cluster of the distributed cluster are slave storage management units. The master-slave switching of the storage management unit group is managed by a preset controller.
[0015] In some embodiments, the preset controller sets the storage management unit with the identifier of the storage management unit as the master storage management unit by adding the identifier of the storage management unit to the gray list, so as to realize the master-slave state switching of the storage management units in the storage management unit group in the distributed cluster.
[0016] In some embodiments, when there is data to be written to the storage management unit group, the primary storage management unit in the storage management unit group is determined by querying the preset controller, and the data is written to the primary storage management unit.
[0017] In some embodiments, the method further includes: The data storage state of the storage management unit is a finite state machine. A leader node and at least one follower node are elected in the master storage management unit and the slave storage management unit, respectively. The leader node performs replica synchronization of the finite state machine within the storage management unit group based on the data operation log.
[0018] A distributed cluster system includes multiple clusters and a storage system, wherein the multiple clusters include a master cluster and at least one slave cluster, and the storage system is connected to each of the multiple clusters. The storage system is used to store the sequence number of the synchronization time slice; the multiple clusters all perform data synchronization through the above-described data synchronization method.
[0019] In some embodiments, the distributed cluster system further includes a preset controller, which is used to control the master-slave state switching of the storage management unit and record the master-slave state of the storage management unit.
[0020] An electronic device includes: a processor and a memory storing a program, wherein the program includes instructions that, when executed by the processor, cause the processor to perform the data synchronization method described above.
[0021] A non-transitory machine-readable medium storing computer instructions, wherein the computer instructions are used to cause the computer to perform the data synchronization method described above.
[0022] The distributed cluster data synchronization method and related equipment provided in this invention determine the synchronization time slice based on the master-slave state switching of the storage management unit group in the distributed cluster; generate a data operation log of the master storage management unit in the storage management unit group within the synchronization time slice; and synchronize the data operation log to the slave storage management unit in the storage management unit group, so that the slave storage management unit can perform data synchronization based on the data operation log. This solves the problems of service unavailability and incremental data synchronization consistency caused by downtime migration between isolated sites, realizes non-downtime data migration between isolated sites, and realizes incremental data synchronization between isolated sites.
[0023] Details of one or more embodiments of the present invention are set forth in the following drawings and description, so that other features, objects and advantages of the invention will be more readily understood. Attached Figure Description
[0024] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other embodiments can be obtained based on these drawings without creative effort.
[0025] Figure 1 This is a flowchart of a distributed cluster data synchronization method according to an embodiment of the present invention.
[0026] Figure 2 This is a schematic diagram of the data operation logs and metadata of the generation storage management unit in an embodiment of the present invention.
[0027] Figure 3 This is a flowchart illustrating the process of a storage management unit sending a data operation log request according to an embodiment of the present invention.
[0028] Figure 4 This is a flowchart illustrating how the storage management unit receives a data operation log request according to an embodiment of the present invention.
[0029] Figure 5 This is a flowchart illustrating the process of sending data snapshots by the storage management unit, which acts as the Master, according to an embodiment of the present invention.
[0030] Figure 6 This is a schematic diagram of the synchronous control of multiple storage management units according to an embodiment of the present invention.
[0031] Figure 7 This is a schematic diagram of a synchronization task processing based on a distributed consensus algorithm according to an embodiment of the present invention.
[0032] Figure 8 This is a schematic diagram of the structure of a distributed cluster according to an embodiment of the present invention.
[0033] Figure 9 This is a schematic diagram of the structure of the electronic device in this embodiment. Detailed Implementation
[0034] Embodiments of this embodiment will now be described in more detail with reference to the accompanying drawings. While some embodiments of this embodiment are shown in the drawings, it should be understood that this embodiment can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of this embodiment. It should be understood that the accompanying drawings and embodiments are for illustrative purposes only and are not intended to limit the scope of protection of this embodiment.
[0035] An artifact repository, as the name suggests, is a repository for artifacts. Artifacts are the deliverables of software delivery, typically in executable binary form; therefore, an artifact repository is often called a binary artifact repository. During the development phase, the artifact repository provides a single entry point for dependency resolution for microservice developers using various programming languages. During the build phase, it provides a single source of dependency resolution and a unified management repository for artifacts across various languages for build tools. In the testing phase, all test environment deployment tools pull artifacts that meet the testing conditions from the artifact repository for deployment. After testing, the test results are fed back to the artifact repository and associated with the artifacts. During the deployment phase, quality control checks ensure that artifacts meet deployment conditions; if they do, the deployment tools pull artifacts from the artifact repository and deploy them to the environment.
[0036] To ensure data synchronization security, real-time data synchronization solutions require a unified synchronization clock across different devices to avoid synchronization errors and guarantee data rollback. However, the finished goods warehouse uses multi-region isolation. Since there is no synchronization clock between the isolated regions, conventional real-time data synchronization methods cannot be used, and only a shutdown migration method can be adopted.
[0037] For example, JForg's repository replication data migration solution uses HTTP calls to upload artifacts by calling the interface of an existing artifact system that does not have an artifact system. However, this method cannot avoid the security and stability of data synchronization under non-Byzantine problems, only supports artifact migration but not data migration of other formats, and cannot isolate data across multiple regions.
[0038] Rsync's open-source data migration solution, among related technologies, transmits data by establishing an SSH connection with the target system and calling the data interface on the remote system. This method requires manual migration, cannot automatically synchronize incremental data, and only performs simple file synchronization, failing to establish a connection between files and the system.
[0039] The distributed cluster system in this embodiment includes a master cluster and at least one slave cluster. Each cluster comprises multiple nodes, which are further divided into isolated storage management units, also known as regions. The master and slave storage management units that perform data synchronization form a storage management unit group. Each storage management unit group has one and only one master storage management unit and at least one or more slave storage management units. The master-slave status of storage management units within a storage management unit group can be switched. Initially, all regions in the master cluster are in master mode, and all regions in the slave cluster are in slave mode. The master cluster initiates data synchronization, while the slave clusters receive data synchronization. However, after a master-slave status switch within a region of the master-slave cluster, data synchronization may still be initiated by the slave cluster and received by the master cluster.
[0040] For example, during data synchronization, in the initial state, data is written to the region in the master cluster that acts as the master and then synchronized to the region in the slave cluster that acts as the slave. When the master-slave status of two or more regions that act as master and slave switches, data is written to the region in the slave cluster that acts as the master and then synchronized to the region in the master cluster that acts as the slave.
[0041] To achieve data synchronization between isolated sites and avoid service downtime and unavailability, this invention provides a data synchronization method for a distributed cluster. Figure 1 This is a flowchart of a distributed cluster data synchronization method according to an embodiment of the present invention, such as... Figure 1 As shown, the process includes the following steps: Step S101: Determine the synchronization time slice based on the master-slave state switching of the storage management unit group in the distributed cluster.
[0042] Step S102: Generate the data operation log of the primary storage management unit in the storage management unit group within the synchronization time slice.
[0043] Step S103: Synchronize the data operation log to the slave storage management unit in the storage management unit group so that the slave storage management unit can perform data synchronization based on the data operation log.
[0044] Through the above steps, based on the master-slave state switching of storage management unit groups in the distributed cluster, a synchronization time slice is determined. The data storage status of the storage management units within the synchronization time slice is synchronized based on data operation logs, thus solving the problem of real-time data synchronization between isolated multiple storage management units. This data synchronization method can achieve real-time data synchronization not only for existing data but also for incremental data, without requiring downtime migration, and is applicable to any type of data synchronization.
[0045] The synchronization status of the data operation logs, such as synchronized data operation logs and data operation logs submitted to slave storage management units, can be stored in metadata and updated based on the synchronization results of the data operation logs to determine the data storage status of each storage management unit during data synchronization. In some embodiments, the method further includes: generating metadata for the primary storage management unit so that when synchronizing the data operation logs to slave storage management units in the storage management unit group, the metadata is used to determine the data operation logs to be synchronized, wherein the metadata includes the synchronization status of the data operation logs; and updating the metadata based on the synchronization results of the data operation logs.
[0046] In some embodiments, the data storage state of the storage management unit is treated as a finite state machine, thereby enabling data synchronization of the storage management unit based on the replica synchronization mechanism of the finite state machine. In the replica synchronization mechanism of the finite state machine, replica synchronization is performed based on a synchronization log. In this embodiment, the data operation log is used as the synchronization log for the replica synchronization of the finite state machine.
[0047] In this embodiment, the predefined data objects include cluster objects, node objects, and a finite state machine. The cluster object includes the state of each cluster node. The node object includes node metadata, which records the cluster's state information during data synchronization. This metadata includes the synchronization time slice number (term) of the storage management unit, the index (logIndex) of the data operation log used to mark the location information of the data operation log, the index number (snapshotIndex) of the last data operation log contained in the snapshot, the synchronization time slice number (snapshotTerm) of the last data operation log contained in the snapshot, and the index number (preLogIndex) of the largest log that has been applied to the slave. The node object also includes node location information (endpoint), representing the node's coordinates, typically the terminal's IP address in a network environment. The node object may also include the state of the master node that initiated the data synchronization cluster during the data synchronization process. The finite state machine includes the executed data objects and the executed actions (i.e., data operations). In this embodiment, the storage management unit with a master-slave relationship is considered a finite state machine.
[0048] The data storage status includes existing data as well as data operations performed on that existing data, such as adding, deleting, and modifying data. Existing data is typically stored as a snapshot, while data operations are recorded in an operation log. Between storage management units in a master-slave relationship, if the existing data has been synchronized (i.e., the existing data is identical across all storage management units), the data storage status of a storage management unit can be represented solely by data operations performed on the existing data.
[0049] A finite state machine has a finite number of states. It begins with a given initial state (e.g., the initial state, or a state with identical existing data). Each input received generates a new state and corresponding output through transition and output equations. This new state is maintained until the next input arrives, and the output is passed to the appropriate receiver. Multiple copies of the same state machine can be synchronized across multiple memory management units using a replicated state machine approach. Multiple copies of the same state machine start from the initial state and, by receiving the same inputs in the same order, will reach the same state that has generated the same output; this is a replicated state machine.
[0050] The sequence number (term) of the aforementioned synchronization time slice serves as the synchronization clock for all clusters in the distributed cluster. This synchronization time slice sequence number is strictly ordered and auto-incremented starting from a set value (e.g., 0). The synchronization time slice sequence number will be cached in a storage system with high-performance storage media.
[0051] In the above steps, the synchronization time slice of the finite state machine is updated based on the master-slave state switch of any group of storage management units. Since the update of the synchronization time slice number is marked by the master-slave state switch of the storage management unit, the state of the finite state machine of any storage management unit after the master-slave state switch falls within at least one synchronization time slice; that is, a correspondence can be established between the finite state machine of the storage management unit and the synchronization time slice number. Therefore, by obtaining the master-slave state switch logic clock of any group of storage management units in the cluster, the cluster can determine the synchronization time slice number of the synchronization time slice that storage management unit enters from the master-slave state switch logic clock. Since the synchronization time slice number is also incremented due to the master-slave state switches of other groups of storage management units in the distributed cluster, the state changes of the finite state machine of a certain storage management unit may span multiple synchronization time slices, corresponding to multiple synchronization time slice numbers. In this embodiment, the data operation logs and metadata generated within each synchronization time slice are marked with the corresponding synchronization time slice number.
[0052] When any storage management unit in any cluster of a distributed cluster switches between master and slave states, each cluster reports its master-slave state switch logic clock to the storage system. The sequence number of the synchronization time slice in the storage system is incremented by one. The storage system then sequentially increments the sequence number of the synchronization time slice according to the master-slave state switch logic clock and sends it to the distributed cluster. Furthermore, each cluster in the distributed cluster periodically retrieves the sequence number of the synchronization time slice to prevent failure in sending the sequence number.
[0053] In this embodiment, the input data of the finite state machine is data operation information. To meet the requirement of identical input for a replicated state machine, the data operation information must not only have the same operation content but also maintain the same execution order. Therefore, in any cluster of the distributed cluster, the data operation information of the clusters in the distributed cluster is persisted according to the execution order of the data operations. This data operation information includes the operation object, operation content, and information about the storage management unit that performs the data operation.
[0054] Specifically, in the cluster that receives data writes (usually a Master cluster), you can attach a tracking point to each write operation to record the operation object, operation content, and information of the storage management unit that performed the data operation. After encapsulation, this information is used as an incremental operation log (pendingLog) generated by the data synchronization initiator. Then, the incremental operation log is persisted to the database, and the database is used to ensure that the incremental operation log is stored in the execution order.
[0055] In the cluster receiving data writes, the incremental operation logs executed by all storage management units are stored together in execution order. To perform data synchronization on a storage management unit basis, the incremental operation logs can be further grouped according to the storage management unit. For example, ... Figure 2 As shown, in the cluster receiving data writing, the node used to handle the synchronization task is selected to start a thread to read the incremental operation logs from the database in batches. Then, it is divided according to the storage management unit. In the same storage management unit, each log is marked with the sequence number of the synchronization time slice and the index number (logIndex) of the data operation log to generate a data operation log for data synchronization.
[0056] If this is the first time a synchronization log has been generated for the current storage management unit, the index number of the data operation log starts from 0 and increments sequentially. Simultaneously, the metadata of this storage management unit is initialized. The snapshot index number (snapshotIndex) in the metadata is a random value n (e.g., any integer between 1 and 100). The metadata of the storage management unit also includes data used for data synchronization management, such as the index number of the last data operation log that has been applied by the slave node (lastAppliedIndex) and the index number of the committed data operation log (committedIndex). During initialization, lastAppliedIndex and committedIndex are set to the same value n as snapshotIndex. The sequence number of the synchronization time slice in the metadata is set to the sequence number of the current synchronization time slice. Persisting the data operation log and metadata completes the data preparation work for data synchronization.
[0057] If the current storage management unit is not generating a synchronization log for the first time, meaning it already contains historical data operation logs (including those that have been synchronized and those that haven't), then the index number of the newly generated data operation log is incremented by one from the index number of the last data operation log entry generated previously. Similarly, the snapshotIndex, lastAppliedIndex, and committedIndex in the metadata are each incremented by one from the previously generated snapshotIndex, lastAppliedIndex, and committedIndex. The synchronization time slice sequence number is also set to the current synchronization time slice sequence number. Persisting the data operation log and metadata completes the data preparation work for data synchronization.
[0058] During data synchronization, data synchronization is achieved based on replica synchronization using a finite state machine. For the storage management unit, the cluster receiving the data write will determine the data operation log to be synchronized in the primary storage management unit based on the index number of the data operation log, the index number of the committed data operation log recorded in the metadata, and the sequence number of the synchronization time slice, and then synchronize the data operation log to be synchronized to the secondary storage management unit.
[0059] refer to Figure 3 The primary storage management unit selects a node to handle the synchronization task, which then filters out the storage management units that need to be synchronized. The synchronization task first retrieves the index number of the next log to be synchronized from the cache. If it doesn't exist, it queries the index number of the last committed log entry in the metadata. Then, it sets the index number of the previous data operation log entry, `preLogIndex`, to the committed index number minus one. It determines whether to send a snapshot (a snapshot of the current data in the finite state machine) by comparing `preLogIndex` with `snapshotIndex`. If `preLogIndex` is not less than `snapshotIndex`, it means the existing data has already been migrated; otherwise, it retrieves a batch of data operation logs that need to be synchronized from the database and sends them to the secondary storage management units for processing.
[0060] The process of processing data operation logs from the storage management unit is as follows: Figure 4 As shown, a node for handling data synchronization is also selected from the storage management unit. This node is responsible for processing the data operation log.
[0061] In some embodiments, if the synchronization time slice numbers of the primary storage management unit and the secondary storage management unit are the same in the same storage management unit group, then the data operation log to be synchronized is determined and the synchronization of the data operation log to be synchronized is performed. If the synchronization time slice numbers are different, then a retry is performed.
[0062] If the sequence number of the received data operation log synchronization time slice is inconsistent with the sequence number of the current node's synchronization time slice, it may be that the sequence number of the current node's synchronization time slice has not been updated or the data operation log synchronization request has expired. In this case, the node will return the sequence number of the current node's synchronization time slice to the primary storage management unit. If the sequence numbers of the synchronization time slices are consistent, it means that the data operation log synchronization request is valid. The current storage management unit is then checked again to see if it is in a slave role in the cluster. If it is in a slave role, log verification is performed.
[0063] The current FSM state of the slave storage management unit is determined by the committedIndex of the committed data operation log and the sequence number of the synchronization time slice. If it matches the synchronization request, the slave simply applies the log sent by the master storage management unit, updates the current FSM state and metadata, and returns the result to the master storage management unit. Otherwise, the slave needs to return the current FSM state to the master, hoping that the master will send a matching log in the next synchronization request. The master storage management unit may not receive the return value from the slave storage management unit due to response timeout. In this case, it will retry. If it receives the return value from the slave storage management unit, it updates the next synchronization request based on the state returned by the slave storage management unit.
[0064] The synchronization methods described above can be used for both incremental and existing data synchronization. (See also: [link to relevant documentation]) Figure 3 When the first data operation log request is sent, the secondary storage management unit (SMU) has not yet written its own data operation logs, so the conflict position returned to the primary storage management unit (PMU) is 0. The PMU updates `nextLogIndex` and continues sending data operation logs. At this point, the `preLogIndex` of the data operation log is necessarily smaller than the randomly generated `snapshotIndex`, so the PMU sends a snapshot to migrate existing data. A snapshot is a snapshot of the current storage management unit's FSM generated by the PMU. The snapshot stores the indexes of all data (e.g., artifacts) and related data. In some embodiments, the snapshot sent by the PMU can be a snapshot URL. The actual generated snapshot is uploaded to the file storage system, which reduces the size of the snapshot request. The process of the PMU sending a snapshot is as follows: Figure 5 As shown, firstly, the storage management units that need to be migrated are identified from the set of units that need to send snapshots. An FSM snapshot of the storage management unit is generated. After the snapshot installation request is sent to the slave storage management unit, the installation status of the slave storage management unit is checked. If the sequence number of the request and the synchronization time slice of the slave storage management unit do not match or the snapshot installation of the slave storage management unit fails, the snapshot installation request will be added to the set of units to send snapshots for retry.
[0065] In some embodiments, initially, all storage management units in the master cluster of the distributed cluster are master storage management units, and all storage management units in the slave clusters are slave storage management units. The master-slave switching of storage management units is managed by a preset controller. The preset controller sets the storage management unit with the identifier of the storage management unit as the master storage management unit by adding the identifier of the storage management unit to a gray list, thereby realizing the master-slave state switching of storage management units in the distributed cluster.
[0066] For example, refer to Figure 6 This system establishes master-slave relationships for different storage management units (SMUs) across different clusters and stores these relationships in a queryable master-slave controller. A unified access master-slave controller is configured. When a SMU is not in the graylist, all SMUs in Cluster 1 (e.g., the master cluster) are in the Master state, and all SMUs in Cluster 2 (e.g., the slave cluster) are in the Slave state. Data flows from Cluster 1 to Cluster 2. If a SMU is in the graylist, the SMU in Cluster 2 is in the Master state, and data flows from Cluster 2 to Cluster 1. Due to bidirectional data writing, under secure conditions, the finite state machines (FSMs) of the master and slave SMUs within the same SMU group remain consistent. By controlling whether a SMU is in the graylist, the role of different SMUs in different clusters is controlled, thus controlling the direction of data synchronization. Data added by users in any cluster will not be lost; the added data will be synchronized between Cluster 1 and Cluster 2 via a synchronization log. The aforementioned security status refers to the FSM status of the primary storage management unit and the secondary storage management unit within the same storage management unit being consistent, and the absence of data operation logs that have been applied to the primary storage management unit but not yet to the secondary storage management unit.
[0067] In some embodiments where a preset controller is configured to query the master-slave status of storage management units, when new data is written to a storage management unit, the master storage management unit is determined by querying the preset controller, and the new data is written to the master storage management unit. For example, when a user needs to perform data operations, the user can directly access cluster 1 or cluster 2; the user can confirm whether to access the master node or the slave node by querying the identifier of the storage management unit stored in the master-slave controller.
[0068] To ensure reliable data synchronization and avoid synchronization failures due to a single node failure, in some embodiments, a leader node and at least one follower node are elected in both the primary and secondary storage management units. The leader node in each storage management unit then performs replica synchronization of the finite state machines of the storage management units with a master-slave relationship. (See reference...) Figure 7 In this embodiment, Raft (a distributed consensus algorithm) can be used to elect a leader node in each cluster or storage management unit to handle synchronization tasks. At the same time, multiple follower nodes are configured to take over the synchronization tasks after the leader node fails, ensuring that data is not lost and can be synchronized to the slave storage management unit. When the leader node of the master storage management unit crashes or other abnormal situations, the data in the master storage management unit has been persisted and will not be lost. After a new leader is selected from the follower nodes, data can continue to be synchronized to the slave storage management unit according to the persisted log and metadata. Therefore, the slave storage management unit can still maintain consistency with the master storage management unit.
[0069] This invention, based on Raft log synchronization technology, enables the migration of existing data and the synchronization of incremental data across multiple storage management units. It can be applied to files of any format, not limited to JForg artifact files, while Raft ensures data synchronization security and reliability under non-Byzantine fault conditions. All synchronized data is applied to the system via FSM, and the relationships between data can also be synchronized across different systems. By isolating data through multiple storage management units, the synchronization direction between different storage management units and different sites can be controlled.
[0070] This embodiment also provides a distributed cluster system. Figure 8 This is a schematic diagram of the distributed cluster system in this embodiment, as shown below. Figure 8 As shown, the system includes cluster 81, at least one cluster 82, and storage system 83. Cluster 81 acts as the master controller, cluster 82 acts as the slave controller, and storage system 83 is connected to the aforementioned clusters.
[0071] Storage system 83 is used to store the sequence number of the synchronization time slice; the cluster synchronizes data using the distributed cluster data synchronization method described above.
[0072] In some of these embodiments, the cluster determines a synchronization time slice based on the master-slave state switching of the storage management unit group in the distributed cluster; generates a data operation log for the master storage management unit in the storage management unit group within the synchronization time slice; and synchronizes the data operation log to the slave storage management units in the storage management unit group so that the slave storage management units can perform data synchronization based on the data operation log.
[0073] In some embodiments, the cluster generates metadata for the primary storage management unit (MMU) so that when synchronizing data operation logs to the secondary storage management units (SMUs) in the MMU group, the metadata is used to determine the data operation logs to be synchronized, where the metadata includes the synchronization status of the data operation logs; and the metadata is updated based on the synchronization result of the data operation logs. In some embodiments, the cluster persists data operation information of the distributed cluster according to the execution order of data operations. The data operation information includes the operation object, operation content, and information of the storage management unit that performed the data operation. Based on the cluster's data operation information, the cluster obtains the data operation log of the main storage management unit within the synchronization time slice. The data operation log is sorted according to the execution order of the data operations.
[0074] In some embodiments, the cluster obtains the master-slave state switching logic clock of the storage management unit group, and determines the synchronization time slice and the sequence number of the synchronization time slice based on the master-slave state switching logic clock.
[0075] In some of these embodiments, when the master-slave state of the storage management unit of the distributed cluster switches, the cluster reports the master-slave state switching logic clock to the storage system, and the storage system sends the sequence number of the synchronization time slice, which is incremented in order according to the master-slave state switching logic clock, to the distributed cluster.
[0076] In some of these embodiments, the distributed cluster periodically retrieves the sequence number of the synchronization time slice from the storage system.
[0077] In some of these embodiments, the cluster determines the data operation logs to be synchronized in the primary storage management unit based on the index number of the data operation log, the index number of the committed data operation log recorded in the metadata, and the sequence number of the synchronization time slice, and then synchronizes the data operation logs to be synchronized to the secondary storage management unit.
[0078] In some embodiments, the cluster determines the data operation log to be synchronized and performs synchronization of the data operation log when the synchronization time slice sequence numbers of the primary storage management unit and the secondary storage management unit are the same.
[0079] In some embodiments, the distributed cluster system further includes a preset controller, which controls the master-slave state switching of the storage management unit and records the master-slave state of the storage management unit.
[0080] In some of these embodiments, in the initial state, all storage management units in the master cluster of the distributed cluster are master storage management units, and all storage management units in the slave cluster of the distributed cluster are slave storage management units. The master-slave switching of the storage management unit group is managed by a preset controller.
[0081] In some of these embodiments, the preset controller sets the storage management unit with the identifier of the storage management unit as the master storage management unit by adding the identifier of the storage management unit to the gray list, so as to realize the master-slave state switching of the storage management units in the storage management unit group in the distributed cluster.
[0082] In some of these embodiments, when there is data to be written to a storage management unit group, the primary storage management unit in the storage management unit group is determined by querying a preset controller, and the data is written to the primary storage management unit.
[0083] In some embodiments, the data storage state of the storage management unit is a finite state machine. A leader node and at least one follower node are elected in the master storage management unit and the slave storage management unit, respectively. The leader node performs replica synchronization of the finite state machine within the storage management unit group based on the data operation log.
[0084] This invention also provides an electronic device, including: at least one processor; and a memory communicatively connected to the at least one processor. The memory stores a computer program executable by the at least one processor, which, when executed by the at least one processor, causes the electronic device to perform the method of this invention.
[0085] The present invention also provides a non-transitory machine-readable medium storing a computer program, wherein the computer program, when executed by a computer's processor, is used to cause the computer to perform the method of the present invention.
[0086] This invention also provides a computer program product, including a computer program, wherein the computer program, when executed by a computer's processor, is used to cause the computer to perform the method of this invention.
[0087] refer to Figure 9The present invention will now describe a structural block diagram of an electronic device that can serve as a server or client in embodiments of the present invention, which is an example of a hardware device that can be applied to various aspects of the present invention. The electronic device is intended to represent various forms of digital electronic computer devices, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0088] like Figure 9 As shown, the electronic device includes a computing unit 901, which can perform various appropriate actions and processes based on a computer program stored in a read-only memory (ROM) 902 or a computer program loaded into a random access memory (RAM) 903 from a storage unit 908. The RAM 903 may also store various programs and data required for the operation of the electronic device. The computing unit 901, ROM 902, and RAM 903 are interconnected via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.
[0089] Multiple components in the electronic device are connected to I / O interface 905, including: input unit 906, output unit 907, storage unit 908, and communication unit 909. Input unit 906 can be any type of device capable of inputting information into the electronic device. Input unit 906 can receive input digital or character information and generate key signal inputs related to user settings and / or function control of the electronic device. Output unit 907 can be any type of device capable of presenting information and may include, but is not limited to, a display, speaker, video / audio output terminal, vibrator, and / or printer. Storage unit 908 may include, but is not limited to, disks and optical discs. Communication unit 909 allows the electronic device to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks, and may include, but is not limited to, modems, network cards, infrared communication devices, wireless communication transceivers, and / or chipsets, such as Bluetooth devices, WiFi devices, WiMax devices, cellular communication devices, and / or the like.
[0090] The computing unit 901 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 901 include, but are not limited to, CPUs, graphics processing units (GPUs), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any suitable processor, controller, microcontroller, etc. The computing unit 901 performs the various methods and processes described above. For example, in some embodiments, the method embodiments of the present invention can be implemented as a computer program tangibly contained in a machine-readable medium, such as storage unit 908. In some embodiments, part or all of the computer program can be loaded and / or installed on an electronic device via ROM 902 and / or communication unit 909. In some embodiments, the computing unit 901 can be configured to perform the methods described above by any other suitable means (e.g., by means of firmware).
[0091] Computer programs for implementing the methods of embodiments of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0092] In the context of embodiments of the present invention, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable signal medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0093] It should be noted that the term "comprising" and its variations used in the embodiments of the present invention are open-ended, meaning "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The modifications of "one" and "multiple" mentioned in the embodiments of the present invention are illustrative and not restrictive. Those skilled in the art should understand that, unless explicitly indicated otherwise in the context, they should be understood as "one or more".
[0094] 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, data stored, data displayed, etc.) involved in the embodiments of the present invention are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use and processing of the relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation entry points are provided for users to choose to authorize or refuse.
[0095] The steps described in the method embodiments provided by this invention can be performed in different orders and / or in parallel. Furthermore, the method embodiments may include additional steps and / or omit the steps shown. The scope of protection of this invention is not limited in this respect.
[0096] The term "embodiment" in this specification refers to a specific feature, structure, or characteristic described in connection with an embodiment that may be included in at least one embodiment of the invention. The appearance of this phrase in various places in the specification does not necessarily imply the same embodiment, nor does it imply independence or alternativeity from other embodiments. The various embodiments in this specification are described in a related manner, with reference to each other for similar or identical parts. In particular, for apparatus, device, and system embodiments, since they are substantially similar to method embodiments, the description is relatively simple, and relevant details are referred to in the description of the method embodiments.
[0097] The embodiments described above are merely illustrative of several implementations of the present invention, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of patent protection. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these all fall within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the appended claims.
Claims
1. A data synchronization method for a distributed cluster, the distributed cluster comprising a master cluster and at least one slave cluster, the master cluster and the at least one slave cluster being deployed at isolated sites, the nodes in the master cluster and the at least one slave cluster being respectively divided into multiple mutually isolated storage management units according to regions, the master storage management unit and the slave storage management unit within any storage management unit group being located in the master cluster and the slave cluster respectively, the method comprising: Based on the master-slave state switching of the storage management unit group in the distributed cluster, the master-slave state switching logic clock is reported to the storage system. The storage system then sends the sequence number of the synchronization time slice, which is incremented in order according to the master-slave state switching logic clock, to the distributed cluster to determine the synchronization time slice. The sequence number of the synchronization time slice is used as the synchronization clock of each cluster in the distributed cluster. Generate a data operation log for the primary storage management unit in the storage management unit group within the synchronization time slice; The data operation log is synchronized to the slave storage management unit in the storage management unit group, so that the slave storage management unit can perform data synchronization based on the data operation log.
2. The method according to claim 1, wherein, The method further includes: Metadata of the primary storage management unit is generated so that when the data operation log is synchronized to the secondary storage management units in the storage management unit group, the data operation log to be synchronized in the data operation log is determined based on the metadata, wherein the metadata includes the synchronization status of the data operation log; The metadata is updated based on the synchronization results of the data operation log.
3. The method according to claim 1, wherein, The generation of data operation logs for the primary storage management unit in the storage management unit group within the synchronization time slice includes: According to the execution order of data operations, persist the data operation information of the distributed cluster, wherein the data operation information includes the operation object, operation content and the information of the storage management unit that performs the data operation; Based on the data operation information of the cluster, the main storage management unit obtains the data operation log within the synchronization time slice, wherein the data operation log is sorted according to the execution order of the data operations.
4. The method according to claim 1, wherein, Based on the master-slave state switching of storage management unit groups in a distributed cluster, the synchronization time slice is determined as follows: Obtain the master-slave state switching logic clock of the storage management unit group, and determine the synchronization time slice and the sequence number of the synchronization time slice based on the master-slave state switching logic clock.
5. The method according to claim 1, wherein, The method further includes: The distributed cluster periodically obtains the sequence number of the synchronization time slice from the storage system.
6. The method according to claim 2, wherein, Synchronizing the data operation log to the slave storage management units in the storage management unit group includes: Based on the index number of the data operation log, the index number of the committed data operation log recorded in the metadata, and the sequence number of the synchronization time slice, the data operation log to be synchronized in the primary storage management unit is determined, and the data operation log to be synchronized is synchronized to the secondary storage management unit.
7. The method according to claim 6, wherein, If the synchronization time slice numbers of the primary storage management unit and the secondary storage management unit are the same, the data operation log to be synchronized is determined and the synchronization of the data operation log to be synchronized is performed.
8. The method according to claim 1, wherein, In the initial state, all storage management units in the master cluster of the distributed cluster are master storage management units, and all storage management units in the slave cluster of the distributed cluster are slave storage management units. The master-slave switching of the storage management unit group is managed by a preset controller.
9. The method according to claim 8, wherein, The preset controller sets the storage management unit with the identifier of the storage management unit as the master storage management unit by adding the identifier of the storage management unit to the gray list, so as to realize the master-slave state switching of the storage management units in the storage management unit group in the distributed cluster.
10. The method according to claim 8, wherein, When there is data to be written to the storage management unit group, the primary storage management unit in the storage management unit group is determined by querying the preset controller, and the data is written to the primary storage management unit.
11. The method according to claim 1, wherein, The method further includes: The data storage state of the storage management unit is a finite state machine. A leader node and at least one follower node are elected in the master storage management unit and the slave storage management unit, respectively. The leader node performs replica synchronization of the finite state machine within the storage management unit group based on the data operation log.
12. A distributed cluster system, comprising multiple clusters and a storage system, wherein the multiple clusters include a master cluster and at least one slave cluster, the master cluster and the at least one slave cluster are deployed at isolated sites, and the storage system is connected to the multiple clusters respectively; The storage system is used to store the sequence number of the synchronization time slice, which serves as the synchronization clock for the plurality of clusters; the plurality of clusters are all synchronized with data using the method described in any one of claims 1 to 11.
13. The distributed cluster system according to claim 12, wherein, The distributed cluster system also includes a preset controller, which is used to control the master-slave state switching of the storage management unit and record the master-slave state of the storage management unit.
14. An electronic device comprising: A processor, and a memory storing a program, wherein the program includes instructions that, when executed by the processor, cause the processor to perform the method according to any one of claims 1 to 11.
15. A non-transitory machine-readable medium storing computer instructions, wherein, The computer instructions are used to cause the computer to perform the method according to any one of claims 1 to 11.
Citation Information
Patent Citations
Data processing method and system, computer equipment and storage medium
CN111368002A
Cross-regional service disaster recovery method and device based on main and standby cluster servers
CN114090349A