WO2023246236A1 - 分布式数据库的节点配置方法、事务日志同步方法和节点 - Google Patents

分布式数据库的节点配置方法、事务日志同步方法和节点 Download PDF

Info

Publication number
WO2023246236A1
WO2023246236A1 PCT/CN2023/087009 CN2023087009W WO2023246236A1 WO 2023246236 A1 WO2023246236 A1 WO 2023246236A1 CN 2023087009 W CN2023087009 W CN 2023087009W WO 2023246236 A1 WO2023246236 A1 WO 2023246236A1
Authority
WO
WIPO (PCT)
Prior art keywords
nodes
node
distributed database
asynchronous
transaction
Prior art date
Application number
PCT/CN2023/087009
Other languages
English (en)
French (fr)
Inventor
阳振坤
韩富晟
杨传辉
陈俊全
Original Assignee
北京奥星贝斯科技有限公司
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 北京奥星贝斯科技有限公司 filed Critical 北京奥星贝斯科技有限公司
Publication of WO2023246236A1 publication Critical patent/WO2023246236A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2365Ensuring data consistency and integrity
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2282Tablespace storage structures; Management thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor

Definitions

  • One or more embodiments of this specification relate to the field of distributed databases, and in particular, to a node configuration method, transaction log synchronization method and node of a distributed database.
  • Database is a very critical technology in the digital age.
  • the database system has excellent characteristics such as structured data storage, high shareability of stored data, low redundancy, easy expansion, and high independence. It is now a must in many fields, such as finance, medical care, education, scientific research, and e-commerce.
  • the underlying technology used As a result, distributed databases have emerged to handle large-scale data. Distributed databases have good data scalability, as well as the same SQL support and transaction semantic guarantees as traditional databases. Therefore, in application scenarios that require better data scalability, the use of distributed transactional databases has become a trend.
  • distributed database solutions usually use distributed consistency protocols to achieve data consistency for each node in the distributed database system. However, this solution has high requirements on the network bandwidth between database nodes. When the network status is not good, the efficiency of reaching data agreement between nodes will significantly decrease.
  • the embodiments in this specification are intended to provide a more efficient method for achieving data consistency among nodes in a distributed system when the network status between database nodes is not good, and to solve deficiencies in the existing technology.
  • a node configuration method for a distributed database including:
  • the first nodes include master nodes for synchronizing transactions, the first number is an integer greater than N/2, and the The first node determines the first transaction based on the distributed consistency protocol;
  • some or all nodes other than the first node are used as asynchronous nodes or election nodes; the asynchronous nodes are used to receive the first transaction from the master node in an asynchronous manner, and the election nodes At least for changing the master node in said first node.
  • a first number of first nodes are determined from the N nodes of the distributed database, including:
  • a first number of first nodes is determined.
  • the N nodes are N valid nodes in the distributed database
  • the election node is also used to re-determine valid nodes in the distributed database.
  • a transaction log synchronization method for a distributed database including:
  • a first number of first nodes is determined from the N nodes of the distributed database, the first number is an integer greater than N/2, the first nodes include a master node for synchronizing transactions, and the Based on the distributed consistency protocol between the first nodes, determine the transaction log for the first transaction;
  • some or all nodes other than the first node are used as asynchronous nodes or election nodes; the asynchronous nodes are used to receive the transaction log from the master node in an asynchronous manner, and the election nodes are at least Used to change the primary node in the first node.
  • a first number of first nodes are determined from the N nodes of the distributed database, including:
  • a first number of first nodes is determined from the N nodes.
  • the N nodes are N valid nodes in the distributed database
  • the election node is also used to re-determine valid nodes in the distributed database.
  • a distributed database includes N nodes, and the N nodes include:
  • the first nodes include master nodes for synchronizing transactions.
  • the first nodes determine the first transaction based on a distributed consistency protocol.
  • the first number is greater than N/ an integer of 2;
  • An asynchronous node and/or an election node wherein the asynchronous node is used to receive the first transaction from the master node in an asynchronous manner, and the election node is at least used to change the master node in the first node.
  • the N nodes are N valid nodes in the distributed database
  • the election node is also used to re-determine valid nodes in the distributed database.
  • a distributed database includes N nodes, and the N nodes include:
  • the first nodes include a master node for synchronizing transactions.
  • the first nodes determine a transaction log for the first transaction based on a distributed consistency protocol.
  • the first nodes The quantity is an integer greater than N/2;
  • An asynchronous node and/or an election node wherein the asynchronous node is used to receive the transaction log from the master node in an asynchronous manner, and the election node is at least used to change the master node in the first node.
  • the N nodes are N valid nodes in the distributed database
  • the election node is also used to re-determine valid nodes in the distributed database.
  • an asynchronous node in a distributed database further includes a first number of first nodes, and a first transaction is determined between the first nodes based on a distributed consistency protocol, so the first quantity Greater than N/2, N is the total number of effective nodes of the distributed database, and the asynchronous nodes include:
  • the first asynchronous receiving unit is configured to receive the first transaction from the master node in an asynchronous manner.
  • an asynchronous node in a distributed database is provided.
  • the distributed database further includes a first number of first nodes, and the first nodes determine the target for the first transaction based on a distributed consistency protocol.
  • transaction log the first number is greater than N/2
  • N is the total number of effective nodes of the distributed database
  • the asynchronous nodes include:
  • the second asynchronous receiving unit is configured to receive the transaction log for the first transaction from the master node in an asynchronous manner.
  • an election node in a distributed database further includes a first number of first nodes, the first nodes include a master node for synchronizing transactions, and the first The nodes include a master node for synchronizing transactions.
  • the first nodes determine the first transaction based on a distributed consistency protocol. The first number is greater than N/2, and N is a valid node of the distributed database.
  • the total number of election nodes includes:
  • the master node changing unit is configured to change the master node in the first node.
  • the election node further includes:
  • a valid node determination unit is configured to re-determine valid nodes in the distributed database.
  • a computer-readable storage medium on which a computer program is stored.
  • the computer program is executed in a computer, the computer is caused to perform the methods described in the first, second, and third aspects.
  • a computing device including a memory and a processor, characterized in that executable code is stored in the memory, and when the processor executes the executable code, the first and second steps are implemented. , the method described in the third aspect.
  • the data of each node of the distributed system can be more effectively achieved under the condition of poor network bandwidth between database nodes. consistent.
  • Figure 1 shows a schematic diagram of a method for achieving data consistency between database nodes in a distributed database
  • Figure 2 shows a schematic diagram of a node configuration method for a distributed database according to an embodiment of this specification
  • Figure 3 shows a flow chart of a node configuration method for a distributed database according to an embodiment of this specification
  • Figure 4 shows a schematic diagram of a node configuration method of a distributed database according to another embodiment of this specification
  • Figure 5 shows a flow chart of a node configuration method for a distributed database according to another embodiment of this specification
  • Figure 6 shows a schematic diagram of a node configuration method of a distributed database according to another embodiment of this specification.
  • Figure 7 shows a flow chart of a node configuration method for a distributed database according to yet another embodiment of this specification
  • Figure 8 shows a schematic diagram of a node configuration method of a distributed database according to yet another embodiment of this specification.
  • Figure 9 shows a flow chart of a transaction log synchronization method for a distributed database according to an embodiment of this specification
  • Figure 10 shows a structural diagram of a database node according to an embodiment of this specification
  • Figure 11 shows a structural diagram of another database node according to an embodiment of this specification.
  • Figure 12 shows a structural diagram of yet another database node according to an embodiment of this specification.
  • Figure 1 shows a schematic diagram of a method for achieving data consistency between database nodes in a distributed database.
  • node A, node B, node C, node D, and node E are five nodes in a distributed database.
  • Node A, node B, node C, node D, and node E can determine the unique value of a piece of data (for example, V) in the distributed database through the distributed consistency protocol.
  • V a piece of data
  • data consistency can be achieved when the majority of nodes in the system (more than 1/2 of the total number of nodes) can work.
  • data consistency can still be achieved.
  • determining the data in the distributed database can usually be equivalent to determining the transaction that writes the data.
  • the transaction may be determined by determining the transaction log corresponding to the transaction writing data.
  • Each node in the distributed database can determine the transaction log of each pending transaction in the data through the distributed consistency protocol.
  • a series of log values V1, V2...Vx...Vn can be determined, where each value can represent the content of a specific transaction log.
  • one of the nodes can usually serve as the master node. The user writes the transaction data to the master node to generate a transaction log, and then the master node sends the transaction log to other slave nodes through the network, and waits and determines the transaction log based on the consensus feedback of the other slave nodes. Whether it is executed (that is, determine whether to execute the transaction).
  • the inventor proposes a method for achieving data consistency between database nodes in a distributed database in the embodiments of this specification.
  • the core idea is that the database nodes can be divided into ordinary nodes (or first nodes) and asynchronous nodes (or second nodes) according to the network bandwidth conditions between nodes.
  • the ordinary node (or the first node) is used to determine the transaction data based on the distributed consistency protocol
  • the asynchronous node (or the second node) is used to obtain the transaction data in an asynchronous manner from the ordinary node after the transaction data is determined.
  • the transaction data can be determined only through ordinary nodes that usually have good bandwidth status, and then the ordinary nodes asynchronously send the determined transaction data to the asynchronous nodes. Since asynchronous data transmission can be performed, for example, to avoid business peak periods, it can avoid the decline in the overall data consensus efficiency in the distributed database due to poor bandwidth conditions of some nodes during business peak periods.
  • Figure 2 shows a schematic diagram of a method for achieving data consistency between database nodes in a distributed database.
  • the distributed database has 5 nodes, namely nodes A, B, C, D, and E.
  • a and B are placed in Shanghai
  • C and D are placed in Hangzhou
  • node E is placed in Shenzhen. It is assumed that the network bandwidth between Shanghai and Hangzhou is relatively large, while the network bandwidth between Shanghai, Hangzhou and Shenzhen is relatively small.
  • node A is the master node, transactions start to be written from node A, and then node A synchronizes the transaction log to other nodes.
  • node E in Shenzhen can be used as an asynchronous node, that is, node E does not need to participate in the determination of the transaction log, and point A can determine the transaction log and send it to node E in an asynchronous manner.
  • the specific sending time after the transaction log is determined can be determined based on preset time rules or network status judgment conditions. For example, transaction data can be sent to node E not during peak business periods or when the transaction log traffic is lower than a predetermined threshold, thereby not affecting the transaction processing speed or transaction throughput of the entire database system.
  • FIG. 3 shows a flow chart of a node configuration method for a distributed database according to an embodiment of this specification. As shown in Figure 3, this method at least includes the following steps:
  • a first number of first nodes is determined from the N nodes of the distributed database.
  • the first number is an integer greater than N/2.
  • the first nodes determine the first node based on the distributed consistency protocol. One transaction.
  • a distributed database is usually a database that has distributed transaction processing capabilities, can be smoothly expanded, is distributed on a computer network, and is logically unified. The data it stores can be physically stored on different database nodes.
  • thing A transaction is a set of data operations that access or operate data items in the database. This set of data operations is either all executed or not executed at all.
  • all data operations are encapsulated into transactions for processing, or in other words, all data access is performed by submitting transactions.
  • the distributed database may be different specific types of distributed databases, and this specification does not limit this.
  • the nodes of the distributed database may be storage nodes based on one or more of physical nodes, virtual machine nodes, or container nodes.
  • the determined first node can determine the database transaction according to the distributed consistency protocol.
  • the first node may be determined from the nodes of the distributed database according to different specific methods, and this specification does not limit this.
  • a first number of first nodes may be determined from the N nodes according to the network topology of the distributed database and/or the network bandwidth between the N nodes.
  • different specific methods may be used to determine database transactions between the first nodes.
  • the first nodes may determine a transaction log for the first transaction based on a distributed consistency protocol.
  • each first node can determine the first transaction to be executed based on the determined transaction log.
  • step 32 some or all of the N nodes other than the first node are used as asynchronous nodes.
  • the asynchronous node (ie, the second node in Figure 3) is used by at least one first node to send the first transaction to the asynchronous node in an asynchronous manner.
  • the so-called asynchronous method here means that the second node does not participate in the consensus process of the first transaction, and can obtain the first transaction from the first node after the first transaction is determined through the consensus process.
  • the asynchronous node may be determined from nodes other than the first node according to different specific methods, and this specification does not limit this.
  • the asynchronous node may be determined from the node other than the first node based on the network bandwidth between the node other than the first node and each first node.
  • the specific time for sending it to the second node can also be determined based on different specific ways. In one embodiment, the specific time may be determined based on preset time rules or network status judgment conditions.
  • At least one first node may send the transaction log to an asynchronous node in an asynchronous manner.
  • the member nodes of the database system can be re-determined from the currently available nodes, the currently unavailable nodes can be at least temporarily excluded from the database member nodes, and the first node and the first node can be determined based on the new member nodes.
  • Figure 4 shows a schematic diagram of a node configuration method of a distributed database according to another embodiment of this specification.
  • nodes C, D, and E can change the member nodes of the database (or effective nodes, that is, the nodes that can effectively operate in the current database).
  • the number of nodes is changed from 5 to 3 (that is, N is changed from 5 to 3), and one of the nodes is selected as the master node.
  • the number of transaction log copies is also reduced from 5 to 3 copies.
  • the election of the master node and the change Member nodes must reach agreement among nodes C, D, and E. Then, no more than N/2 (note that N is 3 at this time) asynchronous nodes can be determined in C, D, and E.
  • node D is the main node and node E is an asynchronous node.
  • FIG. 5 shows a flow chart of a node configuration method for a distributed database according to yet another embodiment of this specification. As shown in Figure 5, this method at least includes the following steps:
  • a first number of first nodes is determined from the N nodes of the distributed database.
  • the first nodes include master nodes for synchronizing transactions.
  • the first number is greater than N/2.
  • Integer, the first transaction is determined between the first nodes based on the distributed consistency protocol.
  • the determined first node can determine the database transaction according to the distributed consistency protocol, and the first node includes a master node for synchronizing transactions.
  • the first node may be determined from the nodes of the distributed database according to different specific methods, and this specification does not limit this.
  • a first number of first nodes may be determined from the N nodes according to the network topology of the distributed database and/or the network bandwidth between the N nodes.
  • step 52 some or all of the N nodes other than the first node are used as election nodes.
  • the first node may include a master node.
  • the election node can be used to change the master node in the database, that is, to re-determine the master node in the first node.
  • the election node can also be used to determine changes to database member nodes, that is, to re-determine valid nodes (or member nodes) in the database.
  • Figure 6 shows a schematic diagram of a node configuration method of a distributed database according to another embodiment of this specification.
  • node E when the network bandwidth of node E in Shenzhen is lower than the preset bandwidth condition, node E can be set as the election node, that is, node E does not need to participate in the determination of the database transaction log, nor does it need to receive the database transaction log. You only need to participate in determining changes to database member nodes or master nodes. Setting up an election node not only saves network bandwidth, but also further saves other system resources of the node, such as CPU, memory and disk. Therefore, in one embodiment, the election node may be determined based on the network bandwidth between nodes other than the first node and each first node. In another embodiment, the election node may also be determined based on the computing resources of nodes other than the first node. In one embodiment, the election node can also be determined based on the network bandwidth and computing resources of nodes other than the first node.
  • FIG. 7 shows a flow chart of a node configuration method for a distributed database according to yet another embodiment of this specification. As shown in Figure 7, this method at least includes the following steps:
  • a first number of first nodes is determined from the N nodes of the distributed database.
  • the first nodes include master nodes for synchronizing transactions.
  • the first number is greater than N/2.
  • Integer the first transaction is determined between the first nodes based on the distributed consistency protocol;
  • step 51 The operation of this step is similar to step 51.
  • step 51 For detailed description, please refer to the description of step 51, which will not be described again here.
  • step 72 among the N nodes, the first part of the nodes other than the first node is used as the asynchronous node.
  • a second part of nodes other than one node serves as an election node, wherein the asynchronous node is used to receive the first transaction from the master node in an asynchronous manner, and the election node is at least used to change the first node the master node in .
  • the method of determining asynchronous nodes and election nodes is similar to the method of determining asynchronous nodes and election nodes in steps 32 and 52.
  • the N nodes may be N valid nodes in the distributed database; the third node may also be used to re-determine the valid nodes in the distributed database.
  • FIG 8 shows a schematic diagram of a node configuration method of a distributed database according to yet another embodiment of this specification.
  • asynchronous nodes and election nodes can be set up in a distributed database system, and their total number is limited to less than 1/2 of the total number of nodes (that is, less than N/2).
  • the ratio between asynchronous nodes and election nodes may be different in different embodiments, and this specification does not limit this.
  • any two nodes such as nodes A, B, C, D, and E, can be set as asynchronous nodes, election nodes, or a combination of the two.
  • FIG. 9 shows a flow chart of a transaction log synchronization method for a distributed database according to an embodiment of this specification. As shown in Figure 9, this method at least includes the following steps:
  • a first number of first nodes is determined from the N nodes of the distributed database.
  • the first number is an integer greater than N/2.
  • the first nodes include a master node used for synchronization transactions. Nodes, the first nodes determine the transaction log for the first transaction based on a distributed consistency protocol;
  • step 92 among the N nodes, the first part of the nodes other than the first node is used as the asynchronous node, and the second part of the nodes other than the first node is used as the election node, where the asynchronous node is used to select from the master in an asynchronous manner.
  • the node receives the first transaction and elects a node for at least changing the master node in the first node.
  • a first number of first nodes may be determined from the N nodes according to the network topology of the distributed database and/or the network bandwidth between the N nodes.
  • the N nodes are N valid nodes in the distributed database; the election node can also be used to re-determine the valid nodes in the distributed database.
  • the node configuration method and transaction log synchronization method of the distributed database have the following advantages: by setting asynchronous nodes and/or election nodes in the distributed database, the asynchronous nodes do not participate in transaction determination and only After the transaction is determined, transaction data is received in an asynchronous manner, while the election node does not participate in transaction determination and does not receive transaction data. It only participates in database member node changes, determining transaction synchronization nodes or electing master nodes, reducing the transaction synchronization consumption of distributed databases. Internet resources. This enables the distributed database to still perform transaction processing based on the distributed data consistency protocol and ensure its transaction processing speed even when the network bandwidth is insufficient.
  • a distributed database is also provided.
  • the distributed database includes N nodes, and the N nodes include:
  • the first nodes include master nodes for synchronizing transactions.
  • the first nodes determine the first transaction based on a distributed consistency protocol.
  • the first number is greater than N/ an integer of 2;
  • An asynchronous node and/or an election node wherein the asynchronous node is used to receive the first transaction from the master node in an asynchronous manner, and the election node is at least used to change the master node in the first node.
  • the N nodes may be N valid nodes in the distributed database; the election node may also be used to re-determine the valid nodes in the distributed database.
  • the distributed database includes N nodes, and the N nodes include:
  • the first nodes include a master node for synchronizing transactions.
  • the first nodes determine a transaction log for the first transaction based on a distributed consistency protocol.
  • the first nodes The quantity is an integer greater than N/2;
  • An asynchronous node and/or an election node wherein the asynchronous node is used to receive the transaction log from the master node in an asynchronous manner, and the election node is at least used to change the master node in the first node.
  • the N nodes may be N valid nodes in the distributed database; the election node may also be used to re-determine the valid nodes in the distributed database.
  • an asynchronous node in a distributed database is also provided.
  • the distributed database further includes a first number of first nodes, and the first nodes determine a first node based on a distributed consistency protocol. For transactions, the first number is greater than N/2, and N is the total number of effective nodes of the distributed database.
  • Figure 10 shows a structural diagram of a database node according to an embodiment of this specification. As shown in Figure 10, the asynchronous node 1000 includes:
  • the first asynchronous receiving unit 101 is configured to receive the first transaction from the master node in an asynchronous manner.
  • yet another asynchronous node in a distributed database is also provided.
  • the distributed database further includes a first number of first nodes, and the first nodes determine based on a distributed consistency protocol. For the transaction log of the first transaction, the first number is greater than N/2, and N is the total number of effective nodes of the distributed database.
  • Figure 11 shows a structural diagram of another database node according to an embodiment of this specification. As shown in Figure 11, the asynchronous node 1100 includes:
  • the second asynchronous receiving unit 111 is configured to receive the transaction log for the first transaction from the master node in an asynchronous manner.
  • an election node in a distributed database is also provided.
  • the distributed database further includes a first number of first nodes, and the first nodes include a master node for synchronizing transactions, so The first transaction is determined between the first nodes based on a distributed consistency protocol, the first number is greater than N/2, and N is the total number of valid nodes of the distributed database.
  • Figure 12 shows a structural diagram of yet another database node according to an embodiment of this specification. As shown in Figure 12, the election node 1200 includes:
  • the master node changing unit 121 is configured to change the master node in the first node.
  • the election node may also include,
  • a valid node determination unit is configured to re-determine valid nodes in the distributed database.
  • Another aspect of this specification provides a computer-readable storage medium on which a computer program is stored.
  • the computer program is executed in a computer, the computer is caused to perform any of the above methods.
  • Another aspect of this specification provides a computing device, including a memory and a processor.
  • the memory stores executable code.
  • the processor executes the executable code, any one of the above methods is implemented.
  • the functions described in the present invention can be implemented by hardware, software, firmware, or any combination thereof.
  • the functions may be stored on or transmitted over as one or more instructions or code on a computer-readable medium.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Software Systems (AREA)
  • Computing Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

说明书实施例提供了一种分布式数据库的节点配置方法、事务日志同步方法和节点,该节点配置方法包括:从分布式数据库的N个节点中,确定出第一数量的第一节点,第一节点中包括用于同步事务的主节点,第一数量为大于N/2的整数,第一节点之间基于分布式一致性协议确定第一事务;以N个节点中,第一节点以外的部分或全部节点,作为异步节点或选举节点;异步节点用于通过异步方式从主节点接收第一事务,选举节点至少用于更改第一节点中的主节点。

Description

分布式数据库的节点配置方法、事务日志同步方法和节点
本申请要求于2022年6月24日提交中国国家知识产权局、申请号为202210724274.X、申请名称为“分布式数据库的节点配置方法、事务日志同步方法和节点”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本说明书一个或多个实施例涉及分布式数据库领域,尤其涉及一种分布式数据库的节点配置方法、事务日志同步方法和节点。
背景技术
数据库对于数字时代是非常关键的技术。数据库系统具有数据存储结构化、存储的数据共享性高、冗余度低、易扩充、独立性高等优秀的特性,在很多领域,例如金融、医疗、教育、科研、电子商务,目前已是必须使用的基础技术。但是,随着技术的发展,数据收集和运用的规模不断增长,传统的单机型关系型数据库越来越不能处理与日俱增的大规模数据。由此,涌现出处理大规模数据的分布式数据库。分布式数据库具有良好的数据可扩展性,以及和传统数据库一样的SQL支持和事务语义保证。因此,在要求更好的数据可扩展性的应用场景中,使用分布式事务型数据库成为一种趋势。目前,分布式数据库方案通常通过分布式一致性协议,达成分布式数据库系统中各个节点的数据一致。但是,这种方案对于数据库节点间的网络带宽具有较高要求,在网络状态不佳时,节点间达成数据一致的效率会显著下降。
发明内容
本说明书中的实施例旨在提供在数据库节点之间的网络状态不佳的状况下,更高效地达成分布式系统各个节点的数据一致的方法,解决现有技术中的不足。
根据第一方面,提供一种分布式数据库的节点配置方法,包括:
从分布式数据库的N个节点中,确定出第一数量的第一节点,所述第一节点中包括用于同步事务的主节点,所述第一数量为大于N/2的整数,所述第一节点之间基于分布式一致性协议确定第一事务;
以所述N个节点中,第一节点以外的部分或全部节点,作为异步节点或选举节点;所述异步节点用于通过异步方式从所述主节点接收所述第一事务,所述选举节点至少用于更改所述第一节点中的主节点。
在一种可能的实施方式中,从分布式数据库的N个节点中,确定出第一数量的第一节点,包括:
根据所述分布式数据库的网络拓扑结构和/或所述N个节点之间的网络带宽,从所述N 个节点中,确定出第一数量的第一节点。
在一种可能的实施方式中,所述N个节点为所述分布式数据库中的N个有效节点;
所述选举节点还用于重新确定所述分布式数据库中的有效节点。
根据第一方面,提供一种分布式数据库的事务日志同步方法,包括:
从分布式数据库的N个节点中,确定出第一数量的第一节点,所述第一数量为大于N/2的整数,所述第一节点中包括用于同步事务的主节点,所述第一节点之间基于分布式一致性协议,确定针对第一事务的事务日志;
以所述N个节点中,第一节点以外的部分或全部节点,作为异步节点或选举节点;所述异步节点用于通过异步方式从所述主节点接收所述事务日志,所述选举节点至少用于更改所述第一节点中的主节点。
在一种可能的实施方式中,从分布式数据库的N个节点中,确定出第一数量的第一节点,包括:
根据所述分布式数据库的网络拓扑结构和/或所述N个节点之间的网络带宽,从所述N个节点中,确定出第一数量的第一节点。
在一种可能的实施方式中,所述N个节点为所述分布式数据库中的N个有效节点;
所述选举节点还用于重新确定所述分布式数据库中的有效节点。
根据第三方面,提供一种分布式数据库,所述分布式数据库包括N个节点,所述N个节点中包括:
第一数量的第一节点,所述第一节点中包括用于同步事务的主节点,所述第一节点之间基于分布式一致性协议确定第一事务,所述第一数量为大于N/2的整数;
异步节点和/或选举节点,其中,所述异步节点用于通过异步方式从所述主节点接收所述第一事务,所述选举节点至少用于更改所述第一节点中的主节点。
在一种可能的实施方式中,所述N个节点为所述分布式数据库中的N个有效节点;
所述选举节点还用于重新确定所述分布式数据库中的有效节点。
根据第四方面,提供一种分布式数据库,所述分布式数据库包括N个节点,所述N个节点中包括:
第一数量的第一节点,所述第一节点中包括用于同步事务的主节点,所述第一节点之间基于分布式一致性协议,确定针对第一事务的事务日志,所述第一数量为大于N/2的整数;
异步节点和/或选举节点,其中,所述异步节点用于通过异步方式从所述主节点接收所述事务日志,所述选举节点至少用于更改所述第一节点中的主节点。
在一种可能的实施方式中,所述N个节点为所述分布式数据库中的N个有效节点;
所述选举节点还用于重新确定所述分布式数据库中的有效节点。
根据第五方面,提供一种分布式数据库中的异步节点,所述分布式数据库还包括第一数量的第一节点,所述第一节点之间基于分布式一致性协议确定第一事务,所述第一数量 大于N/2,N为所述分布式数据库的有效节点总数,所述异步节点包括:
第一异步接收单元,配置为,通过异步方式从所述主节点接收第一事务。
根据第六方面,提供一种分布式数据库中的异步节点,所述分布式数据库还包括第一数量的第一节点,所述第一节点之间基于分布式一致性协议,确定针对第一事务的事务日志,所述第一数量大于N/2,N为所述分布式数据库的有效节点总数,所述异步节点包括:
第二异步接收单元,配置为,通过异步方式从所述主节点接收针对第一事务的事务日志。
根据第七方面,提供一种分布式数据库中的选举节点,所述分布式数据库还包括第一数量的第一节点,所述第一节点中包括用于同步事务的主节点,所述第一节点中包括用于同步事务的主节点,所述第一节点之间基于分布式一致性协议确定第一事务,,所述第一数量大于N/2,N为所述分布式数据库的有效节点总数,所述选举节点包括:
主节点更改单元,配置为,用于更改所述第一节点中的主节点。
在一种可能的实施方式中,所述选举节点,还包括,
有效节点确定单元,配置为,用于重新确定所述分布式数据库中的有效节点。
根据第八方面,提供了一种计算机可读存储介质,其上存储有计算机程序,当所述计算机程序在计算机中执行时,令计算机执行第一、第二、第三方面所述的方法。
根据第九方面,提供了一种计算设备,包括存储器和处理器,其特征在于,所述存储器中存储有可执行代码,所述处理器执行所述可执行代码时,实现第一、第二、第三方面所述的方法。
利用以上各个方面中的方法、数据库、节点、计算设备、存储介质中的一个或多个,可以在数据库节点之间网络带宽不佳的状况下,更为有效地达成分布式系统各个节点的数据一致。
附图说明
为了更清楚说明本发明实施例的技术方案,下面将对实施例描述中所需使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1示出一种分布式数据库中数据库节点之间达成数据一致的方法的示意图;
图2示出根据本说明书实施例的一种分布式数据库的节点配置方法的示意图;
图3示出根据本说明书实施例的一种分布式数据库的节点配置方法的流程图;
图4示出根据本说明书另一实施例的一种分布式数据库的节点配置方法的示意图;
图5示出根据本说明书又一实施例的一种分布式数据库的节点配置方法的流程图;
图6示出根据本说明书又一实施例的一种分布式数据库的节点配置方法的示意图;
图7示出根据本说明书再一实施例的一种分布式数据库的节点配置方法的流程图;
图8示出根据本说明书再一实施例的一种分布式数据库的节点配置方法的示意图;
图9示出根据本说明书实施例的一种分布式数据库的事务日志同步方法的流程图;
图10示出根据本说明书实施例的一种数据库节点的结构图;
图11示出根据本说明书实施例的另一种数据库节点的结构图;
图12示出根据本说明书实施例的又一种数据库节点的结构图。
具体实施方式
下面将结合附图,对本发明书提供的方案进行描述。
如前所述,目前的分布式数据库方案通常通过分布式一致性协议,达成分布式系统各个节点的数据一致。但是,这种方案对于数据库节点间的网络带宽具有较高要求,在网络状态不佳时,节点间达成数据一致的效率会显著下降。为了更清楚的阐述本说明书实施例提供的分布式数据库的节点配置方案的技术效果,下面进一步对现有的数据库节点间达成数据一致的常用技术方案进行概要的说明。
图1示出一种分布式数据库中数据库节点之间达成数据一致的方法的示意图。如图1所示,例如,节点A、节点B、节点C、节点D、节点E是一个分布式数据库中的5个节点。节点A、节点B、节点C、节点D、节点E可以通过分布式一致性协议确定分布式数据库中一个数据(例如为V)的唯一值。通常,通过分布式一致性协议,可以在系统中占多数的(大于1/2的总节点数)节点可以工作的情况下,达成数据的一致性。例如,图1所示中,节点A、B、C、D、E任意两个节点宕机的情况下,还能达成数据的一致性,例如在节点C,D宕机的情况,还可以实际通过节点A、B和C确定唯一的V值。但是,上述方案存在的问题在于,在通过分布式一致性协议,达成数据一致的过程中,上述的节点之间常常需要发送或接收大量的一致性共识信息(例如,对于欲共识数据的共识请求或者对于所述共识请求的响应)。如果节点A、B、C、D、E部分节点之间的网络连接状态不好,导致它们之间的网络带宽下降或稳定度低,会导致节点从与其网络连接状态不好的节点得到这些共识信息的速度大为下降,从而导致整个分布式数据库的共识机制速度大为下降。下面以一种具体的例子来进一步说明上述问题。由于分布式数据库中,通常对于数据进行处理的操作单元为事务(Transaction),因此在分布式数据库中确定数据,通常也可以等同于确定写入该数据的事务。具体的,在一个实施例中,例如可以通过确定写入数据的事务对应的事务日志来确定该事务。
而分布式数据库中各个节点可以通过分布式一致性协议,确定数据中各个待定事务的事务日志。在一个例子中,例如可以确定一系列的日志值V1,V2...Vx...Vn,其中每个值可以代表一条具体事务日志的内容。在一条事务日志确定的过程中,通常可以由其中的一个节点作为主节点。用户把该事务的数据写到这个主节点中生成事务日志,然后再由这个主节点通过网络将事务日志发送到其他各个从节点,等待并根据其他各个从节点的共识反馈,确定该条事务日志是否被执行(也就是确定是否执行该条事务)。但是,当同一时间段内事务发生量很大或写入事务的数据量很大时,事务日志的传输需要消耗很大的网 络带宽。然而,不同节点之间的网络带宽常常是不一样的。例如,一般来说地理分布较近的节点之间(例如在同一城市或者临近的城市)带宽通常会比较高,而地理分布较远的节点之间的带宽通常会比较低。现有的分布式数据库方案在事务的共识过程中,对于各个节点同等对待,即主节点会给各个从节点发送需要共识的事务日志,然后等待各个从节点返回的响应。这样,由于一些与主节点较远的从节点,与主节点间没有足够的带宽,在事务流量大的时候就会导致两者之间事务日志传输和响应的速度下降,进而导致整个数据库的数据共识效率的下降,乃至造成整个数据库系统的数据处理能力出现瓶颈。
发明人为了解决上述技术方案存在的问题,在本说明书中的实施例中,提出一种分布式数据库中数据库节点之间达成数据一致的方法。其核心思想是,可以根据节点间的网络带宽状况,将数据库节点划分为普通节点(或称第一节点)和异步节点(或称第二节点)。其中,普通节点(或称第一节点)用于基于分布式一致性协议确定事务数据,异步节点(或称第二节点)用于在事务数据被确定后从普通节点以异步方式获取事务数据,从而可以仅通过通常带宽状态较好的普通节点进行事务数据的确定,然后再由普通节点将确定后的事务数据异步发送给异步节点。由于异步数据发送可以例如避开业务高峰期进行,因此可以避免在业务高峰期因为部分节点的带宽状况不好,而导致分布式数据库中整个数据共识效率的下降。
图2示出一种分布式数据库中数据库节点之间达成数据一致的方法的示意图。如上图2所示,分布式数据库有5个节点,分别是节点A、B、C、D、E。其中A,B例如放置在上海,C,D例如放置在杭州,E节点放置在深圳。假定上海和杭州之间的网络带宽比较大,而上海、杭州分别和深圳之间的网络带宽比较小。如果A节点是主节点,事务开始从A节点写入,然后A把事务日志同步给其他节点。如前所述,由于通常根据分布式一致性协议,只需把事务日志同步到大多数(即超过半数,3个或3个以上)节点就可以满足数据库整体的数据一致性要求,所以节点A只需要把事务日志先发送给上海和杭州的节点,然后根据它们的反馈确定该事务日志即可以满足数据一致性要求。而深圳的节点E则可以作为异步节点,即节点E无需参与该事务日志的确定,进而A点可以将事务日志确定后,以异步方式发送给节点E。而事务日志确定后的具体的发送时间,则可以基于预设的时间规则或网络状态判断条件确定。例如,可以不在业务高峰期、或在事务日志流量低于预定阈值时,发送事务数据给节点E,从而不会影响整个数据库系统的事务处理速度或事务吞吐量。
下面进一步阐述该方法的具体过程。
图3示出根据本说明书实施例的一种分布式数据库的节点配置方法的流程图。如图3所示,该方法至少包括如下步骤:
在步骤31,从分布式数据库的N个节点中,确定出第一数量的第一节点,所述第一数量为大于N/2的整数,第一节点之间基于分布式一致性协议确定第一事务。
分布式数据库,通常是具备分布式事务处理能力、可平滑扩展、分布于计算机网络且逻辑上统一的数据库,其保存的数据在物理上则可以分别存储在不同的数据库节点上。事 务(transaction),是访问或操作数据库中的数据项的数据操作的集合,该数据操作集合要么全部执行,要么全部不执行。通常,对于分布式事务数据库而言,所有的数据操作均会被封装到事务内进行处理,或者说,所有的数据访问均是通过提交事务来进行。不同的实施例中,所述分布式数据库可以是不同具体类型的分布式数据库,本说明书对此不做限制。在不同的实施例中,分布式数据库的节点可以是基于物理节点、虚拟机节点或容器节点中的一种或多种的存储节点。
如上所述,该步骤中,确定出的第一节点可以根据分布式一致性协议确定数据库事务。在不同的实施例中,可以根据不同的具体方式,从分布式数据库的节点中确定第一节点,本说明书对此不做限制。在一个实施例中,可以根据所述分布式数据库的网络拓扑结构和/或所述N个节点之间的网络带宽,从所述N个节点中,确定出第一数量的第一节点。在不同的实施例中,第一节点之间也可以采用不同的具体方式确定数据库事务。例如,在一个实施例中,所述第一节点之间,可以基于分布式一致性协议,确定针对第一事务的事务日志。进而,各第一节点可以根据已确定的所述事务日志,确定要执行的第一事务。
在步骤32,以所述N个节点中,第一节点以外的部分或全部节点,作为异步节点。
该步骤中,异步节点(即图3中第二节点),用于至少一个第一节点将第一事务,通过异步方式发送到异步节点。这里所谓的异步方式,是指第二节点不参与第一事务的共识过程,并可以在第一事务通过共识过程被确定后,从第一节点获取第一事务。在不同的实施例中,从第一节点以外的节点中,可以根据不同的具体方式确定出异步节点,本说明书对此不做限制。例如,可以根据第一节点以外的节点,与各第一节点之间的网络带宽,从第一节点以外的节点确定出异步节点。在不同的实施例中,在第一事务被确定后,将其发送到第二节点的具体时间也可以基于不同的具体方式确定。在一个实施例中,所述具体时间可以基于预设的时间规则或网络状态判断条件确定。
在上述通过事务日志确定事务的实施例中,至少一个第一节点可以将所述事务日志,通过异步方式发送到异步节点。
根据一种实施方式,在当前部分数据库节点不可用时(通常其数量不能多于总节点数的1/2)。为了进一步加快系统的事务共识效率,可以由当前的可用节点重新确定数据库系统的成员节点,将当前的不可用节点至少暂时排除在数据库成员节点之外,并根据新的成员节点确定第一节点和异步节点。图4示出根据本说明书另一实施例的一种分布式数据库的节点配置方法的示意图。如图4所示,例如当上海的节点A、B均不可用时,节点C、D、E可以变更数据库的成员节点(或称有效节点,即当前数据库中可有效运作的节点),把成员节点数从5个变更为3个(即N由5变为3),并选择其中一个节点做为主节点,此时事务日志份数也由5份降低到3份,其中,选举主节点和变更成员节点均要在节点C、D、E之间达成一致。然后,可以在C、D、E中确定出不多于N/2(注意,此时N为3)的异步节点。如图4所示中,例如D节点为主节点,节点E为异步节点。
在一些应用场景下,部分数据库节点的带宽条件非常低下,为了进一步降低这些节点 对于数据库事务共识效率的响应,可以将这些节点设置为选举节点,所述选举节点无需参与事务的确定过程,也无需在事务的确定后从其他节点接收事务。选举节点只需要参与确定第一节点,以及例如参与确定数据库成员节点变更、或参与选举主节点。因此,其只需要接收或发送与数据库成员节点变更、或选举主节点相关的信息(例如paxos协议的prepare信息)。所以选举节点发送或接收的数据量非常小,可以极大的减少其对于网络带宽的消耗。图5示出根据本说明书又一实施例的一种分布式数据库的节点配置方法的流程图。如图5所示,该方法至少包括如下步骤:
在步骤51,从分布式数据库的N个节点中,确定出第一数量的第一节点,所述第一节点中包括用于同步事务的主节点,所述第一数量为大于N/2的整数,所述第一节点之间基于分布式一致性协议确定第一事务。
如上所述,该步骤中,确定出的第一节点可以根据分布式一致性协议确定数据库事务,且第一节点中包括用于同步事务的主节点。在不同的实施例中,可以根据不同的具体方式,从分布式数据库的节点中确定第一节点,本说明书对此不做限制。在一个实施例中,可以根据所述分布式数据库的网络拓扑结构和/或所述N个节点之间的网络带宽,从所述N个节点中,确定出第一数量的第一节点。
在步骤52,以所述N个节点中,第一节点以外的部分或全部节点,作为选举节点。
如上所述,第一节点中可以包括主节点。该步骤中,选举节点,可以用于变更数据库中的主节点,即重新确定第一节点中的主节点。在一个实施例中,选举节点还可以用于确定数据库成员节点的变更,即重新确定数据库中的有效节点(或称成员节点)。图6示出根据本说明书又一实施例的一种分布式数据库的节点配置方法的示意图。如上图6所示,例如当深圳的节点E网络带宽低于预先设置的带宽条件时,可以将节点E设置为选举节点,即节点E无需参与数据库事务日志的确定,也无需接收数据库事务日志,而只需参与确定数据库成员节点的或主节点的变更。设置选举节点不仅节约了网络带宽,还进一步节约了该节点的其他系统资源,例如cpu、内存和磁盘等。因此,在一个实施例中,可以根据第一节点以外的节点,与各第一节点之间的网络带宽,从中确定出选举节点。在另一个实施例中,也可以根据第一节点以外的节点的计算资源,从中确定出选举节点。在一个实施例中,还可以结合第一节点以外节点的网络带宽和计算资源,从中确定出选举节点。
图7示出根据本说明书再一实施例的一种分布式数据库的节点配置方法的流程图。如图7所示,该方法至少包括如下步骤:
在步骤71,从分布式数据库的N个节点中,确定出第一数量的第一节点,所述第一节点中包括用于同步事务的主节点,所述第一数量为大于N/2的整数,所述第一节点之间基于分布式一致性协议确定第一事务;
该步骤的操作类似于步骤51,对其的详细描述参见对于步骤51的描述,这里不再赘述。
在步骤72,以所述N个节点中,第一节点以外的第一部分的节点,作为异步节点,第 一节点以外的第二部分的节点,作为选举节点,其中,所述异步节点用于通过异步方式从所述主节点接收所述第一事务,所述选举节点至少用于更改所述第一节点中的主节点。
该步骤中,确定出异步节点和选举节点的方式,类似于步骤32和步骤52确定出异步节点和选举节点的方式,对其的详细描述参见对于步骤32和步骤52的描述,这里不再赘述。在一个实施例中,N个节点可以为分布式数据库中的N个有效节点;第三节点还可以用于重新确定所述分布式数据库中的有效节点。
图8示出根据本说明书再一实施例的一种分布式数据库的节点配置方法的示意图。如图8所示,可以在分布式数据库系统中,设置异步节点和选举节点,其总数量限制为少于1/2的总节点数(即少于N/2)。在此限制范围内,不同的实施例中,可以异步节点和选举节点之间的比例可以不同,本说明书对此不作限制。例如图8中所示中,例如节点A、B、C、D、E任意两个节点,可以设置为异步节点、或者选举节点或者两者的组合。
图9示出根据本说明书实施例的一种分布式数据库的事务日志同步方法的流程图。如图9所示,该方法至少包括如下步骤:
在步骤91,从分布式数据库的N个节点中,确定出第一数量的第一节点,所述第一数量为大于N/2的整数,所述第一节点中包括用于同步事务的主节点,所述第一节点之间基于分布式一致性协议,确定针对第一事务的事务日志;
在步骤92,以N个节点中,第一节点以外的第一部分的节点,作为异步节点,第一节点以外的第二部分的节点,作为选举节点,其中,异步节点用于通过异步方式从主节点接收所述第一事务,选举节点至少用于更改第一节点中的主节点。
在一个实施例中,可以根据所述分布式数据库的网络拓扑结构和/或所述N个节点之间的网络带宽,从所述N个节点中,确定出第一数量的第一节点。
在一个实施例中,所述N个节点为所述分布式数据库中的N个有效节点;选举节点还可以用于重新确定所述分布式数据库中的有效节点。
根据本说明书实施例提供的分布式数据库的节点配置方法、以及事务日志同步方法,具有如下优点:通过在分布式数据库中设置异步节点和/或选举节点,其中,异步节点不参与事务确定、仅在事务确定后通过异步方式接收事务数据,而选举节点则不参与事务确定也不接收事务数据,仅参与数据库成员节点变更、确定事务同步节点或选举主节点,减少分布式数据库了事务同步消耗的网络资源。使得分布式数据库在网络带宽不足的情况下,仍可以基于分布式数据一致性协议进行事务处理,并保证其事务处理速度。
根据另一部分的实施例,还提供一种分布式数据库,该分布式数据库包括N个节点,所述N个节点中包括:
第一数量的第一节点,所述第一节点中包括用于同步事务的主节点,所述第一节点之间基于分布式一致性协议确定第一事务,所述第一数量为大于N/2的整数;
异步节点和/或选举节点,其中,所述异步节点用于通过异步方式从所述主节点接收所述第一事务,所述选举节点至少用于更改所述第一节点中的主节点。
在一个实施例中,N个节点可以为分布式数据库中的N个有效节点;选举节点还还可以用于重新确定所述分布式数据库中的有效节点。
根据又一部分的实施例,还提供又一种分布式数据库,该分布式数据库包括N个节点,所述N个节点中包括:
第一数量的第一节点,所述第一节点中包括用于同步事务的主节点,所述第一节点之间基于分布式一致性协议,确定针对第一事务的事务日志,所述第一数量为大于N/2的整数;
异步节点和/或选举节点,其中,所述异步节点用于通过异步方式从所述主节点接收所述事务日志,所述选举节点至少用于更改所述第一节点中的主节点。
在一个实施例中,N个节点可以为分布式数据库中的N个有效节点;选举节点还还可以用于重新确定所述分布式数据库中的有效节点。
根据另一部分的实施例,还提供一种分布式数据库中的异步节点,所述分布式数据库还包括第一数量的第一节点,所述第一节点之间基于分布式一致性协议确定第一事务,所述第一数量大于N/2,N为所述分布式数据库的有效节点总数。图10示出根据本说明书实施例的一种数据库节点的结构图,如图10所示,该异步节点1000包括:
第一异步接收单元101,配置为,通过异步方式从所述主节点接收第一事务。
根据又一部分的实施例,还提供又一种分布式数据库中的异步节点,所述分布式数据库还包括第一数量的第一节点,所述第一节点之间基于分布式一致性协议,确定针对第一事务的事务日志,所述第一数量大于N/2,N为所述分布式数据库的有效节点总数。图11示出根据本说明书实施例的另一种数据库节点的结构图,如图11所示,该异步节点1100包括:
第二异步接收单元111,配置为,通过异步方式从所述主节点接收针对第一事务的事务日志。
根据另一部分的实施例,还提供一种分布式数据库中的选举节点,所述分布式数据库还包括第一数量的第一节点,所述第一节点中包括用于同步事务的主节点,所述第一节点之间基于分布式一致性协议确定第一事务,所述第一数量大于N/2,N为所述分布式数据库的有效节点总数。图12示出根据本说明书实施例的又一种数据库节点的结构图,如图12所示,该选举节点1200包括:
主节点更改单元121,配置为,用于更改所述第一节点中的主节点。
在一个实施例中,选举节点还可以包括,
有效节点确定单元,配置为,用于重新确定所述分布式数据库中的有效节点。
本说明书另一方面提供一种计算机可读存储介质,其上存储有计算机程序,当所述计算机程序在计算机中执行时,令计算机执行上述任一项方法。
本说明书另一方面提供一种计算设备,包括存储器和处理器,所述存储器中存储有可执行代码,所述处理器执行所述可执行代码时,实现上述任一项方法。
需要理解,本文中的“第一”,“第二”等描述,仅仅为了描述的简单而对相似概念进行区分,并不具有其他限定作用。
本领域技术人员应该可以意识到,在上述一个或多个示例中,本发明所描述的功能可以用硬件、软件、固件或它们的任意组合来实现。当使用软件实现时,可以将这些功能存储在计算机可读介质中或者作为计算机可读介质上的一个或多个指令或代码进行传输。
以上所述的具体实施方式,对本发明的目的、技术方案和有益效果进行了进一步详细说明,所应理解的是,以上所述仅为本发明的具体实施方式而已,并不用于限定本发明的保护范围,凡在本发明的技术方案的基础之上,所做的任何修改、等同替换、改进等,均应包括在本发明的保护范围之内。

Claims (16)

  1. 一种分布式数据库的节点配置方法,包括:
    从分布式数据库的N个节点中,确定出第一数量的第一节点,所述第一节点中包括用于同步事务的主节点,所述第一数量为大于N/2的整数,所述第一节点之间基于分布式一致性协议确定第一事务;
    以所述N个节点中,第一节点以外的部分或全部节点,作为异步节点或选举节点;所述异步节点用于通过异步方式从所述主节点接收所述第一事务,所述选举节点至少用于更改所述第一节点中的主节点。
  2. 根据权利要求1所述的方法,其中,从分布式数据库的N个节点中,确定出第一数量的第一节点,包括:
    根据所述分布式数据库的网络拓扑结构和/或所述N个节点之间的网络带宽,从所述N个节点中,确定出第一数量的第一节点。
  3. 根据权利要求1所述的方法,其中,所述N个节点为所述分布式数据库中的N个有效节点;
    所述选举节点还用于重新确定所述分布式数据库中的有效节点。
  4. 一种分布式数据库的事务日志同步方法,包括:
    从分布式数据库的N个节点中,确定出第一数量的第一节点,所述第一数量为大于N/2的整数,所述第一节点中包括用于同步事务的主节点,所述第一节点之间基于分布式一致性协议,确定针对第一事务的事务日志;
    以所述N个节点中,第一节点以外的部分或全部节点,作为异步节点或选举节点;所述异步节点用于通过异步方式从所述主节点接收所述事务日志,所述选举节点至少用于更改所述第一节点中的主节点。
  5. 根据权利要求4所述的方法,其中,从分布式数据库的N个节点中,确定出第一数量的第一节点,包括:
    根据所述分布式数据库的网络拓扑结构和/或所述N个节点之间的网络带宽,从所述N个节点中,确定出第一数量的第一节点。
  6. 根据权利要求4所述的方法,其中,所述N个节点为所述分布式数据库中的N个有效节点;
    所述选举节点还用于重新确定所述分布式数据库中的有效节点。
  7. 一种分布式数据库,所述分布式数据库包括N个节点,所述N个节点中包括:
    第一数量的第一节点,所述第一节点中包括用于同步事务的主节点,所述第一节点之间基于分布式一致性协议确定第一事务,所述第一数量为大于N/2的整数;
    异步节点和/或选举节点,其中,所述异步节点用于通过异步方式从所述主节点接收所述第一事务,所述选举节点至少用于更改所述第一节点中的主节点。
  8. 根据权利要求7所述的数据库,其中,所述N个节点为所述分布式数据库中的N个有效节点;
    所述选举节点还用于重新确定所述分布式数据库中的有效节点。
  9. 一种分布式数据库,所述分布式数据库包括N个节点,所述N个节点中包括:
    第一数量的第一节点,所述第一节点中包括用于同步事务的主节点,所述第一节点之间基于分布式一致性协议,确定针对第一事务的事务日志,所述第一数量为大于N/2的整数;
    异步节点和/或选举节点,其中,所述异步节点用于通过异步方式从所述主节点接收所述事务日志,所述选举节点至少用于更改所述第一节点中的主节点。
  10. 根据权利要求9所述的数据库,其中,所述N个节点为所述分布式数据库中的N个有效节点;
    所述选举节点还用于重新确定所述分布式数据库中的有效节点。
  11. 一种分布式数据库中的异步节点,所述分布式数据库还包括第一数量的第一节点,所述第一节点之间基于分布式一致性协议确定第一事务,所述第一数量大于N/2,N为所述分布式数据库的有效节点总数,所述异步节点包括:
    第一异步接收单元,配置为,通过异步方式从所述主节点接收第一事务。
  12. 一种分布式数据库中的异步节点,所述分布式数据库还包括第一数量的第一节点,所述第一节点之间基于分布式一致性协议,确定针对第一事务的事务日志,所述第一数量大于N/2,N为所述分布式数据库的有效节点总数,所述异步节点包括:
    第二异步接收单元,配置为,通过异步方式从所述主节点接收针对第一事务的事务日志。
  13. 一种分布式数据库中的选举节点,所述分布式数据库还包括第一数量的第一节点,所述第一节点中包括用于同步事务的主节点,所述第一节点中包括用于同步事务的主节点,所述第一节点之间基于分布式一致性协议确定第一事务,所述第一数量大于N/2,N为所述分布式数据库的有效节点总数,所述选举节点包括:
    主节点更改单元,配置为,用于更改所述第一节点中的主节点。
  14. 根据权利要求13所述的选举节点,还包括,
    有效节点确定单元,配置为,用于重新确定所述分布式数据库中的有效节点。
  15. 一种计算机可读存储介质,其上存储有计算机程序,当所述计算机程序在计算机中执行时,令计算机执行权利要求1-6中任一项的所述的方法。
  16. 一种计算设备,包括存储器和处理器,其特征在于,所述存储器中存储有可执行代码,所述处理器执行所述可执行代码时,实现权利要求1-6中任一项所述的方法。
PCT/CN2023/087009 2022-06-24 2023-04-07 分布式数据库的节点配置方法、事务日志同步方法和节点 WO2023246236A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210724274.XA CN115185961A (zh) 2022-06-24 2022-06-24 分布式数据库的节点配置方法、事务日志同步方法和节点
CN202210724274.X 2022-06-24

Publications (1)

Publication Number Publication Date
WO2023246236A1 true WO2023246236A1 (zh) 2023-12-28

Family

ID=83514464

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/087009 WO2023246236A1 (zh) 2022-06-24 2023-04-07 分布式数据库的节点配置方法、事务日志同步方法和节点

Country Status (2)

Country Link
CN (1) CN115185961A (zh)
WO (1) WO2023246236A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115185961A (zh) * 2022-06-24 2022-10-14 北京奥星贝斯科技有限公司 分布式数据库的节点配置方法、事务日志同步方法和节点

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7617369B1 (en) * 2003-06-30 2009-11-10 Symantec Operating Corporation Fast failover with multiple secondary nodes
CN104679796A (zh) * 2013-12-03 2015-06-03 方正信息产业控股有限公司 一种选举方法、装置及数据库镜像集群节点
CN106991113A (zh) * 2015-12-18 2017-07-28 Sap欧洲公司 数据库环境中的表格复制
CN108090222A (zh) * 2018-01-05 2018-05-29 中国科学院计算技术研究所 一种数据库集群节点间数据同步系统
CN112015744A (zh) * 2020-08-18 2020-12-01 广州市百果园信息技术有限公司 配置数据访问方法、装置、设备、配置中心及存储介质
US20210209131A1 (en) * 2020-01-07 2021-07-08 YottaChain Foundation Ltd. Method for Data Synchronization of Multiple Nodes and Computer Device
CN114461438A (zh) * 2022-04-12 2022-05-10 北京易鲸捷信息技术有限公司 非对称中心模式的分布式数据库容灾系统及方法
CN115185961A (zh) * 2022-06-24 2022-10-14 北京奥星贝斯科技有限公司 分布式数据库的节点配置方法、事务日志同步方法和节点

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7617369B1 (en) * 2003-06-30 2009-11-10 Symantec Operating Corporation Fast failover with multiple secondary nodes
CN104679796A (zh) * 2013-12-03 2015-06-03 方正信息产业控股有限公司 一种选举方法、装置及数据库镜像集群节点
CN106991113A (zh) * 2015-12-18 2017-07-28 Sap欧洲公司 数据库环境中的表格复制
CN108090222A (zh) * 2018-01-05 2018-05-29 中国科学院计算技术研究所 一种数据库集群节点间数据同步系统
US20210209131A1 (en) * 2020-01-07 2021-07-08 YottaChain Foundation Ltd. Method for Data Synchronization of Multiple Nodes and Computer Device
CN112015744A (zh) * 2020-08-18 2020-12-01 广州市百果园信息技术有限公司 配置数据访问方法、装置、设备、配置中心及存储介质
CN114461438A (zh) * 2022-04-12 2022-05-10 北京易鲸捷信息技术有限公司 非对称中心模式的分布式数据库容灾系统及方法
CN115185961A (zh) * 2022-06-24 2022-10-14 北京奥星贝斯科技有限公司 分布式数据库的节点配置方法、事务日志同步方法和节点

Also Published As

Publication number Publication date
CN115185961A (zh) 2022-10-14

Similar Documents

Publication Publication Date Title
Wiesmann et al. Comparison of database replication techniques based on total order broadcast
EP2954424B1 (en) Method, device, and system for peer-to-peer data replication and method, device, and system for master node switching
CN112597251B (zh) 数据库集群日志同步方法、装置、服务器及存储介质
US20040153473A1 (en) Method and system for synchronizing data in peer to peer networking environments
US8639786B2 (en) Consistency domains for replication in distributed computing
US20100114824A1 (en) Replication for common availability substrate
Cassell et al. Nessie: A decoupled, client-driven key-value store using RDMA
US11210277B2 (en) Distributing and processing streams over one or more networks for on-the-fly schema evolution
CN104361030A (zh) 一种具有任务分发功能的分布式缓存架构及缓存方法
WO2023246236A1 (zh) 分布式数据库的节点配置方法、事务日志同步方法和节点
WO2019103950A1 (en) Multi-region, multi-master replication of database tables
JP2023503120A (ja) ブロックチェーンにおけるコンセンサスノードの動的増加方法及び装置
WO2022111188A1 (zh) 事务处理方法、系统、装置、设备、存储介质及程序产品
WO2016065776A1 (zh) 一种紧耦合可扩展的大数据交互方法
WO2021036684A1 (zh) 分布式数据同步方法、装置、设备及可读存储介质
WO2023082992A1 (zh) 数据处理方法以及系统
US10776012B2 (en) Lock-free datapath design for efficient parallel processing storage array implementation
Camargos et al. Multicoordinated paxos
US9311379B2 (en) Utilization of data structures to synchronize copies of a resource
WO2024103898A1 (zh) 数据库集群管理的方法和装置
WO2024037239A1 (zh) 一种加速器调度方法及相关装置
CN116069262B (zh) 一种分布式存储卸载方法、装置、电子设备及存储介质
CN111209263A (zh) 数据存储方法、装置、设备及存储介质
WO2022133656A1 (zh) 一种数据处理装置、方法及相关设备
WO2021237704A1 (zh) 数据同步方法及相关装置

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 23825891

Country of ref document: EP

Kind code of ref document: A1