[go: up one dir, main page]

CN110737716B - A method and device for writing data - Google Patents

A method and device for writing data Download PDF

Info

Publication number
CN110737716B
CN110737716B CN201810706826.8A CN201810706826A CN110737716B CN 110737716 B CN110737716 B CN 110737716B CN 201810706826 A CN201810706826 A CN 201810706826A CN 110737716 B CN110737716 B CN 110737716B
Authority
CN
China
Prior art keywords
sub
log
logs
node
stored
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201810706826.8A
Other languages
Chinese (zh)
Other versions
CN110737716A (en
Inventor
戴冠群
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CN201810706826.8A priority Critical patent/CN110737716B/en
Publication of CN110737716A publication Critical patent/CN110737716A/en
Application granted granted Critical
Publication of CN110737716B publication Critical patent/CN110737716B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1448Management of the data involved in backup or backup restore

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application provides a data writing method and device. The method comprises the following steps: the method comprises the steps that a main node stores N sub-logs of a log to the local, the log is generated according to an atomic write request, the atomic write request comprises N sub-writes, information of the sub-writes is recorded in the sub-logs, and N is a positive integer larger than 0; the main node backs up the N sub-logs into a standby node; and the master node marks the logs as valid under the condition that the master node determines that all the N sub-logs are stored in the standby node. The technical scheme provided by the application can ensure the atomicity of a group of write requests through a log mechanism in the data backup process, and avoids the realization of the atomicity through a file system semantic lock in the prior art, so that the process complexity and the system overhead can be reduced.

Description

一种数据写入的方法和装置A method and device for writing data

技术领域technical field

本申请涉及存储领域,并且更具体地,涉及一种数据写入的方法和装置。The present application relates to the field of storage, and more particularly, to a method and apparatus for writing data.

背景技术Background technique

存储系统中,为了防止操作系统出现硬件或存储媒体出现故障而导致的数据丢失,可以将本地存储的数据备份到备用节点中。文件系统是操作系统中管理和存储文件信息的软件机构,主要负责为用户建立文件,存入、读出、转储文件,控制文件的存取等。文件系统在提供数据备份的存储服务过程中,主要通过原子操作(即需要保证一组写请求全部成功或全部失败)来防止掉电或系统崩溃造成的数据不一致或损坏。例如,网络附属存储(network attached storage,NAS)可以是一种为存储设备提供高效稳定的文件系统。In the storage system, in order to prevent data loss caused by the hardware failure of the operating system or the failure of the storage medium, the locally stored data can be backed up to the standby node. The file system is a software organization that manages and stores file information in the operating system. It is mainly responsible for creating files for users, storing, reading, and dumping files, and controlling file access. In the process of providing data backup storage services, the file system mainly uses atomic operations (that is, it is necessary to ensure that a group of write requests all succeed or fail) to prevent data inconsistency or damage caused by power failure or system crash. For example, network attached storage (NAS) may be a file system that provides efficient and stable storage devices.

现有技术在数据备份的过程中,为了保证文件系统中多个节点之间的原子操作,需要在文件系统中增加语义锁,在数据备份过程中,通过语义锁保证一组写请求的原子操作。但是,通过增加语义锁来保证写请求的原子操作会使得系统流程复杂,同时需要在一组写请求全部写入并备份成功之后,需要打开语义锁,从而增加了系统开销。In the process of data backup in the prior art, in order to ensure atomic operations between multiple nodes in the file system, it is necessary to add semantic locks in the file system. In the process of data backup, semantic locks are used to ensure the atomic operation of a group of write requests. . However, adding semantic locks to ensure the atomic operation of write requests will complicate the system process. At the same time, after a group of write requests are all written and backed up successfully, semantic locks need to be opened, which increases system overhead.

因此,如何在数据备份过程中,保证写请求的原子操作的同时可以降低流程复杂性以及系统开销。Therefore, how to ensure the atomic operation of the write request during the data backup process can reduce the process complexity and system overhead.

发明内容SUMMARY OF THE INVENTION

本申请提供一种数据写入的方法和装置,可以在数据备份的过程中通过日志机制保证一组写请求的原子性,避免了现有技术中通过文件系统语义锁来实现原子性,从而可以降低流程复杂性以及系统开销。The present application provides a data writing method and device, which can ensure the atomicity of a group of write requests through a log mechanism in the process of data backup, avoiding the implementation of atomicity through the semantic lock of the file system in the prior art, so that the Reduce process complexity and system overhead.

第一方面,提供了一种数据写入的方法,该方法包括:主节点将日志的N个子日志存储到本地;所述主节点将所述N个子日志备份到备节点中;所述主节点在确定N个子日志全部存储到所述备节点的情况下,将所述日志标记为有效。In a first aspect, a data writing method is provided, the method comprising: a master node stores N sub-logs of a log locally; the master node backs up the N sub-logs to a standby node; the master node When it is determined that all the N sub-logs are stored in the standby node, the log is marked as valid.

本申请实施例中,一组写请求可以包括N个子写,N为大于0的正整数。为了保证该一组写请求全部成功或全部失败(也就是说,该一组写请求为不可被中断的一个或一个系列操作),该组写请求可以被称为一个原子写,该组写请求也可以称为具有原子性。In this embodiment of the present application, a group of write requests may include N sub-writes, where N is a positive integer greater than 0. In order to ensure that the set of write requests all succeed or fail (that is, the set of write requests is one or a series of operations that cannot be interrupted), the set of write requests can be called an atomic write, and the set of write requests can be called an atomic write. It can also be called atomic.

应理解,一个原子写中的一连串子写可以生成一条日志(log),一个原子写中的N个子写可以生成N条子日志(sublog)。其中,子日志可以记录子写的信息(也就是说,一个子写可以对应一条子日志),记录的信息可以包括但不限于:存放的地址(起始地址),写入的数据、写入数据的长度等。It should be understood that a series of sub-writes in one atomic write can generate one log (log), and N sub-writes in one atomic write can generate N sub-logs (sublog). Among them, the sub-log can record the information of the sub-write (that is, a sub-write can correspond to a sub-log), and the recorded information can include but is not limited to: the stored address (starting address), the written data, the written length of data, etc.

本申请实施例中,在数据备份的过程中通过日志机制保证一组写请求的原子性,避免了现有技术中通过文件系统语义锁来实现原子性,从而可以降低流程复杂性以及系统开销。In the embodiments of the present application, the log mechanism is used to ensure the atomicity of a group of write requests in the process of data backup, which avoids implementing the atomicity through the file system semantic lock in the prior art, thereby reducing process complexity and system overhead.

结合第一方面,在第一方面的某些实现方式中,所述方法还包括:在所述备节点中的所述N个子日志存储失败的情况下,所述主节点将存储的所述N个子日志删除。With reference to the first aspect, in some implementations of the first aspect, the method further includes: in the case where the storage of the N sub-logs in the standby node fails, the master node will store the N sub-logs Sublogs are deleted.

可选地,在一些实施例中,如果对端由于资源或各种原因,使得对端的操作执行失败。本申请实施例可以采用回滚机制,可以将本端存储的log回滚掉,可以保障整个系统数据的原子性(一组写请求或者全部成功或者全部失败)。Optionally, in some embodiments, if the peer end fails to perform the operation due to resources or various reasons. The embodiment of the present application may adopt a rollback mechanism, which may roll back the log stored at the local end, and ensure the atomicity of the entire system data (either a set of write requests succeed or fail).

本申请实施例中,通过回滚机制保障节点间写请求的原子性,避免了现有技术中依赖重试来保障节点间写请求的原子性,提高了系统的可服务性。In the embodiment of the present application, the atomicity of the write request between nodes is guaranteed by the rollback mechanism, which avoids relying on retry to ensure the atomicity of the write request between the nodes in the prior art, and improves the serviceability of the system.

结合第一方面,在第一方面的某些实现方式中,所述N个子日志携带相同的日志标识号ID,所述主节点根据所述ID将所述N个子日志有序存储到所述主节点的日志存储容器中。With reference to the first aspect, in some implementations of the first aspect, the N sub-logs carry the same log identification number ID, and the master node stores the N sub-logs in the master node in an orderly manner according to the ID. in the log storage container of the node.

本申请实施例中,在数据备份过程中,备节点作为主节点的容灾备份,备节点写入的数据顺序需要按照主节点的顺序写入,也就是说,备节点写入的数据和主节点写入的数据的顺序需要保持一致。作为一个示例,本申请实施例可以对每一个log生成一个身份标识号(identity,ID),log上面的多个sublog也可以具有相同的log ID。本节点以及备节点可以按照log ID将sublog挂入相对应的chunk中,chunk中的sublog链表中的sublog可以按照log ID有序排列。In the embodiment of the present application, during the data backup process, the standby node serves as the disaster recovery backup of the master node, and the data written by the standby node needs to be written in the order of the master node. The order of data written by nodes needs to be consistent. As an example, this embodiment of the present application may generate an identity number (identity, ID) for each log, and multiple sublogs on the log may also have the same log ID. The local node and the standby node can attach sublogs to the corresponding chunks according to their log IDs, and the sublogs in the sublog linked list in the chunks can be arranged in order according to their log IDs.

结合第一方面,在第一方面的某些实现方式中,所述主节点接收通知消息,所述通知消息用于指示所述N个子日志全部存储到所述备节点中;所述主节点将所述日志标记为有效。With reference to the first aspect, in some implementations of the first aspect, the master node receives a notification message, and the notification message is used to instruct the N sub-logs to be stored in the standby node; The log is marked as valid.

第二方面,提供了一种数据写入的方法,该方法包括:备节点将主节点备份的日志的N个子日志存储到所述备节点中;在所述N个子日志全部存储到所述备节点时,所述备节点将所述日志标记为有效;所述备节点向所述主节点通知所述N个子日志全部存储到所述备节点中。In a second aspect, a data writing method is provided. The method includes: a standby node stores N sub-logs of logs backed up by a master node in the standby node; and stores all the N sub-logs in the standby node. The standby node marks the log as valid; the standby node notifies the master node that all the N sub-logs are stored in the standby node.

应理解,所述日志是根据一个原子写请求生成的,所述一个原子写请求包括N个子写,所述子日志记录子写的信息,N为大于0的正整数。It should be understood that the log is generated according to one atomic write request, the one atomic write request includes N sub-writes, the sub-log records the information of the sub-writes, and N is a positive integer greater than 0.

本申请实施例中,在数据备份的过程中通过日志机制保证一组写请求的原子性,避免了现有技术中通过文件系统语义锁来实现原子性,从而可以降低流程复杂性以及系统开销。In the embodiments of the present application, the log mechanism is used to ensure the atomicity of a group of write requests in the process of data backup, which avoids implementing the atomicity through the file system semantic lock in the prior art, thereby reducing process complexity and system overhead.

结合第二方面,在第二方面的某些实现方式中,所述N个子日志携带相同的日志标识号ID,所述备节点根据所述ID将所述N个子日志有序存储到所述备节点的日志存储容器中。With reference to the second aspect, in some implementations of the second aspect, the N sub-logs carry the same log identification number ID, and the standby node stores the N sub-logs in the standby node in an orderly manner according to the ID. in the log storage container of the node.

结合第二方面,在第二方面的某些实现方式中,所述备节点向所述主节点发送通知消息,所述通知消息用于指示所述N个子日志全部存储到所述备节点的日志存储容器中。With reference to the second aspect, in some implementations of the second aspect, the standby node sends a notification message to the primary node, where the notification message is used to instruct the N sub-logs to be all stored in the log of the standby node in storage container.

第三方面,提供了一种数据写入的装置,该装置包括:存储模块,用于将日志的N个子日志存储到本地;发送模块,用于将所述N个子日志备份到备节点中;第一处理模块,用于在确定所述N个子日志全部存储到所述备节点的情况下,将所述日志标记为有效。In a third aspect, a data writing device is provided, the device comprising: a storage module for storing N sub-logs of a log locally; a sending module for backing up the N sub-logs to a standby node; The first processing module is configured to mark the log as valid when it is determined that all the N sub-logs are stored in the standby node.

应理解,所述日志是根据一个原子写请求生成的,所述一个原子写请求包括N个子写,所述N个子日志中的每个子日志记录每个子写的信息,N为大于0的正整数。It should be understood that the log is generated according to an atomic write request, and the one atomic write request includes N sub-writes, each of the N sub-logs records the information of each sub-write, and N is a positive integer greater than 0 .

本申请实施例提供的数据写入装置,可以在数据备份的过程中通过日志机制保证一组写请求的原子性,避免了现有技术中通过文件系统语义锁来实现原子性,从而可以降低流程复杂性以及系统开销。The data writing device provided by the embodiments of the present application can ensure the atomicity of a group of write requests through a log mechanism during the data backup process, avoiding the implementation of atomicity through file system semantic locks in the prior art, thereby reducing the process flow complexity and system overhead.

结合第三方面,在第三方面的某些实现方式中,所述装置还包括:第二处理模块,用于在所述备节点中的所述N个子日志存储失败的情况下,将存储的所述N个子日志删除。With reference to the third aspect, in some implementations of the third aspect, the apparatus further includes: a second processing module, configured to store the stored N sub-logs in the case of failure to store the N sub-logs in the standby node. The N sub-logs are deleted.

结合第三方面,在第三方面的某些实现方式中,所述N个子日志携带相同的日志标识号ID,所述存储模块具体用于:所述主节点根据所述ID将所述N个子日志有序存储到所述主节点的日志存储容器中。With reference to the third aspect, in some implementations of the third aspect, the N sub-logs carry the same log identification number ID, and the storage module is specifically configured to: the master node stores the N sub-logs according to the IDs The logs are stored in the log storage container of the master node in an orderly manner.

结合第三方面,在第三方面的某些实现方式中,所述第一处理模块具体用于:接收通知消息,所述通知消息用于指示所述N个子日志全部存储到所述备节点中;将所述日志标记为有效。With reference to the third aspect, in some implementations of the third aspect, the first processing module is specifically configured to: receive a notification message, where the notification message is used to instruct all the N sub-logs to be stored in the standby node ; mark the log as valid.

需要说明的是,在第三方面所示的实体装置中,处理器可以通过调用存储器中的计算机程序,实现各个模块执行的步骤。例如,可以由处理器调用缓存中存储的计算机指令来执行各个模块(存储模块、发送模块、第一处理模块、第二处理模块)所需要执行的步骤。It should be noted that, in the physical device shown in the third aspect, the processor may implement the steps executed by each module by calling the computer program in the memory. For example, the computer instructions stored in the cache may be invoked by the processor to execute the steps required by each module (storage module, sending module, first processing module, and second processing module).

第四方面,提供了一种数据写入的装置,该装置包括:存储模块,用于将主节点备份的日志的N个子日志存储到所述备节点中;处理模块,用于在将所述N个子日志全部存储到所述备节点时,将所述日志标记为有效;发送模块,用于备节点向所述主节点通知所述N个子日志全部存储到所述备节点中。In a fourth aspect, a data writing device is provided, the device comprising: a storage module for storing N sub-logs of a log backed up by a master node in the standby node; a processing module for storing the log in the standby node When all N sub-logs are stored in the standby node, the log is marked as valid; the sending module is used for the standby node to notify the master node that all the N sub-logs are stored in the standby node.

应理解,所述日志是根据一个原子写请求生成的,所述一个原子写请求包括N个子写,所述N个子日志中的每个子日志记录每个子写的信息,N为大于0的正整数。It should be understood that the log is generated according to an atomic write request, and the one atomic write request includes N sub-writes, each of the N sub-logs records the information of each sub-write, and N is a positive integer greater than 0 .

本申请实施例提供的数据写入装置可以在数据备份的过程中,通过日志机制保证一组写请求的原子性,避免了现有技术中通过文件系统语义锁来实现原子性,从而可以降低流程复杂性以及系统开销。The data writing device provided by the embodiment of the present application can ensure the atomicity of a group of write requests through a log mechanism during the data backup process, avoiding the implementation of atomicity through the semantic lock of the file system in the prior art, thereby reducing the process flow complexity and system overhead.

结合第四方面,在第四方面的某些实现方式中,所述N个子日志携带相同的日志标识号ID,所述存储模块具体用于:根据所述ID将所述N个子日志有序存储到所述备节点的日志存储容器中。With reference to the fourth aspect, in some implementations of the fourth aspect, the N sub-logs carry the same log identification number ID, and the storage module is specifically configured to: store the N sub-logs in an orderly manner according to the IDs into the log storage container of the standby node.

结合第四方面,在第四方面的某些实现方式中,所述发送模块具体用于:向所述主节点发送通知消息,所述通知消息用于指示所述N个子日志全部存储到所述备节点的日志存储容器中。With reference to the fourth aspect, in some implementations of the fourth aspect, the sending module is specifically configured to: send a notification message to the master node, where the notification message is used to instruct the N sub-logs to be stored in the in the log storage container of the standby node.

需要说明的是,在第四方面所示的实体装置中,处理器可以通过调用存储器中的计算机程序,实现各个模块执行的步骤。例如,可以由处理器调用缓存中存储的计算机指令来执行各个模块(存储模块、处理模块、发送模块)所需要执行的步骤。It should be noted that, in the physical device shown in the fourth aspect, the processor may implement the steps executed by each module by calling the computer program in the memory. For example, the computer instructions stored in the cache can be invoked by the processor to execute the steps required by each module (storage module, processing module, and sending module).

第五方面,提供了一种主节点,其特征在于,包括输入输出接口、处理器和存储器,其中所述处理器用于控制所述输入输出接口收发信息,所述存储器用于存储计算机程序,所述处理器用于从存储器中调用并运行该计算机程序,使得所述主节点执行第一方面或第一方面任意一种可能的实现方式中所述的方法。In a fifth aspect, a master node is provided, which is characterized by comprising an input and output interface, a processor and a memory, wherein the processor is used to control the input and output interface to send and receive information, the memory is used to store a computer program, and the The processor is configured to call and run the computer program from the memory, so that the master node executes the method described in the first aspect or any possible implementation manner of the first aspect.

可选地,该处理器可以是通用处理器,可以通过硬件来实现也可以通过软件来实现。当通过硬件实现时,该处理器可以是逻辑电路、集成电路等;当通过软件来实现时,该处理器可以是一个通用处理器,通过读取存储器中存储的软件代码来实现,该存储器可以集成在处理器中,可以位于该处理器之外,独立存在。Optionally, the processor may be a general-purpose processor, which may be implemented by hardware or software. When implemented by hardware, the processor can be a logic circuit, an integrated circuit, etc.; when implemented by software, the processor can be a general-purpose processor, implemented by reading software codes stored in a memory, which can Integrated in the processor, can be located outside the processor, independent existence.

第六方面,提供了一种备节点,其特征在于,包括输入输出接口、处理器和存储器,其中所述处理器用于控制所述输入输出接口收发信息,所述存储器用于存储计算机程序,所述处理器用于从存储器中调用并运行该计算机程序,使得所述主节点执行第二方面或第二方面任意一种可能的实现方式中所述的方法。A sixth aspect provides a standby node, characterized in that it includes an input and output interface, a processor and a memory, wherein the processor is used to control the input and output interface to send and receive information, the memory is used to store a computer program, and the The processor is configured to call and run the computer program from the memory, so that the master node executes the method described in the second aspect or any possible implementation manner of the second aspect.

可选地,该处理器可以是通用处理器,可以通过硬件来实现也可以通过软件来实现。当通过硬件实现时,该处理器可以是逻辑电路、集成电路等;当通过软件来实现时,该处理器可以是一个通用处理器,通过读取存储器中存储的软件代码来实现,该存储器可以集成在处理器中,可以位于该处理器之外,独立存在。Optionally, the processor may be a general-purpose processor, which may be implemented by hardware or software. When implemented by hardware, the processor can be a logic circuit, an integrated circuit, etc.; when implemented by software, the processor can be a general-purpose processor, implemented by reading software codes stored in a memory, which can Integrated in the processor, can be located outside the processor, independent existence.

第七方面,提供了一种计算机程序产品,所述计算机程序产品包括:计算机程序代码,当所述计算机程序代码在计算机上运行时,使得计算机执行上述各方面中的方法。In a seventh aspect, a computer program product is provided, the computer program product comprising: computer program code, which, when the computer program code is run on a computer, causes the computer to perform the methods in the above aspects.

第八方面,提供了一种计算机可读介质,所述计算机可读介质存储有程序代码,当所述计算机程序代码在计算机上运行时,使得计算机执行上述各方面中的方法。In an eighth aspect, a computer-readable medium is provided, and the computer-readable medium stores program codes, which, when executed on a computer, cause the computer to execute the methods in the above-mentioned aspects.

第九方面,提供了一种系统,包括前述的主节点和备节点。In a ninth aspect, a system is provided, including the aforementioned master node and a backup node.

附图说明Description of drawings

图1是本申请实施例适用的场景的示意性框图。FIG. 1 is a schematic block diagram of a scenario to which this embodiment of the present application is applicable.

图2是本申请实施例提供的一种数据写入方法的示意性流程图。FIG. 2 is a schematic flowchart of a data writing method provided by an embodiment of the present application.

图3是本申请实施例提供的一种数据写入系统的示意性结构图。FIG. 3 is a schematic structural diagram of a data writing system provided by an embodiment of the present application.

图4是本申请另一实施例提供的一种数据写入系统的示意性结构图。FIG. 4 is a schematic structural diagram of a data writing system provided by another embodiment of the present application.

图5是本申请另一实施例提供的一种数据写入系统的示意性结构图。FIG. 5 is a schematic structural diagram of a data writing system provided by another embodiment of the present application.

图6是本申请另一实施例提供的一种数据写入方法的示意性流程图。FIG. 6 is a schematic flowchart of a data writing method provided by another embodiment of the present application.

图7是本申请另一实施例提供的一种数据写入系统的示意性结构图。FIG. 7 is a schematic structural diagram of a data writing system provided by another embodiment of the present application.

图8是本申请实施例提供的一种数据写入装置800的示意性框图。FIG. 8 is a schematic block diagram of a data writing apparatus 800 provided by an embodiment of the present application.

图9是本申请实施例提供的一种数据写入装置900的示意性框图。FIG. 9 is a schematic block diagram of a data writing apparatus 900 provided by an embodiment of the present application.

图10是本申请实施例提供的一种主节点1000的示意性框图。FIG. 10 is a schematic block diagram of a master node 1000 provided by an embodiment of the present application.

图11是本申请实施例提供的一种备节点1100的示意性框图。FIG. 11 is a schematic block diagram of a standby node 1100 provided by an embodiment of the present application.

具体实施方式Detailed ways

下面将结合附图,对本申请中的技术方案进行描述。The technical solutions in the present application will be described below with reference to the accompanying drawings.

在分布式存储系统中,系统可用性是重要指标之一,需要保证在机器发生故障时,系统的可用性不受影响。为了保证系统可用性,数据需要进行备份(也就是说,需要保存存储数据的多个副本,该多副本的数据需要保持一致),在机器发生故障引起一个副本失效时,其他副本仍然可以提供服务。In a distributed storage system, system availability is one of the important indicators, and it is necessary to ensure that the availability of the system is not affected when a machine fails. In order to ensure system availability, data needs to be backed up (that is, multiple copies of stored data need to be saved, and the data of the multiple copies needs to be consistent), and when a machine failure causes one copy to fail, other copies can still provide services.

图1是本申请实施例适用的场景的示意性框图。图1所示的场景可以包括至少两个节点。一般将可以复制的源节点称之为主节点110,而复制的目的节点(一个或多个)可以称之为备节点120。FIG. 1 is a schematic block diagram of a scenario to which this embodiment of the present application is applicable. The scene shown in FIG. 1 may include at least two nodes. The source node that can be replicated is generally referred to as the primary node 110 , and the replicated destination node(s) may be referred to as the standby node 120 .

主节点110,是整个文件系统的管理节点,可以接收用户的操作请求。作为一个示例,主节点110可以在接收用于的写请求之后,可以将数据写入本地,并且可以将写入的数据备份至备节点120上。主节点110也可以称为主副本。The master node 110 is the management node of the entire file system, and can receive operation requests from users. As an example, after receiving the write request for the primary node 110 , the data can be written locally, and the written data can be backed up on the standby node 120 . The master node 110 may also be referred to as a master replica.

备节点120,作为基于磁盘数据的容灾备份,使得在主机进行定期的计划维护时或主机发生故障(计划外)时,备节点120能够迅速的接管应用和应用数据,从而使得用户的访问不受计划或计划外停机的干扰。作为一个示例,备节点120可以将主节点110写入的数据进行数据备份。备节点120也可以称为副副本。The standby node 120, as a disaster recovery backup based on disk data, enables the standby node 120 to quickly take over applications and application data when the host performs regular planned maintenance or when the host fails (unplanned), so that user access is not possible. Disrupted by planned or unplanned downtime. As an example, the standby node 120 may back up the data written by the primary node 110 . The standby node 120 may also be referred to as a secondary replica.

文件系统作为操作系统中管理和存储文件信息的软件机构,主要负责为用户建立文件,存入、读出、转储文件,控制文件的存取等。As a software organization that manages and stores file information in the operating system, the file system is mainly responsible for creating files for users, storing, reading, and dumping files, and controlling access to files.

例如,网络附属存储(network attached storage,NAS)可以为连接到计算机网络的计算机数据存储装置,因此也称为“网络存储器”。NAS是一种专用数据存储服务器,以数据为中心,将存储设备与服务器彻底分离,集中管理数据。NAS作为一种在存储系统中大量使用的业务形式,主要通过为存储设备提供高效稳定的文件系统。NAS设备通常可配合典型的文件系统共享协议,共享给主机来为多种行业提供存储服务。For example, network attached storage (NAS) may be a computer data storage device connected to a computer network, and is therefore also referred to as "network storage." NAS is a dedicated data storage server, which is data-centric, completely separates the storage device from the server, and centrally manages data. As a business form that is widely used in storage systems, NAS mainly provides an efficient and stable file system for storage devices. NAS devices can usually be used with typical file system sharing protocols to be shared with hosts to provide storage services for a variety of industries.

在对于提供文件系统的服务中,许多场景(例如,涉及2个节点以上的数据存储系统)下需要保证一组写请求全部成功或全部失败,可以将该组写请求称为一个原子写。例如,数据库系统为了保证即使在遭遇了掉电的非预期时间内,每次更新是全部成功或全部失败,存储系统的数据写请求需要为原子写,需要符合原子性的要求。In many scenarios (for example, a data storage system involving more than 2 nodes) for providing a file system service, it is necessary to ensure that a group of write requests all succeed or all fail. This group of write requests can be called an atomic write. For example, in order to ensure that each update is all successful or all failed even in the unexpected time of power failure, the data write request of the storage system needs to be atomic, and it needs to meet the requirements of atomicity.

应理解,一个原子写也可以称为一组写请求具有原子性或该组写请求为一个原子操作(即,该组写请求为不可中断的一个或一个系列的操作)。It should be understood that an atomic write may also be referred to as a set of write requests being atomic or the set of write requests being an atomic operation (ie, the set of write requests being an uninterruptible one or a series of operations).

现有技术中,通过文件系统的语义锁保证一组写请求的原子性。但是,增加的语义锁会导致系统流程复杂同时增加了系统开销。In the prior art, the atomicity of a set of write requests is guaranteed by the semantic lock of the file system. However, the increased semantic lock will cause the system process to be complicated and increase the system overhead.

在数据备份的过程中,为了保证2个以上节点间写请求原子性的同时,还可以降低系统流程复杂性及系统开销,本申请实施例提供了一种数据写入的方法,可以避免现有技术中通过文件系统语义锁来实现原子性所造成的复杂的流程以及大的系统开销。In the process of data backup, in order to ensure the atomicity of write requests between two or more nodes, and also reduce the complexity of the system process and the system overhead, the embodiment of the present application provides a data writing method, which can avoid the existing In the technology, the complex process and large system overhead caused by atomicity are realized through the semantic lock of the file system.

下文基于图1所示的架构,结合图2详细说明本申请实施例的数据写入方法。图2是本申请实施例提供的一种数据写入方法的示意性流程图。图2所示的方法可以包括:步骤210-230。下面分别对步骤210-230进行详细描述。Based on the architecture shown in FIG. 1 , the data writing method according to the embodiment of the present application will be described in detail below with reference to FIG. 2 . FIG. 2 is a schematic flowchart of a data writing method provided by an embodiment of the present application. The method shown in FIG. 2 may include steps 210-230. Steps 210-230 will be described in detail below, respectively.

在步骤210中,主节点将日志的N个子日志存储到本地。In step 210, the master node stores the N sub-logs of the log locally.

本申请实施例中,一组写请求可以包括N个子写,N为大于0的正整数。为了保证该一组写请求全部成功或全部失败(也就是说,该一组写请求为不可被中断的一个或一个系列操作),该组写请求可以被称为一个原子写,该组写请求也可以称为具有原子性。In this embodiment of the present application, a group of write requests may include N sub-writes, where N is a positive integer greater than 0. In order to ensure that the set of write requests all succeed or fail (that is, the set of write requests is one or a series of operations that cannot be interrupted), the set of write requests can be called an atomic write, and the set of write requests can be called an atomic write. It can also be called atomic.

一个原子写中的一连串子写可以生成一条日志(log),一个原子写中的N个子写可以生成N条子日志(sublog)。其中,子日志可以记录子写的信息(也就是说,一个子写可以对应一条子日志),记录的信息可以包括但不限于:存放的地址(起始地址),写入的数据、写入数据的长度等。A series of sub-writes in an atomic write can generate a log (log), and N sub-writes in an atomic write can generate N sublogs (sublogs). Among them, the sub-log can record the information of the sub-write (that is, a sub-write can correspond to a sub-log), and the recorded information can include but is not limited to: the stored address (starting address), the written data, the written length of data, etc.

主节点可以将生成的N条子日志存储到本地,作为一个示例,主节点可以将N条子日志按照记录的起始地址存储到对应的日志存储容器中,例如,主节点可以将N条子日志按照记录的起始地址存储到对应的chunk中。下面会结合图3对一个原子写请求的写入过程进行详细描述,此处不再赘述。The master node can store the generated N sub-logs locally. As an example, the master node can store the N sub-logs in the corresponding log storage container according to the starting address of the record. For example, the master node can store the N sub-logs according to the record. The starting address is stored in the corresponding chunk. The writing process of an atomic write request will be described in detail below with reference to FIG. 3 , which will not be repeated here.

在步骤220中,主节点将N个子日志备份到备节点中。In step 220, the master node backs up the N sublogs to the standby node.

本申请实施例中,主节点可以将生成的N条子日志备份到备节点中。备节点可以将主节点写入的N条子日志存储到备节点中,作为一个示例,备节点可以将N条子日志按照记录的起始地址存储到对应的日志存储容器中,例如,备节点可以将N条子日志按照记录的起始地址存储到对应的chunk中。下面会结合图3对一个原子写请求的写入过程进行详细描述,此处不再赘述。In this embodiment of the present application, the master node may back up the generated N sub-logs to the standby node. The standby node can store the N sub-logs written by the primary node in the standby node. As an example, the standby node can store the N sub-logs in the corresponding log storage container according to the starting address of the record. For example, the standby node can store the N sub-logs in the corresponding log storage container. N sublogs are stored in the corresponding chunk according to the starting address of the record. The writing process of an atomic write request will be described in detail below with reference to FIG. 3 , which will not be repeated here.

需要说明的是,备节点中的chunk地址和主节点中的地址相同,备节点可以将N条子日志按照记录的起始地址存储到对应的chunk中与主节点中的操作流程一样。It should be noted that the address of the chunk in the standby node is the same as the address in the master node, and the slave node can store N sublogs in the corresponding chunk according to the recorded starting address, which is the same as the operation process in the master node.

在步骤230中,主节点在确定N个子日志全部存储到所述备节点的情况下,将日志标记为有效。In step 230, the master node marks the log as valid when it is determined that all the N sub-logs are stored in the standby node.

本申请实施例中主节点可以在将N条子日志全部存储到本地之后,可以确定备节点是否将N条子日志全部存储到对应的日志存储容器。如果主节点可以确定备节点将N条子日志全部存储到对应的日志存储容器,该主节点可以在将N条子日志全部存储到本地之后,可以将日志标记为有效。作为一个示例,主节点可以在日志中增加一个标记位,主节点可以修改该标记位的状态,可以将该标记位置为有效。In the embodiment of the present application, after storing all N sub-logs locally, the master node may determine whether the standby node stores all N sub-logs in the corresponding log storage container. If the master node can determine that the standby node stores all N sublogs in the corresponding log storage container, the master node can mark the log as valid after storing all the N sublogs locally. As an example, the master node may add a flag bit in the log, the master node may modify the state of the flag bit, and the flag bit may be set as valid.

应理解,本申请实施例中主节点在将日志标记为有效,可以表示该日志的N个子日志已经存储至本地,并且该N个子日志也已经备份至备节点中,一个原子写请求可以认为已经全部写入主节点和备节点,可以保证节点间一组写请求的原子性。It should be understood that in the embodiment of the present application, when the master node marks the log as valid, it may indicate that the N sub-logs of the log have been stored locally, and the N sub-logs have also been backed up to the standby node, and an atomic write request can be considered to have been All writes to the primary and secondary nodes can ensure the atomicity of a set of write requests between nodes.

本申请实施例中,在数据备份过程中,通过日志机制实现主节点和备节点间写请求的原子性,可以避免使用现有技术中的文件系统语义锁,从而可以降低系统流程复杂性及系统开销。In the embodiment of the present application, in the data backup process, the atomicity of the write request between the primary node and the standby node is realized through the log mechanism, which can avoid using the semantic lock of the file system in the prior art, thereby reducing the complexity of the system process and the system overhead.

下面结合具体的例子,更加详细地描述本申请实施例中的原子写请求的写入过程的具体实现方式。应注意,图3的例子仅仅是为了帮助本领域技术人员理解本申请实施例,而非要将申请实施例限制于所示例的具体数值或具体场景。本领域技术人员根据所给出的图3的例子所给出的例子,显然可以进行各种等价的修改或变化,这样的修改和变化也落入本申请实施例的范围内。The specific implementation of the writing process of the atomic write request in the embodiment of the present application is described in more detail below with reference to specific examples. It should be noted that the example in FIG. 3 is only for helping those skilled in the art to understand the embodiments of the present application, and is not intended to limit the embodiments of the present application to specific numerical values or specific scenarios exemplified. Those skilled in the art can obviously make various equivalent modifications or changes according to the example given in the example of FIG. 3 , and such modifications and changes also fall within the scope of the embodiments of the present application.

图3是本申请实施例提供的一种数据写入系统的示意性结构图。图3所示的系统可以包括组块(chunk)310、组块(chunk)320、组块(chunk)330。FIG. 3 is a schematic structural diagram of a data writing system provided by an embodiment of the present application. The system shown in FIG. 3 may include chunks 310 , chunks 320 , and chunks 330 .

chunk 310中以链表的形式存储的sublog可以有:子日志(sublog)312、子日志(sublog)314、子日志(sublog)316。The sublogs stored in the chunk 310 in the form of a linked list may include: a sublog (sublog) 312 , a sublog (sublog) 314 , and a sublog (sublog) 316 .

chunk 320中以链表的形式存储的sublog可以有:子日志(sublog)322、子日志(sublog)324、子日志(sublog)326。The sublogs stored in the chunk 320 in the form of a linked list may include: a sublog (sublog) 322 , a sublog (sublog) 324 , and a sublog (sublog) 326 .

chunk 330中以链表的形式存储的sublog可以有:子日志(sublog)332、子日志(sublog)334、子日志(sublog)336。The sublogs stored in the chunk 330 in the form of a linked list may include: a sublog (sublog) 332 , a sublog (sublog) 334 , and a sublog (sublog) 336 .

应理解,本申请实施例中一个原子写请求中的一连串子写可以生成一条日志(log),一个原子写中的N个子写可以生成N条子日志(sublog),一条子日志可以记录一个子写的地址、写入的数据、写入数据的长度等。也就是说,一个原子写请求可以对应一条log,一个原子写中的每一个子写对应一条sublog。It should be understood that in the embodiment of the present application, a series of sub-writes in an atomic write request can generate a log (log), N sub-writes in one atomic write can generate N sub-logs (sublogs), and a sub-log can record one sub-write address, data to be written, length of data to be written, etc. That is to say, an atomic write request can correspond to a log, and each sub-write in an atomic write corresponds to a sublog.

本申请实施例中chunk可以是一个逻辑上划分的一块内存,是一个基本的数据索引单元,可以用于存储sublog。节点可以根据sublog中记录的子写的起始地址,将该sublog以链表的形式存储在对应地址的chunk内部。In this embodiment of the present application, a chunk may be a logically divided piece of memory, a basic data index unit, and may be used to store sublogs. The node can store the sublog in the chunk of the corresponding address in the form of a linked list according to the starting address of the sub-write recorded in the sublog.

写请求生成的sublog可以根据其记录的子写的地址找到与之对应的chunk,并可以加入到该chunk上的sublog链表上。作为一个示例,读请求可以通过sublog中记录的地址和偏移,可以找到与之对应的chunk。作为一个示例,写请求也可以根据sublog中记录的地址和偏移,可以找到与之对应的chunk。The sublog generated by the write request can find the corresponding chunk according to the address of its recorded sub-write, and can add it to the sublog list on the chunk. As an example, a read request can find the corresponding chunk through the address and offset recorded in the sublog. As an example, the write request can also find the corresponding chunk according to the address and offset recorded in the sublog.

应理解,链表可以是一种物理存储单元上非连续、非顺序的存储结构,数据元素的逻辑顺序可以是通过链表中的指针连接依次实现的。链表可以由一系列节点组成,链表可以允许插入或移除表上任意位置的节点。作为一个示例,chunk链表上的多个sublog可以认为是chunk链表上的一系列节点,chunk链表上的可以插入或移除sublog。It should be understood that a linked list may be a non-consecutive and non-sequential storage structure on a physical storage unit, and the logical order of data elements may be sequentially implemented by connecting pointers in the linked list. A linked list can consist of a series of nodes, and a linked list can allow insertion or removal of nodes anywhere on the list. As an example, multiple sublogs on the chunk linked list can be considered as a series of nodes on the chunk linked list, and sublogs on the chunk linked list can be inserted or removed.

下面以写请求为例进行详细说明。The following takes the write request as an example for detailed description.

参见图3,一组写请求生成的log 311可以包括sublog 316、sublog 324、sublog334,其中,sublog 316、sublog 324、sublog 334可以以链表的形式组织在log 311内部。Referring to FIG. 3 , a log 311 generated by a group of write requests may include sublog 316 , sublog 324 , and sublog 334 , wherein sublog 316 , sublog 324 , and sublog 334 may be organized within log 311 in the form of a linked list.

sublog可以根据其记录的地址和偏移,可以找到与之对应的chunk。例如,sublog316可以加入到chunk 310的链表上,sublog 324可以加入到chunk 320的链表上,sublog334可以加入到chunk 320的链表上。The sublog can find the corresponding chunk according to its recorded address and offset. For example, sublog316 can be added to the linked list of chunk 310, sublog 324 can be added to the linked list of chunk 320, and sublog334 can be added to the linked list of chunk 320.

需要说明的是,图中的实线框可以用于表示一条log中包括的多个sublog已经全部存储至相对应的chunk中,该多个sublog已经标记为有效(一组写请求已经全部写入内存中,可以保证该组写请求的原子性),可以被读请求读取到。例如,sublog 312、sublog 314、sublog 322、sublog 332已经全部写入相对应的chunk中,可以被读请求读取到。图中的虚线框可以用于表示一条log中包括的多个sublog还没有全部存储至相对应的chunk中,该log还未标记为有效,该log上的多个sublog还不能被读请求读取到。例如,log 311中包括的sublog 316、sublog 324、sublog 334,以及sublog 332还未标记为有效,还不能被读请求读取到。It should be noted that the solid line box in the figure can be used to indicate that multiple sublogs included in a log have all been stored in the corresponding chunks, and the multiple sublogs have been marked as valid (a group of write requests have been written in all In memory, the atomicity of this group of write requests can be guaranteed) and can be read by read requests. For example, sublog 312, sublog 314, sublog 322, and sublog 332 have all been written into the corresponding chunks and can be read by read requests. The dotted box in the figure can be used to indicate that multiple sublogs included in a log have not been stored in the corresponding chunk, the log has not been marked as valid, and multiple sublogs on the log cannot be read by read requests. arrive. For example, sublog 316, sublog 324, sublog 334, and sublog 332 included in log 311 have not been marked as valid and cannot be read by read requests.

应理解,chunk 320链表上的sublog 322可以用于表示在写入log 311之前,已经以链表的形式存储到chunk中,sublog 326可以用于表示在写入log 311的同时,还可以有其他的写数据存储到chunk 320链表上。It should be understood that sublog 322 on the linked list of chunk 320 can be used to indicate that before log 311 is written, it has been stored in the chunk in the form of a linked list, and sublog 326 can be used to indicate that while log 311 is written, there may be other Write data is stored on the chunk 320 linked list.

节点可以在log 311中的sublog 316、sublog 324、sublog 334全部存储到与之对应的chunk链表上之后,将log 311标记为有效。例如,可以在log 311中增加标记位,可以在log 311中的所有sublog全部存储到对应的chunk链表上之后,可以将该标记位置为有效,log 311中的所有sublog可以被读请求读取到。具体可参见图4中所示的系统结构图,图4中的log 311已经被标记为有效(一组写请求已经全部写入内存中,可以保证该组写请求的原子性),log 311上的sublog 316、sublog 324、sublog 334可以被读请求读取到。The node can mark log 311 as valid after all sublog 316, sublog 324, and sublog 334 in log 311 are stored in the corresponding chunk linked list. For example, a marker bit can be added to log 311. After all sublogs in log 311 are stored in the corresponding chunk linked list, the marker bit can be set as valid, and all sublogs in log 311 can be read by a read request. . For details, please refer to the system structure diagram shown in FIG. 4. The log 311 in FIG. 4 has been marked as valid (a group of write requests has been written into the memory, and the atomicity of the group of write requests can be guaranteed). The sublog 316, sublog 324, and sublog 334 can be read by the read request.

可选地,在一个log被标记为有效(也就是log上的所有sublog全部存储到对应的chunk链表上)之后,可以认为一个原子写请求操作已经完成。该log占用的内存空间就可以释放,释放的内存空间可以被循环利用。具体可参见图5中所示的系统结构图,相比较图4所示的系统结构图而言,图5中log 311上的sublog 316、sublog 324、sublog 334均已经全部存储至相对应的chunk中,log 311所占用的内存空间可以被释放。Optionally, after a log is marked as valid (that is, all sublogs on the log are stored in the corresponding chunk linked list), an atomic write request operation can be considered to have been completed. The memory space occupied by the log can be released, and the released memory space can be recycled. For details, please refer to the system structure diagram shown in FIG. 5. Compared with the system structure diagram shown in FIG. 4, the sublog 316, sublog 324, and sublog 334 on the log 311 in FIG. 5 have all been stored in the corresponding chunk. , the memory space occupied by log 311 can be released.

应理解,如果一个原子写请求的log被释放,也可以认为该log上的所有sublog全部存储到对应的chunk链表上,一个原子写请求已经完成。例如,如果指向log的指针为空,可以认为一个原子写请求已经完成,可以被读请求读到。It should be understood that if the log of an atomic write request is released, it can also be considered that all sublogs on the log are stored in the corresponding chunk linked list, and an atomic write request has been completed. For example, if the pointer to log is null, an atomic write request can be considered complete and can be read by a read request.

本申请实施例中,可以通过日志和子日志的机制实现流程上的原子写,可以保证一组写请求的原子性,可以避免现有技术中通过文件系统语义锁来实现一组写请求的原子性,从而可以降低流程复杂性以及系统开销。In the embodiment of the present application, the atomic write in the process can be realized through the mechanism of the log and the sub-log, the atomicity of a group of write requests can be guaranteed, and the atomicity of a group of write requests can be avoided in the prior art by using a file system semantic lock , which can reduce process complexity and system overhead.

可选地,在一些实施例中,在数据备份过程中,备节点作为主节点的数据备份,备节点写入的数据顺序需要按照主节点的顺序写入,也就是说,备节点写入的数据和主节点写入的数据的顺序需要保持一致。作为一个示例,本申请实施例可以对每一个log生成一个身份标识号(identity,ID),log上面的多个sublog也可以具有相同的log ID。本节点以及备节点可以按照log ID将sublog挂入相对应的chunk中,chunk中的sublog链表中的sublog可以按照log ID有序排列。Optionally, in some embodiments, in the data backup process, the backup node serves as the data backup of the master node, and the data written by the backup node needs to be written in the order of the master node, that is, the data written by the backup node is The order of data and data written by the master node needs to be consistent. As an example, this embodiment of the present application may generate an identity number (identity, ID) for each log, and multiple sublogs on the log may also have the same log ID. The local node and the standby node can attach sublogs to the corresponding chunks according to their log IDs, and the sublogs in the sublog linked list in the chunks can be arranged in order according to their log IDs.

下面结合具体的例子,更加详细地描述本申请实施例中的主节点和备节点间保证一组写请求的原子性的具体实现方式。应注意,图6的例子仅仅是为了帮助本领域技术人员理解本申请实施例,而非要将申请实施例限制于所示例的具体数值或具体场景。本领域技术人员根据所给出的图6的例子所给出的例子,显然可以进行各种等价的修改或变化,这样的修改和变化也落入本申请实施例的范围内。The specific implementation manner of ensuring the atomicity of a group of write requests between the primary node and the backup node in the embodiment of the present application is described in more detail below with reference to specific examples. It should be noted that the example in FIG. 6 is only for helping those skilled in the art to understand the embodiments of the present application, and is not intended to limit the embodiments of the present application to specific numerical values or specific scenarios exemplified. Those skilled in the art can obviously make various equivalent modifications or changes according to the example given in the example of FIG. 6 , and such modifications and changes also fall within the scope of the embodiments of the present application.

存储系统中主节点和备节点的原子写流程可以参见图6,应理解,图6中的本端对应于上文中的主节点,对端对应于上文中的备节点。图6的方法可以包括步骤610-670,下面对这些步骤进行详细描述。Figure 6 shows the atomic write process of the primary node and the standby node in the storage system. It should be understood that the local end in Figure 6 corresponds to the primary node above, and the opposite end corresponds to the secondary node above. The method of FIG. 6 may include steps 610-670, which are described in detail below.

步骤610,本端写输入/输出(input/output,I/O)。Step 610, the local end writes input/output (input/output, I/O).

本端(可以理解控制器)可以接收到操作系统的写I/O指令和需要写入的数据,本申请实施例中一组写请求中的一连串子写可以生成一条log,子写可以生成sublog,其中sublog中可以记录需要写入的数据、数据的长度以及该数据存放的地址。The local end (it can be understood that the controller) can receive the write I/O instruction of the operating system and the data to be written. In this embodiment of the present application, a series of sub-writes in a group of write requests can generate a log, and the sub-writes can generate a sublog , in which the data to be written, the length of the data and the address where the data is stored can be recorded in the sublog.

步骤620,本端生成日志(log)ID。Step 620, the local end generates a log (log) ID.

本端可以在接收到操作系统的写I/O指令、生成的一条log以及多条sublog之后,可以对该log生成一个log ID。Log的多条sublog可以具有和log相同的log ID,以便于对端在写入数据时可以按照本端的顺序写入,这样对端写入的数据可以和本端写入的数据一致。The local end can generate a log ID for the log after receiving the write I/O command from the operating system, a generated log, and multiple sublogs. Multiple sublogs of the log can have the same log ID as the log, so that the peer end can write data in the order of the local end when writing data, so that the data written by the peer end can be consistent with the data written by the local end.

步骤630,本端写本地。Step 630, the local end writes the local.

本端可以将接收到的多条sublog写入本地,例如,本端可以根据每条sublog的logID将sublog写入相对应的日志存储容器(例如,可以是chunk)中,chunk中的sublog链表可以按照log ID有序排列。本端写本地的处理流程请参照图3所描述的数据写入的方法,此处不再赘述。The local end can write the received multiple sublogs locally. For example, the local end can write the sublogs to the corresponding log storage container (for example, a chunk) according to the logID of each sublog. The sublog list in the chunk can be Sort by log ID. Please refer to the data writing method described in FIG. 3 for the processing flow of local writing, which will not be repeated here.

步骤640,对端写镜像。Step 640, write the mirror image to the opposite end.

对端(可以理解控制器)可以接收本端发送的待备份的多条sublog,该多条sublog可以携带log ID,对端可以根据每条sublog的log ID将sublog写入相对应的日志存储容器(例如,可以是chunk)中,chunk中的sublog链表可以按照log ID有序排列。The opposite end (it can be understood that the controller) can receive multiple sublogs to be backed up sent by the local end. The multiple sublogs can carry log IDs. The opposite end can write the sublogs to the corresponding log storage container according to the log ID of each sublog. (For example, it can be a chunk), the sublog linked list in the chunk can be ordered according to the log ID.

上述将sublog按照log ID写入对端的过程也可以称为写镜像,也就是将本端存储的多条sublog备份至对端中。对端写镜像的处理流程也请参照图3所描述的数据写入的方法,此处不再赘述。The above process of writing the sublog to the peer end according to the log ID can also be called mirroring, that is, backing up multiple sublogs stored on the local end to the peer end. Please refer to the data writing method described in FIG. 3 for the processing flow of the mirror image at the opposite end, which will not be repeated here.

需要说明的是,本端可以仅将待备份的多条sublog发送至对端,本端也可以将log以及log的多条sublog都发送至对端,本申请实施例对此不做具体限定。如果对端仅收到本端发送的多条sublog,对端可以生成对应的log。It should be noted that the local end may only send multiple sublogs to be backed up to the opposite end, and the local end may also send the log and multiple sublogs of the log to the opposite end, which is not specifically limited in this embodiment of the present application. If the peer end only receives multiple sublogs sent by the local end, the peer end can generate corresponding logs.

步骤650,对端置数据有效。Step 650, valid for terminal data.

当对端将接收的多条sublog全部按照log ID存储至相对应的chunk之后,对端可以将多条sublog的log标记位置为有效。具体的处理流程也请参照图3所描述的数据写入的方法,此处不再赘述。After the peer end stores all the received sublogs in the corresponding chunk according to the log ID, the peer end can mark the log positions of the multiple sublogs as valid. For the specific processing flow, please refer to the data writing method described in FIG. 3 , which will not be repeated here.

对端可以在将多条sublog存储至相对应的chunk之后,可以向本端发送通知消息,可以通知本端本次数据备份的结果。作为一个示例,如果对端将多条sublog全部存储至相对应的chunk,并将log的标记位置为有效之后,对端向本端发送的通知消息可以用于指示对端的一个原子写请求已经全部完成。作为另一个示例,如果对端由于资源或各种其他原因,写镜像的操作执行失败之后,对端向本端发送的通知消息可以用于指示对端写镜像失败。The peer end can send a notification message to the local end after storing multiple sublogs in the corresponding chunk, and can notify the local end of the result of this data backup. As an example, if the peer end stores all multiple sublogs in the corresponding chunk and sets the log's mark position to be valid, the notification message sent by the peer end to the local end can be used to indicate that an atomic write request of the peer end has been completed. Finish. As another example, if the mirror-writing operation fails at the opposite end due to resources or various other reasons, the notification message sent by the opposite end to the local end may be used to indicate the failure of the mirror-writing at the opposite end.

步骤660,本端置数据有效。In step 660, the local set data is valid.

本端可以在确定对端将多条sublog全部存储至相对应的chunk之后,本端可以将多条sublog的log标记位置为有效。具体的处理流程也请参照图3所描述的数据写入的方法,此处不再赘述。After the local end determines that the peer end stores all the multiple sublogs in the corresponding chunk, the local end can mark the log positions of the multiple sublogs as valid. For the specific processing flow, please refer to the data writing method described in FIG. 3 , which will not be repeated here.

步骤670,本端完成。Step 670, the local end completes.

本端在将原子写请求生成的log置为有效,可以用于表示该原子写请求已经在2个节点写入成功,可以被读请求读取到。The local end sets the log generated by the atomic write request to be valid, which can be used to indicate that the atomic write request has been successfully written on two nodes and can be read by the read request.

可选地,在一些实施例中,如果本端在确定对端完全执行完成后,未将log的标记位置为有效(该流程执行失败),可以认为本端出现异常。系统可以以对端的数据作为基准。可以将本端的数据全部失效后,再将对端的所有数据同步至本端。Optionally, in some embodiments, if the local end does not set the marked position of the log to be valid after determining that the opposite end is completely executed (the process fails to execute), it may be considered that the local end is abnormal. The system can use the peer data as a benchmark. After all the data on the local end is invalid, all the data on the opposite end can be synchronized to the local end.

可选地,在一些实施例中,如果对端由于资源或各种原因,使得对端的操作执行失败。本申请实施例可以采用回滚机制,可以将本端存储的log回滚掉,可以保障整个系统数据的原子性(一组写请求或者全部成功或者全部失败)。Optionally, in some embodiments, if the peer end fails to perform the operation due to resources or various reasons. The embodiment of the present application may adopt a rollback mechanism, which may roll back the log stored at the local end, and ensure the atomicity of the entire system data (either a set of write requests succeed or fail).

下面结合具体的例子,更加详细地描述本申请实施例中的回滚机制的具体实现方式。应注意,图7的例子仅仅是为了帮助本领域技术人员理解本申请实施例,而非要将申请实施例限制于所示例的具体数值或具体场景。本领域技术人员根据所给出的图7的例子所给出的例子,显然可以进行各种等价的修改或变化,这样的修改和变化也落入本申请实施例的范围内。The specific implementation of the rollback mechanism in the embodiment of the present application is described in more detail below with reference to specific examples. It should be noted that the example in FIG. 7 is only for helping those skilled in the art to understand the embodiments of the present application, and is not intended to limit the embodiments of the present application to specific numerical values or specific scenarios exemplified. Those skilled in the art can obviously make various equivalent modifications or changes according to the example given in the example of FIG. 7 , and such modifications and changes also fall within the scope of the embodiments of the present application.

如果存储系统需要回滚,本端根据需要回滚的log,通过该log内的sublog链表,本端可以确定与之相关的sublog,并且可以依次将sublog从所在的chunk链表上删除,来完成回滚操作。If the storage system needs to be rolled back, the local end can roll back the log as needed. Through the sublog linked list in the log, the local end can determine the sublog related to it, and can delete the sublog from the chunk linked list in turn to complete the rollback. roll operation.

本端回滚之前的系统可以参见图3,作为一个示例,如果对端将log311内的sublog存储失败,本端可以根据log311内的sublog链表,可以将sublog 316、sublog 324、sublog334从所在的chunk链表上删除,来完成回滚操作。See Figure 3 for the system before the local end rolls back. As an example, if the peer end fails to store the sublog in log311, the local end can save sublog 316, sublog 324, and sublog334 from the chunk where it is located according to the sublog linked list in log311. Delete on the linked list to complete the rollback operation.

本端回滚之后的系统可以参见图7,图7中写入的log311内的sublog已经全部从所在的chunk链表上删除。The system after the local end rolls back can be seen in Figure 7. The sublogs in log311 written in Figure 7 have all been deleted from the chunk list where they are located.

本申请实施例中,通过回滚机制保障节点间写请求的原子性,避免了现有技术中依赖重试来保障节点间写请求的原子性,提高了系统的可服务性。In the embodiment of the present application, the atomicity of the write request between nodes is guaranteed by the rollback mechanism, which avoids relying on retry to ensure the atomicity of the write request between the nodes in the prior art, and improves the serviceability of the system.

上文结合图1至图7,详细描述了本申请实施例提供的数据写入方法,下面将结合图8至图11,详细描述本申请的数据写入装置的实施例。应理解,方法实施例的描述与装置实施例的描述相互对应,因此,未详细描述的部分可以参见前面方法实施例。The data writing method provided by the embodiments of the present application is described in detail above with reference to FIGS. 1 to 7 , and the embodiments of the data writing apparatus of the present application will be described in detail below with reference to FIGS. 8 to 11 . It should be understood that the descriptions of the method embodiments correspond to the descriptions of the apparatus embodiments. Therefore, for the parts not described in detail, reference may be made to the foregoing method embodiments.

图8是本申请实施例提供的一种数据写入装置800的示意性框图。该数据写入装置800可以包括:FIG. 8 is a schematic block diagram of a data writing apparatus 800 provided by an embodiment of the present application. The data writing apparatus 800 may include:

存储模块810,用于将日志的N个子日志存储到本地;A storage module 810, configured to store the N sub-logs of the log locally;

发送模块820,用于将所述N个子日志备份到备节点中;A sending module 820, configured to back up the N sub-logs to the standby node;

第一处理模块830,用于在确定所述N个子日志全部存储到所述备节点的情况下,将所述日志标记为有效。The first processing module 830 is configured to mark the log as valid when it is determined that all the N sub-logs are stored in the standby node.

应理解,所述日志是根据一个原子写请求生成的,所述一个原子写请求包括N个子写,所述N个子日志中的每个子日志记录每个子写的信息,N为大于0的正整数It should be understood that the log is generated according to an atomic write request, and the one atomic write request includes N sub-writes, each of the N sub-logs records the information of each sub-write, and N is a positive integer greater than 0

可选地,在一些实施例中,该数据写入装置800还可以包括:Optionally, in some embodiments, the data writing apparatus 800 may further include:

第二处理模块840,用于在所述备节点中的所述N个子日志存储失败的情况下,将存储的所述N个子日志删除。The second processing module 840 is configured to delete the stored N sub-logs when the storage of the N sub-logs in the standby node fails.

可选地,在一些实施例中,所述N个子日志携带相同的日志标识号ID,所述存储模块810具体用于:所述主节点根据所述ID将所述N个子日志有序存储到所述主节点的日志存储容器中。Optionally, in some embodiments, the N sub-logs carry the same log identification number ID, and the storage module 810 is specifically configured to: the master node stores the N sub-logs in an orderly manner according to the ID. in the log storage container of the master node.

可选地,在一些实施例中,所述第一处理模块830具体用于:接收通知消息,所述通知消息用于指示所述N个子日志全部存储到所述备节点中;将所述日志标记为有效。Optionally, in some embodiments, the first processing module 830 is specifically configured to: receive a notification message, where the notification message is used to instruct all the N sub-logs to be stored in the standby node; marked as valid.

需要说明的是,在图8所示的实体装置800中,处理器可以通过调用存储器中的计算机程序,实现各个模块执行的步骤。例如,可以由处理器调用缓存中存储的计算机指令来执行各个模块(存储模块810、发送模块820、第一处理模块830、第二处理模块840)所需要执行的步骤。It should be noted that, in the physical device 800 shown in FIG. 8 , the processor may implement the steps executed by each module by calling the computer program in the memory. For example, the computer instructions stored in the cache may be invoked by the processor to execute the steps required by each module (the storage module 810, the sending module 820, the first processing module 830, and the second processing module 840).

图9是本申请实施例提供的一种数据写入装置900的示意性框图。该数据写入装置900可以包括:FIG. 9 is a schematic block diagram of a data writing apparatus 900 provided by an embodiment of the present application. The data writing device 900 may include:

存储模块910,用于将主节点备份的日志的N个子日志存储到所述备节点中;A storage module 910, configured to store the N sub-logs of the log backed up by the primary node in the standby node;

处理模块920,用于在将所述N个子日志全部存储到所述备节点时,将所述日志标记为有效;A processing module 920, configured to mark the log as valid when all the N sub-logs are stored in the standby node;

发送模块930,用于备节点向所述主节点通知所述N个子日志全部存储到所述备节点中。The sending module 930 is used for the standby node to notify the master node that all the N sub-logs are stored in the standby node.

应理解,所述日志是根据一个原子写请求生成的,所述一个原子写请求包括N个子写,所述N个子日志中的每个子日志记录每个子写的信息,N为大于0的正整数。It should be understood that the log is generated according to an atomic write request, and the one atomic write request includes N sub-writes, each of the N sub-logs records the information of each sub-write, and N is a positive integer greater than 0 .

可选地,在一些实施例中,所述N个子日志携带相同的日志标识号ID,所述存储模块910具体用于:根据所述ID将所述N个子日志有序存储到所述备节点的日志存储容器中。Optionally, in some embodiments, the N sub-logs carry the same log identification number ID, and the storage module 910 is specifically configured to: store the N sub-logs in an orderly manner on the standby node according to the IDs in the log storage container.

可选地,在一些实施例中,所述发送模块930具体用于:向所述主节点发送通知消息,所述通知消息用于指示所述N个子日志全部存储到所述备节点的日志存储容器中。Optionally, in some embodiments, the sending module 930 is specifically configured to: send a notification message to the master node, where the notification message is used to instruct all the N sub-logs to be stored in the log storage of the standby node in the container.

需要说明的是,在图9所示的实体装置900中,处理器可以通过调用存储器中的计算机程序,实现各个模块执行的步骤。例如,可以由处理器调用缓存中存储的计算机指令来执行各个模块(存储模块910、处理模块920、发送模块930)所需要执行的步骤。It should be noted that, in the physical device 900 shown in FIG. 9 , the processor can implement the steps executed by each module by calling the computer program in the memory. For example, the computer instructions stored in the cache may be invoked by the processor to execute the steps required by each module (the storage module 910, the processing module 920, and the sending module 930).

图10是本申请实施例提供的一种主节点1000的示意性框图。该主节点1000可以包括:存储器1001、处理1002、输入/输出接口1003。FIG. 10 is a schematic block diagram of a master node 1000 provided by an embodiment of the present application. The master node 1000 may include: memory 1001 , processing 1002 , and input/output interface 1003 .

其中,存储器1001、处理器1002和输入/输出接口1003通过内部连接通路相连,该存储器1001用于存储程序指令,该处理器1002用于执行该存储器1001存储的程序指令,以控制输入/输出接口1003接收输入的数据和信息,输出操作结果等数据。The memory 1001, the processor 1002 and the input/output interface 1003 are connected through an internal connection path, the memory 1001 is used for storing program instructions, and the processor 1002 is used for executing the program instructions stored in the memory 1001 to control the input/output interface 1003 receives input data and information, and outputs data such as operation results.

应理解,在本申请实施例中,该处理器1002可以采用中央处理单元(centralprocessingunit,CPU),该处理器还可以是其它通用处理器、数字信号处理器(digitalsignal processor,DSP)、专用集成电路(application specific integrated circuit,ASIC)、现成可编程门阵列(field programmable gate Array,FPGA)或者其它可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。或者该处理器1002采用一个或多个集成电路,用于执行相关程序,以实现本申请实施例所提供的技术方案。It should be understood that, in this embodiment of the present application, the processor 1002 may adopt a central processing unit (central processing unit, CPU), and the processor may also be other general-purpose processors, digital signal processors (digital signal processors, DSP), application-specific integrated circuits (application specific integrated circuit, ASIC), off-the-shelf programmable gate array (field programmable gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, and the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. Alternatively, the processor 1002 uses one or more integrated circuits to execute related programs to implement the technical solutions provided by the embodiments of the present application.

该存储器1001可以包括只读存储器和随机存取存储器,并向处理器1002提供指令和数据。处理器1002的一部分还可以包括非易失性随机存取存储器。例如,处理器1002还可以存储设备类型的信息。The memory 1001 may include read only memory and random access memory, and provides instructions and data to the processor 1002 . A portion of the processor 1002 may also include non-volatile random access memory. For example, the processor 1002 may also store device type information.

在实现过程中,上述方法的各步骤可以通过处理器1002中的硬件的集成逻辑电路或者软件形式的指令完成。结合本申请实施例所公开的方法可以直接体现为硬件处理器执行完成,或者用处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器1001,处理器1002读取存储器1001中的信息,结合其硬件完成上述方法的步骤。为避免重复,这里不再详细描述。In the implementation process, each step of the above-mentioned method can be completed by an integrated logic circuit of hardware in the processor 1002 or an instruction in the form of software. The methods disclosed in conjunction with the embodiments of the present application may be directly embodied as executed by a hardware processor, or executed by a combination of hardware and software modules in the processor. The software modules may be located in random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, registers and other storage media mature in the art. The storage medium is located in the memory 1001, and the processor 1002 reads the information in the memory 1001, and completes the steps of the above method in combination with its hardware. To avoid repetition, detailed description is omitted here.

应理解,根据本申请实施例的主节点1000可对应于本申请实施例中的装置800,并可以用于执行本申请实施例图2-图7中的各个方法的相应流程,并且主节点1000中的各个模块的上述和其它操作和/或功能分别为了实现本申请实施例图2-图7中的各个方法的相应流程,为了简洁,在此不再赘述。It should be understood that the master node 1000 according to the embodiment of the present application may correspond to the apparatus 800 in the embodiment of the present application, and may be used to execute the corresponding processes of each method in FIG. 2 to FIG. 7 in the embodiment of the present application, and the master node 1000 The above-mentioned and other operations and/or functions of each module in FIG. 2 to FIG. 7 in the embodiments of the present application respectively implement the corresponding processes of the methods in FIG. 2 to FIG. 7 , and are not repeated here for the sake of brevity.

图11是本申请实施例提供的一种备节点1100的示意性框图。该备节点1100可以包括:存储器1101、处理1102、输入/输出接口1103。FIG. 11 is a schematic block diagram of a standby node 1100 provided by an embodiment of the present application. The standby node 1100 may include: a memory 1101 , a processing 1102 , and an input/output interface 1103 .

其中,存储器1101、处理器1102和输入/输出接口1103通过内部连接通路相连,该存储器1101用于存储程序指令,该处理器1102用于执行该存储器1101存储的程序指令,以控制输入/输出接口1103接收输入的数据和信息,输出操作结果等数据。The memory 1101, the processor 1102 and the input/output interface 1103 are connected through an internal connection path, the memory 1101 is used to store program instructions, and the processor 1102 is used to execute the program instructions stored in the memory 1101 to control the input/output interface 1103 receives input data and information, and outputs data such as operation results.

应理解,在本申请实施例中,该处理器1102可以采用中央处理单元(centralprocessingunit,CPU),该处理器还可以是其它通用处理器、数字信号处理器(digitalsignal processor,DSP)、专用集成电路(application specific integrated circuit,ASIC)、现成可编程门阵列(field programmable gate Array,FPGA)或者其它可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。或者该处理器1102采用一个或多个集成电路,用于执行相关程序,以实现本申请实施例所提供的技术方案。It should be understood that, in this embodiment of the present application, the processor 1102 may adopt a central processing unit (central processing unit, CPU), and the processor may also be other general-purpose processors, digital signal processors (digital signal processors, DSP), application-specific integrated circuits (application specific integrated circuit, ASIC), off-the-shelf programmable gate array (field programmable gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, and the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. Alternatively, the processor 1102 uses one or more integrated circuits to execute related programs, so as to implement the technical solutions provided by the embodiments of the present application.

该存储器1101可以包括只读存储器和随机存取存储器,并向处理器1102提供指令和数据。处理器1102的一部分还可以包括非易失性随机存取存储器。例如,处理器1102还可以存储设备类型的信息。The memory 1101 may include read only memory and random access memory, and provides instructions and data to the processor 1102 . A portion of the processor 1102 may also include non-volatile random access memory. For example, the processor 1102 may also store device type information.

在实现过程中,上述方法的各步骤可以通过处理器1102中的硬件的集成逻辑电路或者软件形式的指令完成。结合本申请实施例所公开的方法可以直接体现为硬件处理器执行完成,或者用处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器1101,处理器1102读取存储器1101中的信息,结合其硬件完成上述方法的步骤。为避免重复,这里不再详细描述。In the implementation process, each step of the above-mentioned method can be completed by an integrated logic circuit of hardware in the processor 1102 or an instruction in the form of software. The methods disclosed in conjunction with the embodiments of the present application may be directly embodied as executed by a hardware processor, or executed by a combination of hardware and software modules in the processor. The software modules may be located in random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, registers and other storage media mature in the art. The storage medium is located in the memory 1101, and the processor 1102 reads the information in the memory 1101, and completes the steps of the above method in combination with its hardware. To avoid repetition, detailed description is omitted here.

应理解,根据本申请实施例的备节点1100可对应于本申请实施例中的装置900,并可以用于执行本申请实施例图2-图7中的各个方法的相应流程,并且备节点1100中的各个模块的上述和其它操作和/或功能分别为了实现本申请实施例图2-图7中的各个方法的相应流程,为了简洁,在此不再赘述。It should be understood that the standby node 1100 according to the embodiment of the present application may correspond to the apparatus 900 in the embodiment of the present application, and may be used to execute the corresponding processes of each method in FIG. 2 to FIG. 7 in the embodiment of the present application, and the standby node 1100 The above-mentioned and other operations and/or functions of each module in FIG. 2 to FIG. 7 in the embodiments of the present application respectively implement the corresponding processes of the methods in FIG. 2 to FIG. 7 , and are not repeated here for the sake of brevity.

通过上述内容描述,本申请实施例提供的主节点1000以及备节点1100可以在数据备份的过程中通过日志机制保证一组写请求的原子性,避免了现有技术中通过文件系统语义锁来实现原子性,从而可以降低流程复杂性以及系统开销。Through the above description, the primary node 1000 and the backup node 1100 provided by the embodiments of the present application can ensure the atomicity of a group of write requests through a log mechanism during the data backup process, avoiding the implementation of file system semantic locks in the prior art Atomicity, which can reduce process complexity and system overhead.

应理解,在本申请的各种实施例中,上述各过程的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。It should be understood that, in various embodiments of the present application, the size of the sequence numbers of the above-mentioned processes does not mean the sequence of execution, and the execution sequence of each process should be determined by its functions and internal logic, and should not be dealt with in the embodiments of the present application. implementation constitutes any limitation.

本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。Those of ordinary skill in the art can realize that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Skilled artisans may implement the described functionality using different methods for each particular application, but such implementations should not be considered beyond the scope of this application.

所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统、装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the above-described systems, devices and units may refer to the corresponding processes in the foregoing method embodiments, which will not be repeated here.

在本申请所提供的几个实施例中,应该理解到,所揭露的系统、装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided in this application, it should be understood that the disclosed system, apparatus and method may be implemented in other manners. For example, the apparatus embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components may be combined or Can be integrated into another system, or some features can be ignored, or not implemented. On the other hand, the shown or discussed mutual coupling or direct coupling or communication connection may be through some interfaces, indirect coupling or communication connection of devices or units, and may be in electrical, mechanical or other forms.

所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution in this embodiment.

另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit.

所述功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(read-only memory,ROM)、随机存取存储器(random access memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。The functions, if implemented in the form of software functional units and sold or used as independent products, may be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be embodied in the form of a software product in essence, or the part that contributes to the prior art or the part of the technical solution. The computer software product is stored in a storage medium, including Several instructions are used to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: U disk, removable hard disk, read-only memory (ROM), random access memory (RAM), magnetic disk or optical disk and other media that can store program codes .

以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。The above are only specific embodiments of the present application, but the protection scope of the present application is not limited to this. should be covered within the scope of protection of this application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims (18)

1. A method of data writing, the method comprising:
the method comprises the following steps that a main node stores N sub-logs of a log to the local, the log is generated according to an atomic write request, the atomic write request is one or a series of operations which cannot be interrupted, and the log comprises: marking bits, wherein the atomic write request comprises N sub-writes, the sub-log records the information of the sub-writes, and N is a positive integer greater than 0;
the master node backs up the N sub-logs to a standby node;
and the master node modifies the state of the marking bit in the log under the condition that the N sub-logs are all stored in the standby node, so that the log is marked as valid.
2. The method of claim 1, further comprising:
and under the condition that the N sub-logs in the standby node fail to be stored, the main node deletes the stored N sub-logs.
3. The method according to claim 1 or 2, wherein the N sub-logs carry the same log identification number ID,
the main node stores N sub-logs of the log to the local, including:
and the main node orderly stores the N sub-logs into a log storage container of the main node according to the ID.
4. The method according to any one of claims 1 to 3, wherein the master node, in case that it is determined that all of the N sub-logs are stored to the standby node, marking the log as valid comprises:
the main node receives a notification message, wherein the notification message is used for indicating that all the N sub-logs are stored in the standby node;
the master node marks the log as valid.
5. A method of data writing, the method comprising:
the backup node stores N sub-logs of a log backed up by a master node into the backup node, wherein the log is generated according to an atomic write request, the atomic write request is one or a series of operations which cannot be interrupted, and the log comprises: marking bits, wherein the atomic write request comprises N sub-writes, the sub-log records the information of the sub-writes, and N is a positive integer greater than 0;
when the N sub-logs are all stored in the standby node, the standby node modifies the state of the marking bit in the log, so that the log is marked as valid;
and the standby node informs the main node that all the N sub-logs are stored in the standby node.
6. The method of claim 5, wherein the N sub-logs carry the same log identification number ID,
the backup node stores N sub-logs of the log backed up by the master node into the backup node, and the method comprises the following steps:
and the standby node stores the N sub-logs into a log storage container of the standby node in order according to the ID.
7. The method of claim 5 or 6, wherein the notifying, by the standby node, that the N sub-logs are all stored in the standby node to the master node comprises:
and the standby node sends a notification message to the main node, wherein the notification message is used for indicating that all the N sub-logs are stored in a log storage container of the standby node.
8. An apparatus for writing data, the apparatus comprising:
a storage module, configured to store N sub-logs of a log locally, where the log is generated according to an atomic write request, where the atomic write request is one or a series of operations that cannot be interrupted, and the log includes: marking bits, wherein the atomic write request comprises N sub-writes, each sub-log in the N sub-logs records information of each sub-write, and N is a positive integer greater than 0;
the sending module is used for backing up the N sub-logs to a standby node;
and the first processing module is used for modifying the state of the marking bit in the log under the condition that the N sub-logs are all stored in the standby node, so that the log is marked to be valid.
9. The apparatus of claim 8, further comprising:
and the second processing module is used for deleting the N sub-logs stored under the condition that the N sub-logs in the standby node fail to be stored.
10. The apparatus according to claim 8 or 9, wherein the N sub-logs carry the same log identification number ID,
the storage module is specifically configured to:
and the main node orderly stores the N sub-logs into a log storage container of the main node according to the ID.
11. The apparatus according to any one of claims 8 to 10, wherein the first processing module is specifically configured to:
receiving a notification message, wherein the notification message is used for indicating that all the N sub-logs are stored in the standby node;
marking the log as valid.
12. An apparatus for writing data, the method comprising:
a storage module, configured to store N sub-logs of a log backed up by a master node into the backup node, where the log is generated according to an atomic write request, the atomic write request is one or a series of operations that cannot be interrupted, and the log includes: marking bits, wherein the atomic write request comprises N sub-writes, each sub-log in the N sub-logs records information of each sub-write, and N is a positive integer greater than 0;
the processing module is used for modifying the state of the marking bit in the log when the N sub-logs are all stored in the standby node, so that the log is marked to be valid;
and the sending module is used for informing the master node that all the N sub-logs are stored in the standby node by the standby node.
13. The apparatus of claim 12, wherein the N sub-logs carry a same log identification number (ID),
the storage module is specifically configured to:
and orderly storing the N sub-logs into a log storage container of the standby node according to the ID.
14. The apparatus according to claim 12 or 13, wherein the sending module is specifically configured to:
and sending a notification message to the master node, wherein the notification message is used for indicating that all the N sub-logs are stored in a log storage container of the standby node.
15. A master node comprising an input output interface, a processor for controlling the input output interface to transceive information, and a memory for storing a computer program, the processor being configured to retrieve from the memory and execute the computer program such that the master node performs the operational steps of the method of any one of claims 1 to 4.
16. A standby node comprising an input/output interface, a processor for controlling the input/output interface to transceive information, and a memory for storing a computer program, the processor being configured to retrieve and execute the computer program from the memory so that the standby node performs the operation steps of the method of any one of claims 5 to 7.
17. A storage system comprising a master node according to claim 15 and a backup node according to claim 16.
18. A computer-readable storage medium, comprising a computer program which, when run on a computer, causes the computer to perform the method of any one of claims 1 to 7.
CN201810706826.8A 2018-07-02 2018-07-02 A method and device for writing data Active CN110737716B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810706826.8A CN110737716B (en) 2018-07-02 2018-07-02 A method and device for writing data

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810706826.8A CN110737716B (en) 2018-07-02 2018-07-02 A method and device for writing data

Publications (2)

Publication Number Publication Date
CN110737716A CN110737716A (en) 2020-01-31
CN110737716B true CN110737716B (en) 2022-09-23

Family

ID=69233325

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810706826.8A Active CN110737716B (en) 2018-07-02 2018-07-02 A method and device for writing data

Country Status (1)

Country Link
CN (1) CN110737716B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113609150B (en) * 2021-10-08 2022-03-08 阿里云计算有限公司 Hardware-based atomic writing method, equipment and system
CN114780305B (en) * 2022-04-26 2025-08-19 济南浪潮数据技术有限公司 Single node starting method, device, equipment and medium
CN118568166A (en) * 2023-02-28 2024-08-30 华为技术有限公司 Log synchronization method and device, electronic equipment and storage medium
CN115993940B (en) * 2023-03-23 2023-07-25 青岛鼎信通讯股份有限公司 Electric quantity loss prevention method and device, electric energy meter equipment and storage medium
CN116107516B (en) * 2023-04-10 2023-07-11 苏州浪潮智能科技有限公司 Data writing method and device, solid state disk, electronic equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101251814A (en) * 2008-02-04 2008-08-27 浙江大学 A Method of Realizing Trusted Restoration System in Operating System
CN104571956A (en) * 2014-12-29 2015-04-29 成都致云科技有限公司 Data writing method and splitting device
CN106648959A (en) * 2016-09-07 2017-05-10 华为技术有限公司 Data storage method and storage system
US9785510B1 (en) * 2014-05-09 2017-10-10 Amazon Technologies, Inc. Variable data replication for storage implementing data backup

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102609479B (en) * 2012-01-20 2015-11-25 北京思特奇信息技术股份有限公司 A kind of memory database node clone method
CN103793291B (en) * 2012-11-01 2017-04-19 华为技术有限公司 Distributed data copying method and device
CN104346373B (en) * 2013-07-31 2017-12-15 华为技术有限公司 Subregion journal queue synchronization management method and equipment
CN105426439B (en) * 2015-11-05 2022-07-05 腾讯科技(深圳)有限公司 Metadata processing method and device
CN106855822A (en) * 2015-12-08 2017-06-16 阿里巴巴集团控股有限公司 For the method and apparatus of distributing real time system

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101251814A (en) * 2008-02-04 2008-08-27 浙江大学 A Method of Realizing Trusted Restoration System in Operating System
US9785510B1 (en) * 2014-05-09 2017-10-10 Amazon Technologies, Inc. Variable data replication for storage implementing data backup
CN104571956A (en) * 2014-12-29 2015-04-29 成都致云科技有限公司 Data writing method and splitting device
CN106648959A (en) * 2016-09-07 2017-05-10 华为技术有限公司 Data storage method and storage system

Also Published As

Publication number Publication date
CN110737716A (en) 2020-01-31

Similar Documents

Publication Publication Date Title
CN110737716B (en) A method and device for writing data
US8464101B1 (en) CAS command network replication
US8214612B1 (en) Ensuring consistency of replicated volumes
JP6362685B2 (en) Replication method, program, and apparatus for online hot standby database
CN105630632B (en) The method and virtual machine administration device that a kind of virtual machine recovers
US20140208012A1 (en) Virtual disk replication using log files
JP2001356945A (en) Data backup recovery system
US7979651B1 (en) Method, system, and computer readable medium for asynchronously processing write operations for a data storage volume having a copy-on-write snapshot
US20190317872A1 (en) Database cluster architecture based on dual port solid state disk
US11099980B2 (en) Host aware update write
CN107329859B (en) Data protection method and storage device
CN106528338B (en) A remote data replication method, storage device and storage system
WO2022033269A1 (en) Data processing method, device and system
US9330153B2 (en) System, method, and computer readable medium that coordinates between devices using exchange of log files
CN103678608B (en) Blog management method and device
JP5365128B2 (en) Information system, method, and program related to data registered in batch
CN110121712B (en) A log management method, server and database system
CN110121694B (en) Log management method, server and database system
WO2017023244A1 (en) Fault tolerant computing
CN117785546A (en) Database backup method, system and computing device cluster
CN118708130A (en) Data volume remote replication method, device, computer equipment and storage medium
CN114791901A (en) Data processing method, apparatus, equipment and storage medium
WO2024183421A1 (en) Data disaster recovery method, apparatus and system, node device, and standby node device
US20190073128A1 (en) Computer system, data management method, and data management program
CN107357536A (en) Distributed memory system data modification write method and system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant