WO2017080257A1 - 一种基于键值对的数据处理方法及系统 - Google Patents

一种基于键值对的数据处理方法及系统 Download PDF

Info

Publication number
WO2017080257A1
WO2017080257A1 PCT/CN2016/091942 CN2016091942W WO2017080257A1 WO 2017080257 A1 WO2017080257 A1 WO 2017080257A1 CN 2016091942 W CN2016091942 W CN 2016091942W WO 2017080257 A1 WO2017080257 A1 WO 2017080257A1
Authority
WO
WIPO (PCT)
Prior art keywords
node
key
key value
module
database
Prior art date
Application number
PCT/CN2016/091942
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 WO2017080257A1 publication Critical patent/WO2017080257A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • 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/28Databases characterised by their database models, e.g. relational or object models
    • 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/2228Indexing structures
    • G06F16/2255Hash tables

Definitions

  • the present invention belongs to the field of data storage technologies, and in particular, to a data processing method and system based on key value pairs.
  • Redis Database Redis is a high-performance key-value database, also known as non-relational database, which supports master-slave synchronization. Data can be synchronized from the primary server to any number of slave servers. The slave server can be associated with other servers. From the server's primary server, this allows Redis to perform single-tier tree replication.
  • the emergence of Redis data database to a large extent compensate for the lack of relational database storage, in some cases can complement the relational database. With the rise of the Internet web2.0 website, Redis has become a very hot new field, and the development of non-relational database products is also very rapid. However, at present, the data processing mode of the source database Redis is generally single-process processing.
  • the server When receiving the operation command sent by the client, the server can only process the operation command sent by the client through the queue, and cannot use the multi-core of the processor.
  • the advantages are concurrent processing, and the single-core processing capability is limited, thus making the data processing performance of the source database Redis low.
  • the server when deploying a database, due to the performance bottleneck of a single database instance, it is generally necessary to deploy multiple database instances to achieve business performance requirements. This requires a large amount of time and manpower to monitor and operate the database. The burden of database management.
  • An object of the embodiments of the present invention is to provide a data processing method and system based on a key value pair, which aims to solve the low data processing performance of the above-mentioned resource database Redis, and requires a large amount of time and human resources to be used in the database. Monitoring and operation and maintenance have increased the burden of database management.
  • a data processing method based on a key value pair includes:
  • any node in the server cluster receives a database key command sent by the client; [0006] The node calculates a hash slot corresponding to the key value carried in the database key command, and determines whether the hash slot is responsible for itself;
  • the node If not, the node returns a prompt information of the moved error to the client, so that the client turns to the correct node in the server cluster according to the prompt information.
  • the method before any node in the server cluster receives the database key command sent by the client, the method further includes:
  • the prompt information includes a node name to which the hash slot corresponding to the key value is assigned.
  • the hash slot corresponding to the key value carried in the database key command is:
  • the node uses a cluster using the formula CRC16(key) % 16384 to calculate a hash slot corresponding to the key value.
  • CRC16 (key) statement is used to calculate the CRC16 checksum of the key value.
  • the database key command includes a get command, a set command, a del command, and an hget command.
  • Another object of the embodiments of the present invention is to provide a data processing system based on a key value pair, including a receiving module, a computing module, a determining module, an executing module, and a prompting module located inside a node in a server cluster, and the receiving The module, the computing module, the determining module, and the executing module are sequentially connected, and the determining module is further connected to the prompting module, where:
  • the receiving module is configured to receive a database key command sent by the client
  • the calculation module is configured to calculate a hash slot corresponding to the key value carried in the database key command
  • the determining module is configured to determine whether the hash slot is responsible for the node
  • the execution module is configured to execute the database key command if the node is responsible
  • the prompting module is configured to return, to the client, prompt information of a lost error, if the node is not responsible for the move, to cause the client to switch to the correct section in the server cluster according to the prompt information.
  • the data processing system based on the key value pair according to the embodiment of the present invention further includes an allocation module connected to the node in the server cluster, and the inside of the node and the allocation module and the determining Module connected to the storage module, where:
  • the allocating module is configured to respectively assign multiple hash slots in the server cluster to each node in the server cluster;
  • the storage module is configured to store assignment information of the multiple hash slots.
  • the prompt information includes a node name to which the hash slot corresponding to the key value is assigned.
  • the calculation module is specifically used to calculate the data processing system based on the key value pair in the embodiment of the present invention.
  • the cluster is calculated using the formula CRC16(key) % 16384
  • the database key command includes a get command, a set command, a del command, and an hget command.
  • the database key command sent by the client is received by any node in the server cluster.
  • the node calculates the hash slot corresponding to the key value carried in the database key command. And determining whether the hash slot is responsible for itself; if yes, the node executes the database key command; if not, the node returns a prompt message of the moved error to the client, so that the client According to the prompt information, the data is redirected to the correct node in the server cluster, so that the resource database Redis can utilize the multi-core advantage of the processor for concurrent processing, thereby improving the processing performance of the database, so that only one database instance can be deployed to achieve the service. Performance indicators reduce the deployment of database instances and reduce the burden of database management.
  • FIG. 1 is a flowchart of a specific implementation of a data processing method based on a key value pair according to an embodiment of the present invention
  • FIG. 2 is a structural block diagram of a data processing system based on a key value pair according to an embodiment of the present invention
  • FIG. 3 is a structural block diagram of a data processing system based on a key value pair according to another embodiment of the present invention.
  • FIG. 1 shows a specific implementation flow of a data processing method based on a key value pair according to an embodiment of the present invention.
  • a data processing method based on a key value pair includes:
  • any node in the server cluster receives a database key command sent by the client.
  • the method before any node in the server cluster receives the database key command sent by the client, the method further includes: assigning multiple hash slots in the server cluster to the server cluster respectively Each node, and assigning the assignment information of the plurality of hash slots to each node in the server cluster. Further, each hash slot in the server cluster can only be assigned to one node, but each node can be responsible for processing multiple hash slots.
  • the node calculates a hash slot corresponding to the key value carried in the database key command, and determines whether the hash slot is responsible for itself.
  • the server cluster of the database includes 16384 hash slots, and each key value in the database belongs to one of the 16384 hash slots.
  • the node After receiving the data key command sent by the client, the node parses the data key command to obtain a key value carried in the data key command, and then calculates a hash slot corresponding to the key value. And determine whether the hash slot is responsible for itself.
  • the hash slot corresponding to the key value carried in the database key command includes: the node uses the cluster CRC16 (key) % 16384 to calculate the hash corresponding to the key value.
  • determining whether the hash slot is responsible for itself specifically includes: a hash slot and a location according to the calculation
  • the assignment information of the plurality of hash slots pre-stored in the node is used to find the node name to which the hash slot corresponding to the key value is assigned, and determine whether the node name is the same as the node name stored by itself, if the same, The hash slot corresponding to the key value is responsible for itself; on the contrary, the hash slot corresponding to the key value is not responsible for itself.
  • the database key command is executed.
  • the database key command includes but is not limited to a get command, a set command, a del command, and an hget command.
  • the node if not, the node returns a prompt information of the moved error to the client, so that the client turns to the correct node in the server cluster according to the prompt information.
  • the prompt information includes a node name to which the hash slot corresponding to the key value is assigned.
  • the node returns the prompt information of the lost error to the client, and the redirecting the client to the correct node in the server cluster according to the prompt information includes: if the hash slot corresponding to the key value is not
  • the node is responsible for, the node automatically generates prompt information of the moved error according to the node name assigned by the hash slot corresponding to the key value, and returns the prompt information to the client, so that the client The terminal switches to the correct node in the server cluster according to the node name assigned by the hash slot corresponding to the key value in the prompt information.
  • the data processing method based on the key value pair receives the database key command sent by the client by any node in the server cluster first; and then calculates by the node Determining, by the database key command, a hash slot corresponding to the key value, and determining whether the hash slot is responsible for itself; if yes, the node executes the database key command; if not, the node is The client returns the prompt information of the lost error, so that the client turns to the correct node in the server cluster according to the prompt information, so that the resource database Redis can utilize the multi-core advantage of the processor for concurrent processing, and the database is improved.
  • the processing performance makes it possible to deploy a database instance to achieve business performance indicators, reduce the deployment of database instances, and reduce the burden of database management.
  • FIG. 2 is a structural block diagram of a data processing system based on a key value pair according to an embodiment of the present invention, which is used to run the method provided in the embodiment shown in FIG. 1.
  • FIG. 2 For the convenience of description, only the implementation of the present invention is shown. The relevant part of the case.
  • a data processing system based on a key value pair includes a receiving module 1, a computing module 2, a determining module 3, an executing module 4, and a node located in a node in a server cluster.
  • the prompting module 5, the receiving module 1, the calculating module 2, the determining module 3, and the executing module 4 are sequentially connected, and the determining module 3 is further connected to the prompting module 5, wherein:
  • the receiving module 1 is configured to receive a database key command sent by a client
  • the calculation module 2 is configured to calculate a hash slot corresponding to the key value carried in the database key command;
  • the determining module 3 is configured to determine whether the hash slot is responsible by the node
  • the execution module 4 is configured to execute the database key command if the node is responsible;
  • the prompting module 5 is configured to return, to the client, prompt information of a lost error if not responsible by the node, so that the client turns to the correct one in the server cluster according to the prompt information. node.
  • the data processing system based on the key value pair further includes an allocating module 6 connected to the node in the server cluster, and the inside of the node, the distribution module 6 and the determining module. 3 connected storage modules 7, where:
  • the allocating module 6 is configured to respectively assign multiple hash slots in the server cluster to each node in the server cluster;
  • the storage module 7 is configured to store assignment information of the multiple hash slots.
  • the prompt information includes a node name to which the hash slot corresponding to the key value is assigned.
  • the calculating module 2 is specifically configured to:
  • the cluster is calculated using the formula CRC16(key) % 16384
  • the database key command includes a get command, a set command, a del command, and an hget command.
  • the data processing system based on the key value pair provided by the embodiment of the present invention can also make
  • the Redis database Redis can take advantage of the processor's multi-core advantages for concurrent processing, improve the processing performance of the database, and reduce the deployment of database instances, reducing the burden of database management.
  • FIG. 3 is a structural block diagram of a data processing system based on a key value pair according to another embodiment of the present invention.
  • the system is used to run the method provided by the embodiment shown in Figure 1 above. Only the parts related to the present embodiment are shown for convenience of explanation.
  • the embodiment provides a data processing system based on a key value pair, including:
  • processor 310 communication interface 320, memory
  • bus 340 (memory) 330, bus 340.
  • the processor 310, the communication interface 320, and the memory 330 complete communication with each other through the bus 340.
  • the communication interface 320 is configured to communicate with an external device, such as a personal computer, a server, or the like.
  • the processor 310 is configured to execute the program 331.
  • the program 331 may include program code, the program code including computer operation instructions.
  • the processor 310 may be a central processing unit CPU, or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement embodiments of the present invention.
  • CPU central processing unit
  • ASIC application specific integrated circuit
  • the memory 330 is configured to store the program 331.
  • the memory 330 may include a high speed RAM memory and may also include a non-volatile memory such as at least one disk memory.
  • the program 331 may specifically include:
  • the receiving module 1 is configured to receive a database key command sent by the client;
  • the calculation module 2 is configured to calculate a hash slot corresponding to the key value carried in the database key command
  • the determining module 3 is configured to determine whether the hash slot is responsible by the node
  • an execution module 4 configured to execute the database key command if the node is responsible
  • the prompting module 5 is configured to return, to the client, the prompt information of the moved error, if the node is not responsible for the node, so that the client turns to the correct node in the server cluster according to the prompt information.
  • the disclosed systems, devices, and methods can be implemented in other ways.
  • the device embodiments described above are merely illustrative.
  • the division of the unit is only a logical function division, and the actual implementation may have another division manner, for example, multiple units or components may be combined or Can be integrated into another system, or some features can be ignored, or not executed.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some communication interface, device or unit, and may be in an electrical, mechanical or other form.
  • the unit described as a separate component may or may not be physically distributed, and the component displayed as a unit may or may not be a physical unit, that is, may be located in one place, or may be distributed to multiple On the network unit. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
  • each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
  • the functions, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium.
  • the technical solution of the present invention which is essential or contributes to the prior art, or a part of the technical solution, may be embodied in the form of a software product, which is stored in a storage medium, including
  • the instructions are used to cause a computer device (which may be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present invention.
  • the foregoing storage medium includes: u disk
  • RAM random access memory
  • disk disk or optical disk, and other media that can store program code.

Abstract

一种基于键值对的数据处理方法及系统,属于数据存储技术领域。该方法包括:服务器集群中的任一节点接收客户端发送的数据库键命令;节点计算数据库键命令中携带的key值所对应的哈希槽,并判断哈希槽是否由自己负责;若是,则节点执行数据库键命令;若否,则节点向客户端返回moved错误的提示信息,使客户端根据提示信息转向服务器集群中正确的节点,其能够使开源数据库Redis可以利用处理器的多核优势进行并发处理,提升了数据库的处理性能,并且可以减少数据库实例的部署,减轻数据库管理的负担。

Description

一种基于键值对的数据处理方法及系统 技术领域
[0001] 本发明属于数据存储技术领域, 尤其涉及一种基于键值对的数据处理方法及系 统。
背景技术
[0002] 幵源数据库 Redis是一个高性能的键值对数据库, 也称非关系型数据库, 它支 持主从同步, 数据可以从主服务器向任意数量的从服务器上同步, 从服务器可 以是关联其他从服务器的主服务器, 这使得 Redis可执行单层树复制。 幵源数据 库 Redis的出现, 很大程度补偿了关系型数据库存储的不足, 在部分场合可以对 关系型数据库起到很好的补充作用。 随着互联网 web2.0网站的兴起, 幵源数据库 Redis已经成了一个极其热门的新领域, 非关系型数据库产品的发展也非常迅速 。 但是, 目前幵源数据库 Redis的数据处理方式一般为单进程处理, 当接收到客 户端发送的操作命令吋, 服务器端只能通过队列的方式处理客户端发送的操作 命令, 无法利用处理器的多核优势进行并发处理, 而单核处理能力有限, 因此 使得幵源数据库 Redis的数据处理性能较低。 此外, 目前在部署数据库吋, 由于 单个数据库实例性能瓶颈的问题, 一般需要部署多个数据库实例才能达到业务 性能需求, 这样就需要投入大量的吋间和人力对数据库进行监控和运维, 增加 了数据库管理的负担。
技术问题
[0003] 本发明实施例的目的在于提供一种基于键值对的数据处理方法及系统, 旨在解 决上述幵源数据库 Redis的数据处理性能较低, 并且需要投入大量的吋间和人力 对数据库进行监控和运维, 增加了数据库管理的负担的问题。
问题的解决方案
技术解决方案
[0004] 本发明实施例是这样实现的, 一种基于键值对的数据处理方法, 包括:
[0005] 服务器集群中的任一节点接收客户端发送的数据库键命令; [0006] 所述节点计算所述数据库键命令中携带的 key值所对应的哈希槽, 并判断所述 哈希槽是否由自己负责;
[0007] 若是, 则所述节点执行所述数据库键命令;
[0008] 若否, 则所述节点向所述客户端返回 moved错误的提示信息, 使所述客户端根 据所述提示信息转向所述服务器集群中正确的节点。
[0009] 在本发明实施例所述的基于键值对的数据处理方法中, 在服务器集群中的任一 节点接收客户端发送的数据库键命令之前还包括:
[0010] 将所述服务器集群中的多个哈希槽分别指派给所述服务器集群中的各个节点, 并将所述多个哈希槽的指派信息存储至所述服务器集群中的每个节点。
[0011] 在本发明实施例所述的基于键值对的数据处理方法中, 所述提示信息包括所述 key值所对应的哈希槽被指派的节点名称。
[0012] 在本发明实施例所述的基于键值对的数据处理方法中, 所述节点计算所述数据 库键命令中携带的 key值所对应的哈希槽具体包括:
[0013] 所述节点采用集群使用公式 CRC16(key) % 16384来计算 key值所对应的哈希槽
, 其中, CRC16(key)语句用于计算 key值的 CRC16校验和。
[0014] 在本发明实施例所述的基于键值对的数据处理方法中, 所述数据库键命令包括 get命令、 set命令、 del命令和 hget命令。
[0015] 本发明实施例的另一目的在于提供一种基于键值对的数据处理系统, 包括位于 服务器集群中节点内部的接收模块、 计算模块、 判断模块、 执行模块以及提示 模块, 所述接收模块、 所述计算模块、 所述判断模块以及所述执行模块依次连 接, 所述判断模块还与所述提示模块连接, 其中:
[0016] 所述接收模块, 用于接收客户端发送的数据库键命令;
[0017] 所述计算模块, 用于计算所述数据库键命令中携带的 key值所对应的哈希槽;
[0018] 所述判断模块, 用于判断所述哈希槽是否由所述节点负责;
[0019] 所述执行模块, 用于若是由所述节点负责, 则执行所述数据库键命令;
[0020] 所述提示模块, 用于若不是由所述节点负责, 则向所述客户端返回 moved错误 的提示信息, 使所述客户端根据所述提示信息转向所述服务器集群中正确的节 [0021] 在本发明实施例所述的基于键值对的数据处理系统中, 还包括与所述服务器集 群中的节点相连的分配模块和位于所述节点内部与所述分配模块和所述判断模 块连接的存储模块, 其中:
[0022] 所述分配模块, 用于将所述服务器集群中的多个哈希槽分别指派给所述服务器 集群中的各个节点;
[0023] 所述存储模块, 用于存储所述多个哈希槽的指派信息。
[0024] 在本发明实施例所述的基于键值对的数据处理系统中, 所述提示信息包括所述 key值所对应的哈希槽被指派的节点名称。
[0025] 在本发明实施例所述的基于键值对的数据处理系统中, 所述计算模块具体用于
[0026] 采用集群使用公式 CRC16(key) % 16384来计算
key值所对应的哈希槽, 其中, CRC16(key)语句用于计算 key值的 CRC16校验 和。
[0027] 在本发明实施例所述的基于键值对的数据处理系统中, 所述数据库键命令包括 get命令、 set命令、 del命令和 hget命令。 发明的有益效果
有益效果
[0028] 实施本发明实施例提供的基于键值对的数据处理方法及系统具有以下有益效果
[0029] 本发明实施例由于首先采用的由服务器集群中的任一节点接收客户端发送的数 据库键命令; 然后由所述节点计算所述数据库键命令中携带的 key值所对应的哈 希槽, 并判断所述哈希槽是否由自己负责; 若是, 则所述节点执行所述数据库 键命令; 若否, 则所述节点向所述客户端返回 moved错误的提示信息, 使所述客 户端根据所述提示信息转向所述服务器集群中正确的节点, 从而使得幵源数据 库 Redis可以利用处理器的多核优势进行并发处理, 提升了数据库的处理性能, 使得只需部署一个数据库实例即可达到业务性能指标, 减少了数据库实例的部 署, 减轻了数据库管理的负担。
对附图的简要说明 附图说明
[0030] 图 1是本发明实施例提供的基于键值对的数据处理方法的具体实现流程图; [0031] 图 2是本发明实施例提供的基于键值对的数据处理系统的结构框图;
[0032] 图 3是本发明另一实施例提供的基于键值对的数据处理系统的结构框图。
本发明的实施方式
[0033] 为了使本发明的目的、 技术方案及优点更加清楚明白, 以下结合附图及实施例 , 对本发明进行进一步详细说明。 应当理解, 此处所描述的具体实施例仅仅用 以解释本发明, 并不用于限定本发明。
[0034] 图 1示出了本发明实施例提供的基于键值对的数据处理方法的具体实现流程。
参见图 1所示, 本发明实施例提供的一种基于键值对的数据处理方法, 包括:
[0035] 在 S101中, 服务器集群中的任一节点接收客户端发送的数据库键命令。
[0036] 在本发明实施例中, 在服务器集群中的任一节点接收客户端发送的数据库键命 令之前还包括: 将所述服务器集群中的多个哈希槽分别指派给所述服务器集群 中的各个节点, 并将所述多个哈希槽的指派信息存储至所述服务器集群中的每 个节点。 进一步的, 服务器集群中的每个哈希槽只能对应指派给一个节点, 但 是每个节点均可对应负责处理多个哈希槽。
[0037] 在 S102中, 所述节点计算所述数据库键命令中携带的 key值所对应的哈希槽, 并判断所述哈希槽是否由自己负责。
[0038] 在本发明实施例中, 数据库的服务器集群中包括有 16384个哈希槽 (hash slot) , 数据库中的每个 key值都属于这 16384个哈希槽的其中一个。 所述节点在接收 到客户端发送的数据键命令后, 会对所述数据键命令进行解析, 以获取所述数 据键命令中携带的 key值, 然后计算所述 key值所对应的哈希槽, 并判断所述哈希 槽是否由自己负责。
[0039] 其中, 所述节点计算所述数据库键命令中携带的 key值所对应的哈希槽具体包 括: 所述节点采用集群使用公式 CRC16(key) % 16384来计算 key值所对应的哈希 槽, 其中, CRC16(key)语句用于计算 key值的 CRC16校验和。
[0040] 其中, 判断所述哈希槽是否由自己负责具体包括: 根据计算得出的哈希槽和所 述节点中预先存储的多个哈希槽的指派信息査找所述 key值所对应的哈希槽被指 派的节点名称, 判断所述节点名称是否与自身存储的节点名称相同, 若相同, 则说明所述 key值所对应的哈希槽是由自己负责; 反之, 所述 key值所对应的哈希 槽不是由自己负责的。
[0041] 在 S103-1中, 若是, 则所述节点执行所述数据库键命令。
[0042] 在本发明实施例中, 若所述节点判断出所述 key值所对应的哈希槽是由自己负 责的, 则执行所述数据库键命令。 其中, 所述数据库键命令包括但不限于 get命 令、 set命令、 del命令和 hget命令。
[0043] 在 S103-2中, 若否, 则所述节点向所述客户端返回 moved错误的提示信息, 使 所述客户端根据所述提示信息转向所述服务器集群中正确的节点。
[0044] 在本实施例中, 所述提示信息包括所述 key值所对应的哈希槽被指派的节点名 称。 所述节点向所述客户端返回 moved错误的提示信息, 使所述客户端根据所述 提示信息转向所述服务器集群中正确的节点具体包括: 若所述 key值所对应的哈 希槽不是由所述节点负责, 则所述节点自动根据所述 key值所对应的哈希槽被指 派的节点名称生成 moved错误的提示信息, 并将所述提示信息返回至所述客户端 , 使所述客户端根据所述提示信息中的所述 key值所对应的哈希槽被指派的节点 名称转向所述服务器集群中正确的节点。
[0045] 以上可以看出, 本发明实施例提供的基于键值对的数据处理方法由于首先采用 的由服务器集群中的任一节点接收客户端发送的数据库键命令; 然后由所述节 点计算所述数据库键命令中携带的 key值所对应的哈希槽, 并判断所述哈希槽是 否由自己负责; 若是, 则所述节点执行所述数据库键命令; 若否, 则所述节点 向所述客户端返回 moved错误的提示信息, 使所述客户端根据所述提示信息转向 所述服务器集群中正确的节点, 从而使得幵源数据库 Redis可以利用处理器的多 核优势进行并发处理, 提升了数据库的处理性能, 使得只需部署一个数据库实 例即可达到业务性能指标, 减少了数据库实例的部署, 减轻了数据库管理的负 担。
[0046] 图 2示出了本发明实施例提供的基于键值对的数据处理系统的结构框图, 该系 统用于运行图 1所示实施例提供的方法。 为了便于说明仅仅示出了与本发明实施 例相关的部分。
[0047] 参见图 2所示, 本发明实施例提供的一种基于键值对的数据处理系统, 包括位 于服务器集群中节点内部的接收模块 1、 计算模块 2、 判断模块 3、 执行模块 4以 及提示模块 5, 所述接收模块 1、 所述计算模块 2、 所述判断模块 3以及所述执行 模块 4依次连接, 所述判断模块 3还与所述提示模块 5连接, 其中:
[0048] 所述接收模块 1, 用于接收客户端发送的数据库键命令;
[0049] 所述计算模块 2, 用于计算所述数据库键命令中携带的 key值所对应的哈希槽;
[0050] 所述判断模块 3, 用于判断所述哈希槽是否由所述节点负责;
[0051] 所述执行模块 4, 用于若是由所述节点负责, 则执行所述数据库键命令;
[0052] 所述提示模块 5, 用于若不是由所述节点负责, 则向所述客户端返回 moved错误 的提示信息, 使所述客户端根据所述提示信息转向所述服务器集群中正确的节 点。
[0053] 可选的, 所述的基于键值对的数据处理系统还包括与所述服务器集群中的节点 相连的分配模块 6和位于所述节点内部与所述分配模块 6和所述判断模块 3连接的 存储模块 7, 其中:
[0054] 所述分配模块 6, 用于将所述服务器集群中的多个哈希槽分别指派给所述服务 器集群中的各个节点;
[0055] 所述存储模块 7, 用于存储所述多个哈希槽的指派信息。
[0056] 可选的, 所述提示信息包括所述 key值所对应的哈希槽被指派的节点名称。
[0057] 可选的, 所述计算模块 2具体用于:
[0058] 采用集群使用公式 CRC16(key) % 16384来计算
key值所对应的哈希槽, 其中, CRC16(key)语句用于计算 key值的 CRC16校验 和。
[0059] 可选的, 所述数据库键命令包括 get命令、 set命令、 del命令和 hget命令。
[0060] 需要说明的是, 本发明实施例提供的上述系统中各个模块, 由于与本发明方法 实施例基于同一构思, 其带来的技术效果与本发明方法实施例相同, 具体内容 可参见本发明方法实施例中的叙述, 此处不再赘述。
[0061] 因此, 可以看出本发明实施例提供的基于键值对的数据处理系统同样可以使得 幵源数据库 Redis能够利用处理器的多核优势进行并发处理, 提升了数据库的处 理性能, 并且可以减少数据库实例的部署, 减轻数据库管理的负担。
[0062] 请参考图 3, 本发明另一实施例提供的一种基于键值对的数据处理系统的结构 框图。 该系统用于运行上述图 1所示实施例提供的方法。 为了便于说明仅仅示出 了与本实施例相关的部分。
[0063] 参见图 3所示, 本实施例提供一种基于键值对的数据处理系统包括:
[0064] 处理器 (processor) 310, 通信接口 (Communications Interface) 320, 存储器
(memory) 330, 总线 340。
[0065] 处理器 310, 通信接口 320, 存储器 330通过总线 340完成相互间的通信。
[0066] 通信接口 320, 用于与外界设备, 例如, 个人电脑、 服务器等通信。
[0067] 处理器 310, 用于执行程序 331。
[0068] 具体地, 程序 331可以包括程序代码, 所述程序代码包括计算机操作指令。
[0069] 处理器 310可能是一个中央处理器 CPU, 或者是特定集成电路 ASIC (Applicatio n Specific Integrated Circuit) , 或者是被配置成实施本发明实施例的一个或多 集成电路。
[0070] 存储器 330, 用于存放程序 331。 存储器 330可能包含高速 RAM存储器, 也可能 还包括非易失性存储器 (non-volatile memory) , 例如至少一个磁盘存储器。 程 序 331具体可以包括:
[0071] 接收模块 1, 用于接收客户端发送的数据库键命令;
[0072] 计算模块 2, 用于计算所述数据库键命令中携带的 key值所对应的哈希槽;
[0073] 判断模块 3, 用于判断所述哈希槽是否由所述节点负责;
[0074] 执行模块 4, 用于若是由所述节点负责, 则执行所述数据库键命令;
[0075] 提示模块 5, 用于若不是由所述节点负责, 则向所述客户端返回 moved错误的提 示信息, 使所述客户端根据所述提示信息转向所述服务器集群中正确的节点。
[0076] 所属领域的技术人员可以清楚地了解到, 为描述的方便和简洁, 上述描述的系 统、 装置和单元的具体工作过程, 可以参考前述方法实施例中的对应过程, 在 此不再赘述。
[0077] 在本申请所提供的几个实施例中, 应该理解到, 所揭露的系统、 装置和方法, 可以通过其它的方式实现。 例如, 以上所描述的装置实施例仅仅是示意性的, 例如, 所述单元的划分, 仅仅为一种逻辑功能划分, 实际实现吋可以有另外的 划分方式, 例如多个单元或组件可以结合或者可以集成到另一个系统, 或一些 特征可以忽略, 或不执行。 另一点, 所显示或讨论的相互之间的耦合或直接耦 合或通信连接可以是通过一些通信接口, 装置或单元的间接耦合或通信连接, 可以是电性, 机械或其它的形式。
[0078] 所述作为分离部件说明的单元可以是或者也可以不是物理上分幵的, 作为单元 显示的部件可以是或者也可以不是物理单元, 即可以位于一个地方, 或者也可 以分布到多个网络单元上。 可以根据实际的需要选择其中的部分或者全部单元 来实现本实施例方案的目的。
[0079] 另外, 在本发明各个实施例中的各功能单元可以集成在一个处理单元中, 也可 以是各个单元单独物理存在, 也可以两个或两个以上单元集成在一个单元中。
[0080] 所述功能如果以软件功能单元的形式实现并作为独立的产品销售或使用吋, 可 以存储在一个计算机可读取存储介质中。 基于这样的理解, 本发明的技术方案 本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产 品的形式体现出来, 该计算机软件产品存储在一个存储介质中, 包括若干指令 用以使得一台计算机设备 (可以是个人计算机, 服务器, 或者网络设备等) 执 行本发明各个实施例所述方法的全部或部分步骤。 而前述的存储介质包括: u盘
、 移动硬盘、 只读存储器 (ROM, Read-Only
Memory) 、 随机存取存储器 (RAM, Random Access Memory) 、 磁碟或者光盘 等各种可以存储程序代码的介质。
[0081] 以上所述仅为本发明的较佳实施例而已, 并不用以限制本发明, 凡在本发明的 精神和原则之内所作的任何修改、 等同替换和改进等, 均应包含在本发明的保 护范围之内。

Claims

权利要求书
[权利要求 1] 一种基于键值对的数据处理方法, 其特征在于, 包括:
服务器集群中的任一节点接收客户端发送的数据库键命令; 所述节点计算所述数据库键命令中携带的 key值所对应的哈希槽, 并 判断所述哈希槽是否由自己负责;
若是, 则所述节点执行所述数据库键命令;
若否, 则所述节点向所述客户端返回 moved错误的提示信息, 使所述 客户端根据所述提示信息转向所述服务器集群中正确的节点。
[权利要求 2] 如权利要求 1所述的基于键值对的数据处理方法, 其特征在于, 在服 务器集群中的任一节点接收客户端发送的数据库键命令之前还包括: 将所述服务器集群中的多个哈希槽分别指派给所述服务器集群中的各 个节点, 并将所述多个哈希槽的指派信息存储至所述服务器集群中的 每个节点。
[权利要求 3] 如权利要求 2所述的基于键值对的数据处理方法, 其特征在于, 所述 提示信息包括所述 key值所对应的哈希槽被指派的节点名称。
[权利要求 4] 如权利要求 1所述的基于键值对的数据处理方法, 其特征在于, 所述 节点计算所述数据库键命令中携带的 key值所对应的哈希槽具体包括 所述节点采用集群使用公式 CRC16(key) % 16384来计算 key值所对应 的哈希槽, 其中, CRC16(key)语句用于计算 key值的 CRC16校验和
[权利要求 5] 如权利要求 1所述的基于键值对的数据处理方法, 其特征在于, 所述 数据库键命令包括 get命令、 set命令、 del命令和 hget命令。
[权利要求 6] —种基于键值对的数据处理系统, 其特征在于, 包括位于服务器集群 中节点内部的接收模块、 计算模块、 判断模块、 执行模块以及提示模 块, 所述接收模块、 所述计算模块、 所述判断模块以及所述执行模块 依次连接, 所述判断模块还与所述提示模块连接, 其中:
所述接收模块, 用于接收客户端发送的数据库键命令; 所述计算模块, 用于计算所述数据库键命令中携带的 key值所对应的 哈希槽;
所述判断模块, 用于判断所述哈希槽是否由所述节点负责; 所述执行模块, 用于若是由所述节点负责, 则执行所述数据库键命令 所述提示模块, 用于若不是由所述节点负责, 则向所述客户端返回 m oved错误的提示信息, 使所述客户端根据所述提示信息转向所述服务 器集群中正确的节点。
[权利要求 7] 如权利要求 6所述的基于键值对的数据处理系统, 其特征在于, 还包 括与所述服务器集群中的节点相连的分配模块和位于所述节点内部与 所述分配模块和所述判断模块连接的存储模块, 其中:
所述分配模块, 用于将所述服务器集群中的多个哈希槽分别指派给所 述服务器集群中的各个节点;
所述存储模块, 用于存储所述多个哈希槽的指派信息。
[权利要求 8] 如权利要求 7所述的基于键值对的数据处理系统, 其特征在于, 所述 提示信息包括所述 key值所对应的哈希槽被指派的节点名称。
[权利要求 9] 如权利要求 6所述的基于键值对的数据处理系统, 其特征在于, 所述 计算模块具体用于:
采用集群使用公式 CRC16(key) % 16384来计算 key值所对应的哈希槽 , 其中, CRC16(key)语句用于计算 key值的 CRC16校验和。
[权利要求 10] 如权利要求 6所述的基于键值对的数据处理系统, 其特征在于, 所述 数据库键命令包括 get命令、 set命令、 del命令和 hget命令。
PCT/CN2016/091942 2015-11-11 2016-07-27 一种基于键值对的数据处理方法及系统 WO2017080257A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201510765510.2A CN105426451A (zh) 2015-11-11 2015-11-11 一种基于键值对的数据处理方法及系统
CN201510765510.2 2015-11-11

Publications (1)

Publication Number Publication Date
WO2017080257A1 true WO2017080257A1 (zh) 2017-05-18

Family

ID=55504663

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/091942 WO2017080257A1 (zh) 2015-11-11 2016-07-27 一种基于键值对的数据处理方法及系统

Country Status (2)

Country Link
CN (1) CN105426451A (zh)
WO (1) WO2017080257A1 (zh)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109862075A (zh) * 2018-12-29 2019-06-07 北京奥鹏远程教育中心有限公司 一种Redis服务实例的路由方法
FR3103664A1 (fr) * 2019-11-27 2021-05-28 Amadeus Sas Système de stockage distribué pour stocker des données contextuelles
CN113297192A (zh) * 2021-05-31 2021-08-24 上海艾麒信息科技股份有限公司 针对redis hash类型数据控制field过期的方法及系统

Families Citing this family (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105426451A (zh) * 2015-11-11 2016-03-23 深圳市华讯方舟科技有限公司 一种基于键值对的数据处理方法及系统
CN107479829B (zh) * 2017-08-03 2020-04-17 杭州铭师堂教育科技发展有限公司 一种基于消息队列的Redis集群海量数据快速清理系统及方法
CN107688611B (zh) * 2017-08-03 2020-02-28 杭州铭师堂教育科技发展有限公司 一种基于saltstack的Redis键值管理系统及方法
CN108416039A (zh) * 2018-03-14 2018-08-17 北京思特奇信息技术股份有限公司 一种数据查询方法和系统
CN108509540A (zh) * 2018-03-16 2018-09-07 中国银行股份有限公司 基于redis集群的多键值命令处理方法及系统
CN109274665A (zh) * 2018-09-13 2019-01-25 北京奇安信科技有限公司 Dns威胁情报处理方法及装置
CN109710406B (zh) * 2018-12-21 2023-01-17 腾讯科技(深圳)有限公司 数据分配及其模型训练方法、装置、及计算集群
CN112948377A (zh) * 2021-02-02 2021-06-11 京东数字科技控股股份有限公司 数据的存储方法、装置、电子设备及计算机可读介质
CN113836238A (zh) * 2021-09-30 2021-12-24 杭州数梦工场科技有限公司 数据命令的批量处理方法及装置
CN117033395A (zh) * 2023-10-08 2023-11-10 北京凌云雀科技有限公司 一种Redis集群的信息处理方法、装置、电子设备及介质

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101567006A (zh) * 2009-05-25 2009-10-28 中兴通讯股份有限公司 一种数据库系统及分布式sql语句执行计划重用方法
CN104333512A (zh) * 2014-10-30 2015-02-04 北京思特奇信息技术股份有限公司 一种分布式内存数据库访问系统及方法
CN104408073A (zh) * 2014-10-31 2015-03-11 广州华多网络科技有限公司 数据操作方法和装置
CN105426451A (zh) * 2015-11-11 2016-03-23 深圳市华讯方舟科技有限公司 一种基于键值对的数据处理方法及系统

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8504521B2 (en) * 2005-07-28 2013-08-06 Gopivotal, Inc. Distributed data management system
CN101741731A (zh) * 2009-12-03 2010-06-16 中兴通讯股份有限公司 内容分发网络中内容元数据的存储、查询方法及管理系统
US8972488B2 (en) * 2010-09-28 2015-03-03 Redis Labs Ltd. System, methods, and media for providing in-memory non-relational databases
CN103107944B (zh) * 2011-11-14 2016-03-30 中国移动通信集团公司 一种内容定位方法和路由设备
CN103268318B (zh) * 2013-04-16 2016-04-13 华中科技大学 一种强一致性的分布式键值数据库系统及其读写方法
CN103544285B (zh) * 2013-10-28 2017-09-26 华为技术有限公司 一种数据加载方法及装置
CN104156380B (zh) * 2014-03-04 2019-03-26 深圳信息职业技术学院 一种分布式存储器哈希索引方法及系统
CN104361030A (zh) * 2014-10-24 2015-02-18 西安未来国际信息股份有限公司 一种具有任务分发功能的分布式缓存架构及缓存方法

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101567006A (zh) * 2009-05-25 2009-10-28 中兴通讯股份有限公司 一种数据库系统及分布式sql语句执行计划重用方法
CN104333512A (zh) * 2014-10-30 2015-02-04 北京思特奇信息技术股份有限公司 一种分布式内存数据库访问系统及方法
CN104408073A (zh) * 2014-10-31 2015-03-11 广州华多网络科技有限公司 数据操作方法和装置
CN105426451A (zh) * 2015-11-11 2016-03-23 深圳市华讯方舟科技有限公司 一种基于键值对的数据处理方法及系统

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109862075A (zh) * 2018-12-29 2019-06-07 北京奥鹏远程教育中心有限公司 一种Redis服务实例的路由方法
CN109862075B (zh) * 2018-12-29 2022-05-03 北京奥鹏远程教育中心有限公司 一种Redis服务实例的路由方法
FR3103664A1 (fr) * 2019-11-27 2021-05-28 Amadeus Sas Système de stockage distribué pour stocker des données contextuelles
EP3829139A1 (en) * 2019-11-27 2021-06-02 Amadeus S.A.S. Distributed storage system for storing context data
CN113297192A (zh) * 2021-05-31 2021-08-24 上海艾麒信息科技股份有限公司 针对redis hash类型数据控制field过期的方法及系统

Also Published As

Publication number Publication date
CN105426451A (zh) 2016-03-23

Similar Documents

Publication Publication Date Title
WO2017080257A1 (zh) 一种基于键值对的数据处理方法及系统
US11704144B2 (en) Creating virtual machine groups based on request
JP5459800B2 (ja) サーバクラスタ、データ媒体および対応するサーバクラスタの初期化および管理データベースの操作リクエストを生成するための方法
JP2022501752A (ja) 電子手形識別子の割り当て方法、電子手形の生成方法、及びその装置とシステム、並びに、記憶媒体及びコンピュータプログラム
CN106776998B (zh) 一种数据库服务提供方法及服务器
US10656874B2 (en) Storage device operation control method, and storage device
WO2015158108A1 (zh) 虚拟机资源的变更方法、装置及虚拟网络功能设备
WO2014101475A1 (zh) 云平台应用部署方法及装置
CN104035817A (zh) 大规模集成电路物理实现的分布式并行计算方法及其系统
WO2019153880A1 (zh) 集群中镜像文件下载的方法、节点、查询服务器
CN104754008A (zh) 网络存储节点、网络存储系统以及用于网络存储节点的装置和方法
CN104008012A (zh) 一种基于虚拟机动态迁移的高性能MapReduce实现机制
CN113687964A (zh) 数据处理方法、装置、电子设备、存储介质及程序产品
CN104216721A (zh) 一种在操作系统启动之前下发配置的方法
CN114565502A (zh) Gpu资源管理方法、调度方法、装置、电子设备及存储介质
WO2018188607A1 (zh) 流处理方法及装置
WO2017143929A1 (zh) 云数据库资源扩展和服务扩展的方法和系统
CN109586970A (zh) 资源分配方法、装置及系统
CN104809026A (zh) 一种使用远程节点借用cpu计算资源的方法
CN110868330B (zh) 云平台可划分cpu资源的评估方法、装置及评估系统
KR102156656B1 (ko) 가상머신 스택 생성 시스템 및 방법
CN112231058A (zh) 一种突破numa拓扑限制创建云主机的方法及装置
CN109818998B (zh) 信息同步方法和装置
US20190050282A1 (en) Information processing device, information processing method, and non-transitory computer-readable storage medium
CN104363208A (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: 16863435

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205 DATED 15/10/2018)

122 Ep: pct application non-entry in european phase

Ref document number: 16863435

Country of ref document: EP

Kind code of ref document: A1