Cluster expansion method and device, electronic equipment and storage medium

CN116166438BActive Publication Date: 2026-07-07PINGAN YIQIANBAO E COMMERCE CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
PINGAN YIQIANBAO E COMMERCE CO LTD
Filing Date
2023-02-22
Publication Date
2026-07-07

AI Technical Summary

Technical Problem

Existing technologies are inefficient when scaling up Redis Cluster because they only support scaling up one cluster at a time and require a large number of repetitive command operations.

Method used

The expansion options dictionary is constructed by querying the node information of the cluster to be expanded, the node expansion program is encapsulated as an expansion interface, the information and parameters of the new node are selected according to the expansion requirements, the connection relationship between the new node and the cluster is set, and a slot is allocated to each node to complete the cluster expansion.

Benefits of technology

This improves the efficiency of cluster expansion, avoids repeatedly writing expansion commands, and ensures the convenience and efficiency of the cluster expansion process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116166438B_ABST
    Figure CN116166438B_ABST
Patent Text Reader

Abstract

The application provides a cluster expansion method and device, electronic equipment and a storage medium. The cluster expansion method comprises the following steps: querying node information of original nodes in a to-be-expanded cluster to construct an expansion option dictionary; encapsulating a preset node expansion program into an expansion interface; establishing new node information according to a preset expansion requirement, and selecting expansion parameters from the expansion option dictionary according to the new node information; and simultaneously inputting the new node information and the expansion parameters into the expansion interface to set a connection relationship between the new node and the to-be-expanded cluster. The to-be-expanded cluster comprises a plurality of slots, each node in the to-be-expanded cluster is allocated a slot, and cluster expansion is completed. The method can receive expansion parameters through the expansion interface to conveniently expand the cluster, thereby improving the efficiency of cluster expansion.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of cluster operation and maintenance technology, and in particular to a cluster expansion method, device, electronic device and storage medium. Background Technology

[0002] Redis Cluster is a high-availability solution for Redis clusters. Typically, each node in a Redis cluster is deployed on a virtual machine or cloud host, and the nodes are connected through a master-slave relationship to build the Redis cluster. However, the increasing volume of data can affect the stability of the cluster when storing data. Therefore, it is necessary to scale up the Redis cluster to accommodate more business data.

[0003] Currently, when scaling up a Redis Cluster, the default script redis-trib.rb in the Redis Cluster is usually used to perform command-line operations. This operation only supports scaling up one cluster at a time, and a large number of command options need to be prepared before scaling up. The work is repetitive and time-consuming, resulting in low cluster scaling efficiency. Summary of the Invention

[0004] In view of the above, it is necessary to provide a cluster expansion method and related equipment to solve the technical problem of how to improve the efficiency of cluster expansion. The related equipment includes a cluster expansion device, electronic equipment and storage media.

[0005] This application provides a cluster expansion method, the method comprising:

[0006] Query the node information of the existing nodes in the cluster to be expanded to construct a dictionary of expansion options;

[0007] The pre-defined node expansion program is encapsulated into an expansion interface;

[0008] New node information is established based on preset expansion requirements, and expansion parameters are selected from the expansion option dictionary based on the new node information;

[0009] The new node information and the expansion parameters are simultaneously transmitted to the expansion interface to set the connection relationship between the new node and the cluster to be expanded;

[0010] The cluster to be expanded contains multiple slots. Slots are allocated to each node in the cluster to be expanded, and the cluster expansion is completed.

[0011] In some embodiments, querying the node information of existing nodes in the cluster to be expanded to construct an expansion option dictionary specifically includes:

[0012] Query the node information of each existing node in the cluster to be expanded. The existing nodes include master nodes and slave nodes. The node information includes IP address and port number.

[0013] Set the node name for each of the original nodes based on the node information;

[0014] Use the node name as the key and the IP address and port number as the value to construct a key-value pair for each of the original nodes, and combine all the key-value pairs of the original nodes to form a dictionary of expansion options.

[0015] In some embodiments, encapsulating the preset node expansion program into an expansion interface specifically includes:

[0016] Write the node expansion procedure into a pre-written request file and store the request file in the storage directory to which the cluster to be expanded belongs, as an expansion interface.

[0017] In some embodiments, the step of establishing new node information based on preset expansion requirements and selecting expansion parameters from the expansion option dictionary based on the new node information specifically includes:

[0018] The preset expansion requirements are parsed to obtain information on new nodes. The information on new nodes includes the type of new node, the new IP address, and the new port number. The type of new node includes master nodes and slave nodes.

[0019] When the newly added node is classified as a primary node, the newly added IP address and the newly added port number are used as expansion parameters;

[0020] When the newly added node is classified as a slave node, the node information of the master node corresponding to the newly added node is queried from the expansion option dictionary as expansion parameters.

[0021] In some embodiments, when the newly added node is a slave node, querying the node information of the master node corresponding to the newly added node from the expansion option dictionary as expansion parameters specifically includes:

[0022] Query the amount of data stored on each master node in the cluster to be expanded;

[0023] The master node with the largest amount of data is selected as the node to be expanded, and the IP address and port number corresponding to the node to be expanded are queried from the expansion option dictionary as expansion parameters.

[0024] In some embodiments, the step of simultaneously transmitting the new node information and the expansion parameters to the expansion interface to set the connection relationship between the new node and the cluster to be expanded specifically includes:

[0025] Based on the new node information and expansion parameters received by the expansion interface, an expansion request is obtained. The expansion request includes a request header and a request message. The request header includes at least destination port information, and the request message is the new node information and the expansion parameters.

[0026] The expansion request is parsed to obtain the category of the newly added node, which includes master node and slave node;

[0027] When the newly added node becomes the master node, it is connected to the cluster to be expanded according to the expansion parameters.

[0028] When the newly added node is a slave node, the newly added node is connected to the node to be expanded according to the expansion parameters.

[0029] In some embodiments, allocating slots to each node in the cluster to be expanded specifically includes:

[0030] The quotient of the default total number of slots in the cluster to be expanded and the total number of existing nodes is taken as the standard number of slots in the cluster to be expanded.

[0031] Calculate the difference between the number of slots of any existing node in the cluster to be expanded and the standard number of slots;

[0032] For each existing node, a slot with the same difference is selected and evenly distributed to all the new nodes to complete the cluster expansion.

[0033] This application embodiment also provides a cluster expansion device, the device comprising:

[0034] The query unit is used to query the node information of the existing nodes in the cluster to be expanded in order to build a dictionary of expansion options;

[0035] The encapsulation unit is used to encapsulate the preset node expansion program into an expansion interface;

[0036] The selection unit is used to establish new node information based on preset expansion requirements, and to select expansion parameters from the expansion option dictionary based on the new node information;

[0037] A connection unit is used to simultaneously transmit the new node information and the expansion parameters to the expansion interface in order to set the connection relationship between the new node and the cluster to be expanded.

[0038] The slot allocation unit is used to allocate slots to each node in the cluster to be expanded and to complete the cluster expansion.

[0039] This application embodiment also provides an electronic device, the electronic device comprising:

[0040] Memory, which stores computer-readable instructions; and

[0041] The processor executes computer-readable instructions stored in the memory to implement the cluster expansion method.

[0042] This application also provides a computer-readable storage medium storing computer-readable instructions, which are executed by a processor in an electronic device to implement the cluster expansion method.

[0043] The aforementioned AI-based cluster expansion method constructs an expansion option dictionary by querying the node information of existing nodes in the cluster to be expanded, and encapsulates the preset node expansion program into an expansion interface. New node information is created based on preset expansion requirements, and expansion parameters are selected from the expansion option dictionary based on the new node information. The new node information and the expansion parameters are simultaneously passed to the expansion interface to set the connection relationship between the new node and the cluster to be expanded. This avoids repeatedly writing expansion instructions during the cluster expansion process. Finally, slots are allocated to each node in the cluster to complete the cluster expansion. Receiving expansion parameters through the expansion interface facilitates convenient cluster expansion, thereby improving the efficiency of cluster expansion. Attached Figure Description

[0044] Figure 1 This is a flowchart of a preferred embodiment of a cluster expansion method involved in this application.

[0045] Figure 2 This is a functional block diagram of a preferred embodiment of the cluster expansion device involved in this application.

[0046] Figure 3 This is a schematic diagram of the structure of an electronic device that is a preferred embodiment of the cluster expansion method involved in this application. Detailed Implementation

[0047] To better understand the purpose, features, and advantages of this application, a detailed description of the application is provided below with reference to the accompanying drawings and specific embodiments. It should be noted that, unless otherwise specified, the embodiments and features described in the embodiments of this application can be combined with each other. Numerous specific details are set forth in the following description to provide a thorough understanding of this application; the described embodiments are only a part of the embodiments of this application, and not all of them.

[0048] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the stated features. In the description of this application, "a plurality of" means two or more, unless otherwise explicitly specified.

[0049] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. The term "and / or" as used herein includes any and all combinations of one or more of the associated listed items.

[0050] This application provides a cluster expansion method that can be applied to one or more electronic devices. The electronic device is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions. Its hardware includes, but is not limited to, microprocessors, application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.

[0051] The electronic device can be any electronic product that can interact with the user, such as a personal computer, tablet computer, smartphone, personal digital assistant (PDA), game console, interactive network television (IPTV), smart wearable device, etc.

[0052] The electronic device may also include network devices and / or user devices. The network devices include, but are not limited to, a single network server, a server group consisting of multiple network servers, or a cloud based on cloud computing consisting of a large number of hosts or network servers.

[0053] The networks in which the electronic devices are located include, but are not limited to, the Internet, wide area networks, metropolitan area networks, local area networks, and virtual private networks (VPNs).

[0054] like Figure 1The diagram shown is a flowchart of a preferred embodiment of the cluster expansion method of this application. Depending on different requirements, the order of the steps in this flowchart can be changed, and some steps can be omitted.

[0055] S10: Query the node information of the existing nodes in the cluster to be expanded in order to construct the expansion option dictionary.

[0056] In an optional embodiment, the step of querying the node information of existing nodes in the cluster to be expanded to construct an expansion option dictionary specifically includes:

[0057] Query the node information of each existing node in the cluster to be expanded. The existing nodes include master nodes and slave nodes. The node information includes IP address and port number.

[0058] Set the node name for each of the original nodes based on the node information;

[0059] Use the node name as the key and the IP address and port number as the value to construct a key-value pair for each of the original nodes, and combine all the key-value pairs of the original nodes to form a dictionary of expansion options.

[0060] In this optional embodiment, the cluster to be expanded refers to the Redis cluster that needs to be expanded. The cluster to be expanded consists of multiple nodes, and each existing node represents a Redis instance, i.e., a Redis server. A preset query statement can be run on any node of the cluster to be expanded to obtain the node category and node information of each existing node. The category of the existing node includes master nodes and slave nodes, and the node information includes the node IP address and port number.

[0061] For example, the preset query statement can take the form of: redis-cli-h 192.168.81.210-p6380cluster nodes. The function of this query statement is to query all node information under the cluster to be expanded, which has IP address 192.168.81.210 and port number 6380.

[0062] In this optional embodiment, for each existing node in the cluster to be expanded, the hash value of the IP address in the node information can be calculated separately as the name of each existing node; the hash value of the port number in the node information can also be calculated separately as the name of each existing node; or the IP address and port number in the node information can be combined as a node information string, and the hash value of the node information string can be calculated as the name of the existing node.

[0063] For example, when the hash value of the port number is calculated using the SHA256 algorithm and used as the name of the original node, and the port number is 6381, the name of the original node is: 1B36CD7951891F387E1EA2D74FC1B86992F0985CDFD4F824F5A086B3F6973F0B. Since the hash value obtained by any hash algorithm is unique, the name is also unique.

[0064] In this optional embodiment, for each of the original nodes, the name can be used as the key, and the IP address and port number as the value to construct a key-value pair for each original node. All of the key-value pairs are then stored together as a dictionary of expansion options.

[0065] In this way, by calculating the hash value of the node information of each original node to obtain the name of each original node, a scaling option dictionary can be constructed to store the correspondence between the name of each original node and the node information, which can improve the efficiency of node information query during subsequent cluster scaling.

[0066] S11 encapsulates the preset node expansion program into an expansion interface.

[0067] In an optional embodiment, the step of encapsulating the preset node expansion program into an expansion interface specifically includes:

[0068] Write the node expansion procedure into a pre-written request file and store the request file in the storage directory to which the cluster to be expanded belongs, as an expansion interface.

[0069] In this optional embodiment, the preset node expansion program is used to receive expansion parameters and set the master-slave relationship between nodes. For example, the form of the preset node expansion program can be: redis-trib.rb add-node–slave-id A--master-id B. The meaning of this expansion program is to make the node with node name A a slave node and connect the slave node to the master node with node name B.

[0070] In this optional embodiment, the request file refers to a pre-written program file with node expansion function. After the preset node expansion program is written into the request file, the request file can be stored in the storage directory to which the cluster to be expanded belongs as an expansion interface, so as to facilitate subsequent calls to the expansion interface.

[0071] In this way, the node expansion program is encapsulated into an expansion interface, which can be conveniently called during subsequent cluster expansion processes, thereby improving the efficiency of cluster expansion.

[0072] S12, establish new node information based on preset expansion requirements, and select expansion parameters from the expansion option dictionary based on the new node information.

[0073] In an optional embodiment, the step of establishing new node information based on preset expansion requirements and selecting expansion parameters from the expansion option dictionary based on the new node information specifically includes:

[0074] The preset expansion requirements are parsed to obtain information on new nodes. The information on new nodes includes the type of new node, the new IP address, and the new port number. The type of new node includes master nodes and slave nodes.

[0075] When the newly added node is classified as a primary node, the newly added IP address and the newly added port number are used as expansion parameters;

[0076] When the newly added node is classified as a slave node, the node information of the master node corresponding to the newly added node is queried from the expansion option dictionary as expansion parameters.

[0077] In this optional embodiment, a preset expansion requirement can be parsed to obtain the node information of the new node. The node information of the new node includes its category, IP address, and port number. The category of the new node includes master nodes and slave nodes. For example, when the preset expansion requirement is "add a master node with IP address 192.168.1.103 and port number 6081", then the category of the new node is master node, the new IP address is 192.168.1.103, and the new port number is 6081.

[0078] In this optional embodiment, when the newly added node is a master node, it is not necessary to connect the newly added node to the other nodes in the cluster to be expanded. Therefore, the newly added IP address and the newly added port number can be used as expansion parameters.

[0079] In this optional embodiment, when the type of the newly added node is a slave node, it indicates that the newly added node needs to be used as a slave node of a master node in the cluster to be expanded in order to expand the master node. Therefore, the node information of the master node corresponding to the newly added node can be queried from the expansion option dictionary as expansion parameters.

[0080] In an optional embodiment, when the newly added node is a slave node, querying the node information of the master node corresponding to the newly added node from the expansion option dictionary as expansion parameters specifically includes:

[0081] Query the amount of data stored on each master node in the cluster to be expanded;

[0082] The master node with the largest amount of data is selected as the node to be expanded, and the IP address and port number corresponding to the node to be expanded are queried from the expansion option dictionary as expansion parameters.

[0083] In this optional embodiment, a pre-written data volume query script can be run in the cluster to be expanded to obtain the data volume of each master node in the cluster to be expanded. The data volume is used to characterize the amount of data stored by each master node. The master node with the largest data volume can be selected as the node to be expanded, and the IP address and port number corresponding to the node to be expanded are queried from the expansion option dictionary as expansion parameters. This ensures that the new node can be connected to the node to be expanded based on the IP address and port number, so that the new node can act as a slave node of the node to be expanded, thereby expanding the capacity of the node to be expanded.

[0084] S13, The newly added node information and the expansion parameters are simultaneously transmitted to the expansion interface to set the connection relationship between the newly added node and the cluster to be expanded.

[0085] In an optional embodiment, the step of simultaneously transmitting the new node information and the expansion parameters to the expansion interface to set the connection relationship between the new node and the cluster to be expanded specifically includes:

[0086] Based on the new node information and expansion parameters received by the expansion interface, an expansion request is obtained. The expansion request includes a request header and a request message. The request header includes at least destination port information, and the request message is the new node information and the expansion parameters.

[0087] The expansion request is parsed to obtain the category of the newly added node, which includes master node and slave node;

[0088] When the newly added node is the master node, the newly added node is connected to the cluster to be expanded according to the expansion parameters;

[0089] When the newly added node is a slave node, the newly added node and the node to be expanded are connected according to the newly added node information and the expansion parameters.

[0090] In this optional embodiment, the destination port information in the request header refers to the storage directory of the expansion program in the cluster to be expanded. The destination port information is used to provide path guidance for the expansion request to ensure that the expansion request can be sent to the storage directory, thereby ensuring that the expansion program can accept the request message and construct the expansion instruction.

[0091] In this optional embodiment, when the newly added node is the master node, a first expansion instruction can be constructed based on the expansion parameters, and the first expansion instruction can be executed to connect the newly added node to the cluster to be expanded. For example, when the IP address in the expansion parameters is 192.168.100.104 and the port number is 8007, the first expansion instruction can be in the form of: `cluster add-node 192.168.100.104:8007`. This expansion instruction means connecting the newly added node with IP address 192.168.100.104 and port number 8007 to the cluster to be expanded.

[0092] When the newly added node is a slave node, a second expansion command can be constructed based on the expansion parameters, and the second expansion command can be executed to connect the newly added node to the node to be expanded. For example, when the IP address in the newly added node information is 192.168.100.104 and the port number is 8007, and the IP address in the expansion parameters is 192.168.100.101 and the port number is 8001, the form of the second expansion command can be: `cluster add-node 192.168.100.104:8007 192.168.100.101:8001`. This expansion command means connecting the newly added node with IP address 192.168.100.104 and port number 8007 to the node to be expanded with IP address 192.168.100.101 and port number 8001.

[0093] In this way, by receiving expansion parameters and generating expansion requests through the expansion interface, and performing corresponding expansion operations on different types of newly added nodes according to the expansion requests, the ease of operation of the expansion process can be improved, thereby improving the efficiency of cluster expansion.

[0094] S14, allocate slots to each node in the cluster to be expanded, and complete the cluster expansion.

[0095] In an optional embodiment, allocating slots to each node in the cluster to be expanded specifically includes:

[0096] The quotient of the default total number of slots in the cluster to be expanded and the total number of existing nodes is taken as the standard number of slots in the cluster to be expanded.

[0097] Calculate the difference between the number of slots in the original nodes of the cluster to be expanded and the number of standard slots;

[0098] For each existing node, a slot with the same difference is selected and evenly distributed to all the new nodes to complete the cluster expansion.

[0099] In this optional embodiment, the total number of existing nodes in the cluster to be expanded can be queried and denoted as M, and the default total number of slots in the cluster to be expanded can be queried and denoted as N. For example, when the cluster to be expanded is a RedisCluster cluster, the default total number of slots in the cluster to be expanded is 16384. The slots in the cluster to be expanded are used to represent the minimum unit for storing data that is set in advance.

[0100] In this optional embodiment, the quotient of the total number of slots N and the total number of existing nodes M can be calculated as the standard number of slots. This standard number of slots characterizes the number of slots corresponding to each existing node in the cluster to be expanded after a new node is added. It should be noted that if the quotient is not an integer, it is rounded down to the nearest integer to obtain the standard number of slots. For example, when the total number of slots N is 16384 and the total number of existing nodes M in the cluster to be expanded is 6, the quotient can be rounded down to obtain the standard number of slots, which is 2730.

[0101] In this optional embodiment, the difference between the number of slots in the original nodes of the cluster to be expanded and the standard number of slots can be calculated. This difference is used to characterize the number of slots that need to be selected from each original node of the cluster to be expanded during the slot allocation process. For example, when the number of slots in the original nodes of the cluster to be expanded is 4096 and the standard number of slots is 2730, the difference is 1366, meaning that 1366 slots need to be randomly selected from each original node of the cluster to be expanded to migrate to the new node.

[0102] For each existing node, a slot migration instruction is constructed based on the IP address and port number of the existing node, so that slots in the existing node with the same number of differences are used as slots to be migrated and are evenly distributed to the new node. For example, when the IP address of the original node is 192.168.100.101 and the port number is 8002, the slot migration instruction can be in the form of: cluster reshard 192.168.100.101:8002 600. This slot migration instruction means that any 1366 slots from the original node with IP address 192.168.100.101 and port number 8002 are selected as slots to be migrated and migrated to the new node. It should be noted that when there is only one new node, all 1366 slots to be migrated will be migrated to the new node; when there is more than one new node, the 1366 slots to be migrated will be evenly distributed among each of the new nodes.

[0103] It should also be noted that during the node migration process, when more than one new node is added, the slots to be migrated are evenly distributed to each of the new nodes, specifically including:

[0104] Calculate the migration quotient and migration remainder between the number of slots to be migrated and the number of new nodes. For example, when there are 1366 slots to be migrated and 2 new nodes, the migration quotient is 683 and the migration remainder is 0; when there are 1366 slots to be migrated and 3 new nodes, the migration quotient is 455 and the migration remainder is 1.

[0105] If the migration remainder is 0, then all slots to be migrated can be evenly distributed to the new node.

[0106] If the migration remainder is not 0, then each of the new nodes can be allocated a slot equal to the migration quotient, and the slot equal to the migration remainder can be allocated to any one of the new nodes. For example, when there are 1366 slots to be migrated, and the number of new nodes is 3, namely node A, node B and node C, then 455 slots to be migrated can be allocated to node A, node B and node C respectively, and 1 slot to be migrated can be allocated to any one of the 3 new nodes, so as to ensure that the number of slots corresponding to each node in the cluster to be expanded can be as similar as possible, so as to achieve the effect of load balancing.

[0107] Thus, after the newly added node establishes a connection with the cluster to be expanded, the number of slots for each node in the cluster to be expanded is ensured to be equal by reallocating slots to the newly added node, which can ensure that the cluster maintains load balance when storing data.

[0108] The aforementioned AI-based cluster expansion method constructs an expansion option dictionary by querying the node information of existing nodes in the cluster to be expanded, and encapsulates the preset node expansion program into an expansion interface. New node information is created based on preset expansion requirements, and expansion parameters are selected from the expansion option dictionary based on the new node information. The new node information and the expansion parameters are simultaneously passed to the expansion interface to set the connection relationship between the new node and the cluster to be expanded. This avoids repeatedly writing expansion instructions during the cluster expansion process. Finally, slots are allocated to each node in the cluster to complete the cluster expansion. Receiving expansion parameters through the expansion interface facilitates convenient cluster expansion, thereby improving the efficiency of cluster expansion.

[0109] like Figure 2The diagram shown is a functional block diagram of a preferred embodiment of the cluster expansion device provided in this application. The cluster expansion device 11 includes a query unit 110, an encapsulation unit 111, a selection unit 112, a connection unit 113, and a slot allocation unit 114. The module / unit referred to in this application refers to a series of computer program segments that can be executed by the processor 13 and perform a fixed function, and are stored in the memory 12. In this embodiment, the functions of each module / unit will be described in detail in subsequent embodiments.

[0110] The query unit 110 is used to query the node information of the original nodes in the cluster to be expanded in order to construct an expansion option dictionary.

[0111] The encapsulation unit 111 is used to encapsulate the preset node expansion program into an expansion interface.

[0112] The selection unit 112 is used to establish new node information based on preset expansion requirements, and select expansion parameters from the expansion option dictionary based on the new node information.

[0113] The connection unit 113 is used to simultaneously transmit the new node information and the expansion parameters to the expansion interface in order to set the connection relationship between the new node and the cluster to be expanded.

[0114] The slot allocation unit 114 is used to allocate slots to each node in the cluster to be expanded and to complete the cluster expansion.

[0115] In an optional embodiment, the query unit 110 is specifically used for:

[0116] Query the node information of each existing node in the cluster to be expanded. The existing nodes include master nodes and slave nodes. The node information includes IP address and port number.

[0117] Set the node name for each of the original nodes based on the node information;

[0118] Use the node name as the key and the IP address and port number as the value to construct a key-value pair for each of the original nodes, and combine all the key-value pairs of the original nodes to form a dictionary of expansion options.

[0119] In an optional embodiment, the packaging unit 111 is specifically used for:

[0120] Write the node expansion procedure into a pre-written request file and store the request file in the storage directory to which the cluster to be expanded belongs, as an expansion interface.

[0121] In an optional embodiment, the selection unit 112 is specifically used for:

[0122] The preset expansion requirements are parsed to obtain information on new nodes. The information on new nodes includes the type of new node, the new IP address, and the new port number. The type of new node includes master nodes and slave nodes.

[0123] When the newly added node is classified as a primary node, the newly added IP address and the newly added port number are used as expansion parameters;

[0124] When the newly added node is classified as a slave node, the node information of the master node corresponding to the newly added node is queried from the expansion option dictionary as expansion parameters.

[0125] In an optional embodiment, the selection unit 112 is further configured to:

[0126] Query the amount of data stored on each master node in the cluster to be expanded;

[0127] The master node with the largest amount of data is selected as the node to be expanded, and the IP address and port number corresponding to the node to be expanded are queried from the expansion option dictionary as expansion parameters.

[0128] In an optional embodiment, the connection unit 113 is specifically used for:

[0129] Based on the new node information and expansion parameters received by the expansion interface, an expansion request is obtained. The expansion request includes a request header and a request message. The request header includes at least destination port information, and the request message is the new node information and the expansion parameters.

[0130] The expansion request is parsed to obtain the category of the newly added node, which includes master node and slave node;

[0131] When the newly added node becomes the master node, it is connected to the cluster to be expanded according to the expansion parameters.

[0132] When the newly added node is a slave node, the newly added node is connected to the node to be expanded according to the expansion parameters.

[0133] In an optional embodiment, the slot allocation unit 114 is specifically used for:

[0134] The quotient of the default total number of slots in the cluster to be expanded and the total number of existing nodes is taken as the standard number of slots in the cluster to be expanded.

[0135] Calculate the difference between the number of slots of any existing node in the cluster to be expanded and the standard number of slots;

[0136] For each existing node, a slot with the same difference is selected and evenly distributed to all the new nodes to complete the cluster expansion.

[0137] like Figure 3 The diagram shown is a structural schematic of an electronic device provided in an embodiment of this application. The electronic device 1 includes a memory 12 and a processor 13. The memory 12 is used to store computer-readable instructions, and the processor 13 uses the computer-readable instructions stored in the memory to implement the cluster expansion method of any of the above embodiments.

[0138] In an optional embodiment, the electronic device 1 further includes a bus and a computer program, such as a cluster expansion program, stored in memory 12 and executable on processor 13.

[0139] Figure 3 Only electronic device 1 with memory 12 and processor 13 is shown. It will be understood by those skilled in the art that... Figure 3 The structure shown does not constitute a limitation on the electronic device 1, and may include fewer or more components than shown, or combine certain components, or have different component arrangements.

[0140] Combination Figure 1 The memory 12 in electronic device 1 stores multiple computer-readable instructions to implement a cluster expansion method, and the processor 13 can execute multiple instructions to achieve:

[0141] Query the node information of the existing nodes in the cluster to be expanded to construct a dictionary of expansion options;

[0142] The pre-defined node expansion program is encapsulated into an expansion interface;

[0143] New node information is established based on preset expansion requirements, and expansion parameters are selected from the expansion option dictionary based on the new node information;

[0144] The new node information and the expansion parameters are simultaneously transmitted to the expansion interface to set the connection relationship between the new node and the cluster to be expanded;

[0145] Allocate slots to each node in the cluster to be expanded, and complete the cluster expansion.

[0146] Specifically, the processor 13's implementation method for the above instructions can be found in [reference needed]. Figure 1 The descriptions of the relevant steps in the corresponding embodiments are not repeated here.

[0147] Those skilled in the art will understand that the schematic diagram is merely an example of electronic device 1 and does not constitute a limitation on electronic device 1. Electronic device 1 can be either a bus topology or a star topology. Electronic device 1 may also include more or fewer other hardware or software than shown in the diagram, or different component arrangements. For example, electronic device 1 may also include input / output devices, network access devices, etc.

[0148] It should be noted that electronic device 1 is only an example. Other existing or future electronic products that are suitable for this application should also be included within the scope of protection of this application and are incorporated herein by reference.

[0149] The memory 12 includes at least one type of readable storage medium, which can be non-volatile or volatile. The readable storage medium includes flash memory, portable hard drives, multimedia cards, card-type memory (e.g., SD or DX memory), magnetic storage, magnetic disks, optical disks, etc. In some embodiments, the memory 12 can be an internal storage unit of the electronic device 1, such as a portable hard drive of the electronic device 1. In other embodiments, the memory 12 can be an external storage device of the electronic device 1, such as a plug-in portable hard drive, Smart Media Card (SMC), Secure Digital (SD) card, Flash Card, etc., equipped on the electronic device 1. Furthermore, the memory 12 can include both internal storage units and external storage devices of the electronic device 1. The memory 12 can be used not only to store application software and various types of data installed on the electronic device 1, such as the code of a cluster expansion program, but also to temporarily store data that has been output or will be output.

[0150] In some embodiments, the processor 13 may be composed of integrated circuits, such as a single packaged integrated circuit or multiple integrated circuits packaged with the same or different functions, including combinations of one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and various control chips. The processor 13 is the control unit of the electronic device 1, connecting various components of the electronic device 1 through various interfaces and lines. It executes programs or modules stored in the memory 12 (e.g., executing cluster expansion programs) and calls data stored in the memory 12 to perform various functions and process data in the electronic device 1.

[0151] The processor 13 executes the operating system of the electronic device 1 and various installed applications. The processor 13 executes these applications to implement the steps in the various cluster expansion method embodiments described above, for example... Figure 1 The steps are shown.

[0152] For example, the computer program may be divided into one or more modules / units, which are stored in memory 12 and executed by processor 13 to complete this application. The one or more modules / units may be a series of computer-readable instruction segments capable of performing specific functions, which describe the execution process of the computer program in electronic device 1. For example, the computer program may be divided into a query unit 110, an encapsulation unit 111, a selection unit 112, a connection unit 113, and a slot allocation unit 114.

[0153] The integrated unit implemented as a software functional module can be stored in a computer-readable storage medium. This software functional module, stored in a storage medium, includes several instructions to cause a computer device (which may be a personal computer, computer equipment, or network device, etc.) or processor to execute portions of the cluster expansion methods described in the various embodiments of this application.

[0154] If the modules / units integrated in electronic device 1 are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware devices. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above.

[0155] The computer program includes computer program code, which may be in the form of source code, object code, executable file, or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording media, USB flash drive, portable hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory, and other memory.

[0156] Furthermore, the computer-readable storage medium may primarily include a stored program area and a stored data area, wherein the stored program area may store the operating system, an application program required for at least one function, etc.; and the stored data area may store data created based on the use of blockchain nodes, etc.

[0157] The bus can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This bus can be divided into address bus, data bus, control bus, etc. For ease of representation, in... Figure 3 The symbol is represented by only one arrow, but this does not indicate that there is only one bus or one type of bus. The bus is configured to enable communication between the memory 12 and at least one processor 13, etc.

[0158] This application also provides a computer-readable storage medium (not shown), which stores computer-readable instructions that are executed by a processor in an electronic device to implement the cluster expansion method described in any of the above embodiments.

[0159] Furthermore, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices described in the specification may also be implemented by a single unit or device through software or hardware. Terms such as "first," "second," etc., are used to indicate names and do not indicate any specific order.

[0160] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application and are not intended to limit it. Although this application has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of this application without departing from the spirit and scope of the technical solutions of this application.

Claims

1. A cluster expansion method, characterized in that, The method includes: Query the node information of the existing nodes in the cluster to be expanded to construct a dictionary of expansion options; The pre-defined node expansion program is encapsulated into an expansion interface; The process involves establishing new node information based on preset expansion requirements, and selecting expansion parameters from the expansion option dictionary based on the new node information. This includes: parsing the preset expansion requirements to obtain new node information; when the new node is a master node, using the new IP address and new port number as expansion parameters; when the new node is a slave node, querying the node information of the corresponding master node from the expansion option dictionary as expansion parameters; wherein the new node information includes the new node's category, new IP address, and new port number, and the new node's category includes both master and slave nodes. The new node information and the expansion parameters are simultaneously transmitted to the expansion interface. Based on the expansion request, corresponding expansion operations are performed on different types of new nodes to set the connection relationship between the new node and the cluster to be expanded. Allocate slots to each node in the cluster to be expanded, and complete the cluster expansion.

2. The cluster expansion method as described in claim 1, characterized in that, The process of querying the node information of existing nodes in the cluster to be expanded to construct an expansion option dictionary specifically includes: Query the node information of each existing node in the cluster to be expanded. The existing nodes include master nodes and slave nodes. The node information includes IP address and port number. Set the node name for each of the original nodes based on the node information; Use the node name as the key and the IP address and port number as the value to construct a key-value pair for each of the original nodes, and combine all the key-value pairs of the original nodes to form a dictionary of expansion options.

3. The cluster expansion method as described in claim 1, characterized in that, The process of encapsulating the preset node expansion program into an expansion interface specifically includes: Write the node expansion procedure into a pre-written request file and store the request file in the storage directory to which the cluster to be expanded belongs, as an expansion interface.

4. The cluster expansion method as described in claim 1, characterized in that, When the newly added node is a slave node, the node information of the master node corresponding to the newly added node is queried from the expansion option dictionary as expansion parameters, specifically including: Query the amount of data stored on each master node in the cluster to be expanded; The master node with the largest amount of data is selected as the node to be expanded, and the IP address and port number corresponding to the node to be expanded are queried from the expansion option dictionary as expansion parameters.

5. The cluster expansion method as described in claim 4, characterized in that, The step of simultaneously transmitting the new node information and the expansion parameters to the expansion interface to set the connection relationship between the new node and the cluster to be expanded specifically includes: Based on the new node information and expansion parameters received by the expansion interface, an expansion request is obtained. The expansion request includes a request header and a request message. The request header includes at least destination port information, and the request message is the new node information and the expansion parameters. The expansion request is parsed to obtain the category of the newly added node, which includes master node and slave node; When the newly added node becomes the master node, it is connected to the cluster to be expanded according to the expansion parameters. When the newly added node is a slave node, the newly added node is connected to the node to be expanded according to the expansion parameters.

6. The cluster expansion method as described in claim 1, characterized in that, The process of allocating slots to each node in the cluster to be expanded specifically includes: The quotient of the default total number of slots in the cluster to be expanded and the total number of existing nodes is taken as the standard number of slots in the cluster to be expanded. Calculate the difference between the number of slots of any existing node in the cluster to be expanded and the standard number of slots; For each existing node, a slot with the same difference is selected and evenly distributed to all the new nodes to complete the cluster expansion.

7. A cluster expansion device, characterized in that, The device includes: The query unit is used to query the node information of the existing nodes in the cluster to be expanded in order to build a dictionary of expansion options; The encapsulation unit is used to encapsulate the preset node expansion program into an expansion interface; The selection unit is used to establish new node information based on preset expansion requirements, and select expansion parameters from the expansion option dictionary based on the new node information, including: parsing the preset expansion requirements to obtain new node information; when the new node is a master node, using the new IP address and new port number as expansion parameters; when the new node is a slave node, querying the node information of the master node corresponding to the new node from the expansion option dictionary as expansion parameters; wherein, the new node information includes the new node category, new IP address, and new port number, and the new node category includes master node and slave node; The connection unit is used to simultaneously transmit the new node information and the expansion parameters to the expansion interface, and perform corresponding expansion operations for different types of new nodes according to the expansion request, so as to set the connection relationship between the new node and the cluster to be expanded. The slot allocation unit is used to allocate slots to each node in the cluster to be expanded and to complete the cluster expansion.

8. An electronic device, characterized in that, The electronic device includes: Memory, which stores computer-readable instructions; and The processor executes computer-readable instructions stored in the memory to implement the cluster expansion method as described in any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, which are executed by a processor in an electronic device to implement the cluster expansion method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Database cluster expansion method and device based on Docker

    CN110633325A

  • Cluster node extension method and device, equipment and storage medium

    CN113438107A

  • Capacity expansion method and device, electronic equipment and computer readable medium

    CN114281880A