Redis cluster expansion method, device, electronic device and storage medium

By deploying a second redis instance with a capacity specified on the target machine and adding it to the cluster as a replica of the first instance, the problem of slow migration of redis cluster expansion in the prior art is solved, and rapid capacity expansion and high availability are achieved.

CN114945910BActive Publication Date: 2025-03-25SHENZHEN HEYTAP TECHNOLOGY CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202080093350.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-02-24
Publication Date
2025-03-25
Estimated Expiration
2040-02-24

AI Technical Summary

Technical Problem

The existing redis cluster expansion method relies on the migrate command that comes with redis, resulting in slow migration speed and affecting business availability.

Method used

By deploying and opening a second redis instance with a capacity not greater than the specified capacity on the target machine, joining it as a copy of the first redis instance, and copying the data of the first instance into the second instance, and finally replacing the first instance, to achieve rapid expansion of the cluster.

Benefits of technology

By replication instead of migration, the scaling speed of the redis cluster is significantly improved and the availability of services is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114945910B_ABST
    Figure CN114945910B_ABST
Patent Text Reader

Abstract

A redis cluster expansion method, device, electronic device and storage medium, relating to the technical field of electronic devices. The method comprises: when migrating a first redis instance in a redis cluster deployed on a first machine to a second machine, deploying and starting a second redis instance on the second machine, wherein the capacity of the second redis instance is not greater than a specified capacity (S110), adding the second redis instance as a copy of the first redis instance to the redis cluster, and copying the data in the first redis instance to the second redis instance (S120), replacing the first redis instance with the second redis instance in the redis cluster (S130). The present application achieves the purpose of rapid expansion of the redis cluster by copying instead of migrating, thereby improving the availability of the service.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of electronic devices, and more specifically, to a redis cluster expansion method, device, electronic device and storage medium. Background Art

[0002] Redis is an open source (BSD licensed) in-memory data structure storage used as a database, cache, and message broker. Currently, Redis clusters are divided into two camps, one is the proxy + stand-alone Redis solution based on Codis, and the other is the official Redis Cluster. Regardless of which solution is adopted, the industry uses the migrate command that comes with Redis for migration, which is slow and affects the availability of the business. Summary of the invention

[0003] In view of the above problems, the present application proposes a redis cluster expansion method, device, electronic device and storage medium to solve the above problems.

[0004] In a first aspect, an embodiment of the present application provides a redis cluster expansion method, the method comprising:

[0005] When migrating a first redis instance in a redis cluster deployed on a first machine to a second machine, deploy and start a second redis instance on the second machine, and the capacity of the second redis instance is not greater than a specified capacity; add the second redis instance to the redis cluster as a copy of the first redis instance, and copy the data in the first redis instance to the second redis instance; replace the first redis instance with the second redis instance in the redis cluster.

[0006] In a second aspect, an embodiment of the present application provides a redis cluster expansion device, the device comprising:

[0007] The first redis instance deployment module is used to deploy and start the second redis instance on the second machine when migrating the first redis instance in the redis cluster deployed on the first machine to the second machine, and the capacity of the second redis instance is not greater than the specified capacity; the first data replication module is used to add the second redis instance to the redis cluster as a copy of the first redis instance, and replicate the data in the first redis instance to the second redis instance; the first redis instance replacement module is used to replace the first redis instance with the second redis instance in the redis cluster.

[0008] In a third aspect, an embodiment of the present application provides an electronic device, comprising a memory and a processor, wherein the memory is coupled to the processor, the memory stores instructions, and when the instructions are executed by the processor, the processor executes the above method.

[0009] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which a program code is stored, and the program code can be called by a processor to execute the above method.

[0010] The redis cluster expansion method, device, electronic device and storage medium provided in the embodiments of the present application deploy and start a second redis instance on the second machine when migrating a first redis instance in a redis cluster deployed on a first machine to a second machine, wherein the capacity of the second redis instance is not greater than a specified capacity, adds the second redis instance to the redis cluster as a copy of the first redis instance, copies the data in the first redis instance to the second redis instance, and replaces the first redis instance with the second redis instance in the redis cluster, thereby achieving the purpose of rapid expansion of the redis cluster by copying instead of migrating, and improving the availability of the business. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without paying any creative work.

[0012] Figure 1 A schematic diagram of a process for expanding a redis cluster provided by an embodiment of the present application is shown;

[0013] Figure 2 A schematic diagram of redis cluster expansion provided by an embodiment of the present application is shown;

[0014] Figure 3 Another schematic diagram of redis cluster expansion provided by an embodiment of the present application is shown;

[0015] Figure 4 A schematic diagram of a process of expanding a redis cluster provided by another embodiment of the present application is shown;

[0016] Figure 5 A schematic diagram of a process of a redis cluster expansion method provided in another embodiment of the present application is shown;

[0017] Figure 6 This application shows Figure 5 The flowchart of step S340 of the redis cluster expansion method shown in FIG.

[0018] Figure 7 Another schematic diagram of redis cluster expansion provided by an embodiment of the present application is shown;

[0019] Figure 8 Another schematic diagram of redis cluster expansion provided by an embodiment of the present application is shown;

[0020] Fig. 9 This application shows Figure 5 A flowchart of an embodiment of step S360 of the redis cluster expansion method shown;

[0021] Fig.10 This application shows Figure 5 A flowchart of another embodiment of step S360 of the redis cluster expansion method shown;

[0022] Fig.11 A schematic diagram of a process of expanding a redis cluster provided in another embodiment of the present application is shown;

[0023] Fig.12 This application shows Fig.11 The flowchart of step S430 of the redis cluster expansion method shown in FIG.

[0024] Fig.13 A module block diagram of a redis cluster capacity expansion device provided in an embodiment of the present application is shown;

[0025] Fig.14 A block diagram of an electronic device for executing a redis cluster expansion method according to an embodiment of the present application is shown;

[0026] Fig.15 A storage unit for storing or carrying program codes for implementing the redis cluster expansion method according to an embodiment of the present application is shown. DETAILED DESCRIPTION

[0027] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.

[0028] At present, Redis clusters are divided into two major camps. One is the proxy + stand-alone Redis solution based on Codis, and the other is the officially implemented Redis Cluster. Regardless of which solution is adopted, the industry uses Redis's own migrate command for migration. According to different cluster solutions, many different optimizations are made on the basis of migrate.

[0029] Among them, Redis Cluster supports moving specified slots in nodes in Redis 4.0 Cluster, and also supports automatic redistribution according to the existing slot distribution in the cluster nodes after adding empty nodes.

[0030] Among them, Alibaba Cloud Redis uses the migrate command to migrate keys in batches. In order to reduce the synchronization blocking time of migration on Redis, Alibaba Cloud has optimized the migrate command and split the migrate command into two stages. 1. Serialize the key requested for migration and send it to the target node. The target node returns confirmation after receiving it; 2. After the target node completes deserialization, it actively notifies the source node, and the source node deletes the local data. The main purpose of this split is to reduce the synchronization blocking time of the source node by the migrate command, but it requires modifying the Redis kernel, and the effect is not obvious.

[0031] Among them, Pre-sharding is a redis cluster expansion solution proposed by antirez, the author of redis, before the official redis cluster solution was perfected. The business must first divide the data into N parts, each corresponding to a redis instance. When the business storage volume is small, all redis instances are deployed on a few machines. Migration is carried out in the following steps: 1. Start a standby redis instance in a new virtual machine; 2. Set this instance as a copy of the old instance to be moved; 3. When the initial synchronization is completed and all slave servers are working, please change the client configuration to use the new instance; 4. Use slaveof no one to select the new instance as the master instance; 5. Finally, shut down all old instances; 6. Use the new IP / PORT information of each instance to improve the shell script configuration.

[0032] The inventor found in the research that the commonly used redis cluster solution (similar to Alibaba Cloud) in the industry currently relies on the migrate command of redis itself. In order to ensure atomicity, the entire redis main process will be synchronously blocked during the migration process, which greatly affects availability. Moreover, migrate can only migrate one key at a time, and the migration speed is also very slow. The Pre-sharding solution previously proposed by antirez uses replication instead of migration, which can effectively guarantee the availability and migration speed of redis at the expense of a certain consistency. However, because it is a fixed number of copies N, N cannot be changed before and after migration, so it becomes a difficult problem to determine how much N is set. If it is set too small, because a single redis will eventually be limited by the memory of the physical machine, the final total capacity will be too small and cannot be further expanded; if it is set too large, when the total number of machines is small at the beginning, the performance will be low due to resource preemption, affecting the service. Moreover, the previously mentioned pre-sharding is mainly for the master-slave version cluster, and does not explain the current redis cluster solution.

[0033] In response to the above technical problems, the inventors have discovered and proposed the redis cluster expansion method, device, electronic device and storage medium provided in the embodiments of the present application after long-term research. For the official redis cluster solution, the purpose of rapid expansion of the redis cluster is achieved by copying instead of migrating, so as to improve the availability of the business. Among them, the specific redis cluster expansion method is specifically described in the subsequent embodiments.

[0034] See also Figure 1 , Figure 1 The flowchart of a redis cluster expansion method provided by an embodiment of the present application is shown. The redis cluster expansion method is used to achieve the purpose of rapid expansion of the redis cluster by copying instead of migrating, thereby improving the availability of the service. In a specific embodiment, the redis cluster expansion method is applied to Fig.13 The redis cluster expansion device 200 and the electronic device 100 equipped with the redis cluster expansion device 200 ( Fig.14 ). The following will take an electronic device as an example to illustrate the specific process of this embodiment. Of course, it can be understood that the electronic device used in this embodiment can be a smart phone, a tablet computer, a wearable electronic device, etc., which is not limited here. Figure 1 The process shown is described in detail, and the redis cluster expansion method may specifically include the following steps:

[0035] Step S110: when migrating a first redis instance in a redis cluster deployed on a first machine to a second machine, deploying and starting a second redis instance on the second machine, the capacity of the second redis instance is not greater than a specified capacity.

[0036] In some implementations, a redis cluster may include multiple redis instances, wherein the capacities of the multiple redis instances may all be the same, may all be different, or may be partially the same. In this embodiment, a redis cluster may include a first redis instance and multiple other redis instances, wherein the capacity of the first redis instance may be the same as the capacity of the multiple other redis instances, or may be different from the capacity of the multiple other redis instances, which is not limited here.

[0037] In some embodiments, the first redis instance in the redis cluster is deployed on the first machine, and multiple other redis instances in the redis cluster can be deployed on the first machine or on other machines different from the first machine, which is not limited here. For example, assume that the redis cluster includes 5 redis instances, and the 5 redis instances are the first redis instance, the first other redis instance, the second other redis instance, the third other redis instance, and the fourth other redis instance, wherein the first redis instance is deployed on the first machine, the first other redis instance, the second other redis instance, the third other redis instance, and the fourth other redis instance can be deployed on the first machine or on other machines. When the first other redis instance, the second other redis instance, the third other redis instance, and the fourth other redis instance are deployed on other machines, the first other redis instance, the second other redis instance, the third other redis instance, and the fourth other redis instance can all be deployed on the same other machine, can be partially deployed on the same other machine, or can all be deployed on different other machines, which is not limited here.

[0038] In some implementations, when expanding the capacity of a redis cluster, at least one of the multiple redis instances included in the redis cluster can be expanded. That is, when expanding the capacity of a redis cluster, the first redis instance in the redis cluster can be expanded, and other redis instances in the redis cluster can also be expanded at the same time, which is not limited here. In this embodiment, when expanding the capacity of a redis cluster, the expansion of the first redis instance in the redis cluster is used as an example for explanation. Of course, other redis instances in the redis cluster can also be expanded, which is not repeated here.

[0039] In some embodiments, when the first redis instance in the redis cluster is expanded, the first redis instance deployed on the first machine can be migrated to the second machine, wherein the second machine is different from the first machine, and the memory of the second machine can be more sufficient than the memory of the first machine, so as to meet the purpose of expansion when the first redis instance is migrated from the first machine to the second machine. In this embodiment, when the first redis instance in the redis cluster deployed on the first machine is migrated to the second machine, the second redis instance can be deployed and started on the second machine, wherein, in order to avoid a single node being too large and difficult to maintain, the upper limit of the capacity of the second redis instance deployed on the second machine can be limited, that is, the capacity of the second redis instance can be limited to no more than the specified capacity. In this embodiment, the capacity of the second redis instance can be simply limited to no more than the specified capacity through the maxmemory configuration of redis.

[0040] Step S120: adding the second redis instance as a copy of the first redis instance to the redis cluster, and copying the data in the first redis instance to the second redis instance.

[0041] In some embodiments, after deploying and starting the second redis instance on the second machine, the second redis instance can be added to the redis cluster as a copy of the first redis instance, and the data in the first redis instance can be synchronized to the second redis instance, wherein the method of synchronizing the data in the first redis instance to the second redis instance may include replication, copying, etc., so as to achieve rapid synchronization of the data in the first redis instance to the second redis instance, greatly improving the migration speed. At the same time, redis itself does not support the function of migrating slots, and an additional migration tool needs to be written to perform slot migration, which can easily lead to migration errors due to logical problems. This embodiment uses the relatively mature replication function of redis itself to replace the slot migration logic of the external program to reduce the error probability. Furthermore, this embodiment synchronizes the data in the first redis instance to the second redis instance by replication, which does not affect the use of the business at all during the replication process, and can improve the availability of the business.

[0042] In some embodiments, when copying data in a first redis instance to a second redis instance, if the first redis instance includes a slave node, data in the slave node of the first redis instance may also be copied to the second redis instance, which is not limited here.

[0043] See also Figure 2 , Figure 2 A schematic diagram of redis cluster expansion provided by an embodiment of the present application is shown. Figure 2 In this example, machine A can be regarded as the first machine, machine B can be regarded as the second machine, M can be regarded as the first redis instance, and S can be regarded as the second redis instance. Figure 2 As shown, the data in the redis instance M in machine A can be copied to the redis instance S, and the capacity of the redis instance S is larger than that of the redis instance M, thereby realizing the expansion of the redis cluster.

[0044] Step S130: replacing the first redis instance with the second redis instance in the redis cluster.

[0045] In some embodiments, after copying the data in the first redis instance to the second redis instance, the first redis instance can be replaced with the second redis instance in the redis cluster. That is, at this time, the redis cluster includes the second redis instance and multiple other redis instances, thereby achieving the purpose of expanding the redis cluster by expanding the first redis instance to the second redis.

[0046] In some embodiments, before replacing the first redis instance with the second redis instance in the redis cluster, it is also possible to detect whether the data in the first redis instance is completely copied to the second redis instance. As a method, the capacity occupied by the data in the first redis instance can be obtained, and the capacity occupied by the data in the second redis instance during the process of copying the data from the first redis instance to the second redis instance can be monitored. At the end of the copying, if it is monitored that the capacity occupied by the data in the second redis instance is lower than the capacity occupied by the data in the first redis instance, it can be determined that the data in the first redis instance is not completely copied to the second redis instance, and an operation of re-copying the data in the first redis instance to the second redis instance can be triggered, or an operation of continuing to copy the data in the first redis instance that has not been copied to the second redis instance to the second redis instance can be triggered, until the capacity occupied by the data in the second redis instance is equal to the capacity occupied by the data in the first redis instance, and then the first redis instance is replaced with the second redis instance in the redis cluster.

[0047] See also Figure 3 , Figure 3 Another schematic diagram of redis cluster expansion provided by the embodiment of the present application is shown. Figure 3 In this example, machine A can be regarded as the first machine, machine B can be regarded as the second machine, M can be regarded as the first redis instance, and S can be regarded as the second redis instance. Figure 3 As shown, the redis instance M in machine A can be removed, and the redis instance S in machine B can replace the redis instance M in machine B.

[0048] An embodiment of the present application provides a redis cluster expansion method. When migrating a first redis instance in a redis cluster deployed on a first machine to a second machine, a second redis instance is deployed and started on the second machine, wherein the capacity of the second redis instance is not greater than a specified capacity, the second redis instance is added to the redis cluster as a copy of the first redis instance, and the data in the first redis instance is copied to the second redis instance, and the first redis instance is replaced with the second redis instance in the redis cluster, thereby achieving the purpose of rapid expansion of the redis cluster by copying instead of migrating, and improving the availability of the business.

[0049] See also Figure 4 , Figure 4A schematic diagram of a redis cluster expansion method provided by another embodiment of the present application is shown below. Figure 4 The process shown is described in detail, and the redis cluster expansion method may specifically include the following steps:

[0050] Step S210: when migrating a first redis instance in a redis cluster deployed on a first machine to a second machine, deploying and starting a second redis instance on the second machine, the capacity of the second redis instance is not greater than a specified capacity.

[0051] Step S220: adding the second redis instance as a copy of the first redis instance to the redis cluster, and copying the data in the first redis instance to the second redis instance.

[0052] Step S230: replacing the first redis instance with the second redis instance in the redis cluster.

[0053] For the detailed description of step S210 to step S230 , please refer to step S110 to step S130 , which will not be repeated here.

[0054] Step S240: when migrating the second redis instance in the redis cluster deployed on the second machine to the third machine, deploying and starting a third redis instance on the third machine, the capacity of the third redis instance is not greater than the specified capacity.

[0055] In some embodiments, the redis cluster may include a second redis instance and multiple other redis instances. The second redis instance in the redis cluster is deployed on the second machine, and the multiple other redis instances in the redis cluster may be deployed on the first machine, the second machine, or other machines different from the first machine and the second machine, which is not limited here. For example, suppose that the redis cluster includes 5 redis instances, and the 5 redis instances are the second redis instance, the first other redis instance, the second other redis instance, the third other redis instance and the fourth other redis instance, wherein the second redis instance is deployed on the second machine, the first other redis instance, the second other redis instance, the third other redis instance and the fourth other redis instance can be deployed on the first machine, the second machine, or other machines. When the first other redis instance, the second other redis instance, the third other redis instance and the fourth other redis instance are deployed on other machines, the first other redis instance, the second other redis instance, the third other redis instance and the fourth other redis instance can all be deployed on the same machine, partly on the same machine, or all on different machines, and there is no limitation here.

[0056] In some implementations, when expanding the capacity of a redis cluster, at least one of the multiple redis instances included in the redis cluster can be expanded. That is, when expanding the capacity of a redis cluster, the second redis instance in the redis cluster can be expanded, and other redis instances in the redis cluster can also be expanded at the same time, which is not limited here. In this embodiment, when expanding the capacity of a redis cluster, the expansion of the second redis instance in the redis cluster is used as an example for explanation. Of course, other redis instances in the redis cluster can also be expanded, which is not repeated here.

[0057] In some embodiments, when the second redis instance in the redis cluster is expanded, the second redis instance deployed on the second machine can be migrated to a third machine, wherein the third machine is different from the second machine, and the memory of the third machine can be more sufficient than the memory of the second machine, so as to meet the purpose of expansion when the second redis instance is migrated from the second machine to the third machine. In this embodiment, when the second redis instance in the redis cluster deployed on the second machine is migrated to the third machine, the third redis instance can be deployed and started on the third machine, wherein, in order to avoid a single node being too large and difficult to maintain, the upper limit of the capacity of the third redis instance deployed on the second machine can be limited, that is, the capacity of the third redis instance can be limited to no more than the specified capacity. In this embodiment, the capacity of the third redis instance can be simply limited to no more than the specified capacity through the maxmemory configuration of redis.

[0058] Step S250: adding the third redis instance as a copy of the second redis instance to the redis cluster, and copying the data in the second redis instance to the third redis instance.

[0059] In some embodiments, after deploying and starting a third redis instance on a third machine, the third redis instance can be added to the redis cluster as a copy of the second redis instance, and the data in the second redis instance can be synchronized to the third redis instance, wherein the method of synchronizing the data in the second redis instance to the third redis instance can include replication, copying, etc., so as to quickly synchronize the data in the second redis instance to the third redis instance, thereby greatly improving the migration speed.

[0060] Step S260: replacing the second redis instance with the third redis instance in the redis cluster.

[0061] In some embodiments, after the data in the second redis instance is copied to the third redis instance, the second redis instance can be replaced with the third redis instance in the redis cluster, that is, at this time, the redis cluster includes the third redis instance and multiple other redis instances, so that the purpose of redis cluster expansion is achieved by expanding the second redis instance to the third redis. Therefore, in this embodiment, the redis cluster can be expanded infinitely as needed to ensure the availability of the service.

[0062] In some embodiments, before replacing the second Redis instance with the third Redis instance in the Redis cluster, it is also possible to detect whether the data in the second Redis instance is completely copied to the third Redis instance. As a method, the capacity occupied by the data in the second Redis instance can be obtained, and the capacity occupied by the data in the third Redis instance during the process of copying the data from the second Redis instance to the third Redis instance can be monitored. At the end of the copying, if it is monitored that the capacity occupied by the data in the third Redis instance is lower than the capacity occupied by the data in the second Redis instance, it can be determined that the data in the second Redis instance is not completely copied to the third Redis instance, and an operation of re-copying the data in the second Redis instance to the third Redis instance can be triggered, or an operation of continuing to copy the data in the second Redis instance that has not been copied to the third Redis instance to the third Redis instance can be triggered, until the capacity occupied by the data in the third Redis instance is equal to the capacity occupied by the data in the second Redis instance, and then the second Redis instance is replaced with the third Redis instance in the Redis cluster.

[0063] Another embodiment of the present application provides a method for expanding the capacity of a redis cluster. When migrating a first redis instance in a redis cluster deployed on a first machine to a second machine, a second redis instance is deployed and started on the second machine, wherein the capacity of the second redis instance is not greater than a specified capacity, the second redis instance is added to the redis cluster as a copy of the first redis instance, and the data in the first redis instance is copied to the second redis instance, and the first redis instance is replaced with the second redis instance in the redis cluster. When migrating the second redis instance in the redis cluster deployed on the second machine to a third machine, a third redis instance is deployed and started on the third machine, wherein the capacity of the third redis instance is not greater than a specified capacity, the third redis instance is added to the redis cluster as a copy of the second redis instance, and the data in the second redis instance is copied to the third redis instance, and the second redis instance is replaced with the third redis instance in the redis cluster. Compared to Figure 1 The redis cluster expansion method shown in the figure, this embodiment also deploys redis instances on different machines according to needs to achieve continuous expansion of the redis cluster and improve the availability of the business.

[0064] See also Figure 5 , Figure 5 A schematic diagram of a redis cluster expansion method provided in another embodiment of the present application is shown below. Figure 5The process shown is described in detail, and the redis cluster expansion method may specifically include the following steps:

[0065] Step S310: when migrating a first redis instance in a redis cluster deployed on a first machine to a second machine, deploying and starting a second redis instance on the second machine, the capacity of the second redis instance is not greater than a specified capacity.

[0066] Step S320: adding the second redis instance as a copy of the first redis instance to the redis cluster, and copying the data in the first redis instance to the second redis instance.

[0067] Step S330: replacing the first redis instance with the second redis instance in the redis cluster.

[0068] For the detailed description of step S310 to step S330 , please refer to step S110 to step S130 , which will not be repeated here.

[0069] Step S340: when migrating the first redis instance in the redis cluster deployed on the first machine to the second machine, deploying and starting a fourth redis instance on the second machine, the capacity of the fourth redis instance is greater than the specified capacity.

[0070] In some embodiments, when the first redis instance in the redis cluster deployed on the first machine is migrated to the second machine, the fourth redis instance can be deployed and started on the second machine, wherein the memory of the fourth redis instance can be set to be temporarily greater than the specified capacity as needed to cope with sudden traffic and ensure the availability of the business. In some embodiments, when the first redis instance in the redis cluster deployed on the first machine is migrated to the second machine, the fourth redis instance can be deployed and started on the second machine, and the capacity of the fourth redis instance is greater than the specified capacity and not greater than the target capacity. Among them, the specified capacity may include 8G, and the target capacity may include 16G. For example, the specified capacity may include 8G, and the capacity of the fourth instance may be set to 16G, so as to be applied in the process of copying the data in the first redis instance to the fourth redis instance, if the data in the first redis instance is greater than 8G (for example, 10G), the fourth redis instance cannot be stored.

[0071] See also Figure 6 , Figure 6 This application shows Figure 5The flowchart of step S340 of the redis cluster expansion method shown in FIG. Figure 6 The process shown is described in detail, and the method may specifically include the following steps:

[0072] Step S341: when migrating a first redis instance in a redis cluster deployed on the first machine to the second machine, obtaining the capacity occupied by data in the first redis instance.

[0073] In some embodiments, when migrating a first redis instance in a redis cluster deployed on a first machine to a second machine, the capacity occupied by the data in the first redis instance can be obtained to determine the capacity of the redis instance deployed on the second device based on the capacity occupied by the data in the first redis instance.

[0074] Step S342: when the capacity occupied by the data in the first redis instance is greater than the specified capacity, deploy and start a fourth redis instance on the second machine, and the capacity of the fourth redis instance is greater than the capacity occupied by the data in the first redis instance.

[0075] In some embodiments, when the capacity occupied by the data in the first redis instance is greater than the specified capacity, a fourth redis instance can be deployed and started on the second machine, wherein the capacity of the fourth redis instance is greater than the capacity occupied by the data in the first redis instance. For example, if the specified capacity is 8G, when the capacity occupied by the data in the first redis instance is 10G, a fourth redis instance with a capacity greater than 10G can be deployed and started on the second machine, such as deploying and starting a fourth redis instance with a capacity of 16G on the second machine, to ensure the availability of the service.

[0076] In some embodiments, when the capacity occupied by the data in the first redis instance is obtained to be no greater than the specified capacity, a second redis instance may be deployed and enabled on the second machine, wherein the capacity of the second redis instance is no greater than the specified capacity. For example, if the specified capacity is 8G, and the capacity occupied by the data in the first redis instance is 6G, a second redis instance with a capacity no greater than 8G may be deployed and enabled on the second machine, such as deploying and enabling a second redis instance with a capacity of 8G on the second machine, to avoid a single node being too large and difficult to maintain.

[0077] Step S350: adding the fourth redis instance as a copy of the first redis instance to the redis cluster, and copying the data in the first redis instance to the fourth redis instance.

[0078] In some embodiments, after the fourth redis instance is deployed and started on the second machine, the fourth redis instance can be added to the redis cluster as a copy of the first redis instance, and the data in the first redis instance can be synchronized to the fourth redis instance, wherein the method of synchronizing the data in the first redis instance to the fourth redis instance can include replication, copying, etc., so as to quickly synchronize the data in the first redis instance to the fourth redis instance, thereby greatly improving the migration speed.

[0079] Step S360: split the fourth redis instance to obtain multiple fifth redis instances, wherein each of the multiple fifth redis instances is not larger than the specified capacity.

[0080] In some embodiments, since the capacity of the fourth redis instance is greater than the specified capacity, the capacity of the fourth redis instance is relatively large. In order to avoid the problem that a single node is too large and difficult to maintain, after copying the data in the first redis instance to the fourth redis instance, the fourth redis instance can be split to split the fourth redis instance into multiple fifth redis instances with smaller capacity, wherein the capacity of each of the multiple fifth redis instances is not greater than the specified capacity. As a way, the memory usage upper limit of each of the multiple fifth redis instances can be configured to be not greater than the specified capacity through max memory.

[0081] In some embodiments, the capacities of multiple fifth redis instances obtained by splitting the fourth redis instance may be equal or unequal. When the capacities of multiple fifth redis instances are equal, the capacity of the fourth redis instance may be equally divided according to the data of the fifth redis instance. For example, when the capacity of the fourth redis instance is 16G and the specified capacity is 8G, if the fourth redis instance needs to be split into two fifth redis instances, the fourth redis instance may be equally divided into two fifth redis instances with a capacity of 8G; if the fourth redis instance needs to be equally divided into four fifth redis instances, the fourth redis instance may be equally divided into four fifth redis instances with a capacity of 4G. When the capacities of multiple fifth redis instances are not equal, the fourth redis instance can be divided according to the specified capacity. For example, when the capacity of the fourth redis instance is 23G and the specified capacity is 8G, if the fourth redis instance needs to be split into 3 fifth redis instances, the fourth redis instance can be split into a fifth redis instance A with a capacity of 8G, a fifth redis instance B with a capacity of 8G, and a fifth redis instance C with a capacity of 7G. There is no limitation here.

[0082] The splitting of the fourth redis instance to obtain multiple fifth redis instances may include: splitting the fourth redis instance through slot migration to obtain multiple fifth redis instances.

[0083] The purpose of the split operation is to ensure that the redis cluster can continue to be expanded in the same way. Whether it is executed or not does not affect the use of the redis cluster. Therefore, the operation can be scheduled in a time period with a small amount of business requests as needed to avoid affecting the availability of the business.

[0084] See also Figure 7 , Figure 7 Another schematic diagram of redis cluster expansion provided by the embodiment of the present application is shown. Figure 7 In the example, machine A can be regarded as the first machine, and machine B can be regarded as the second machine. When the capacity of the fourth redis instance (16G) is greater than the specified capacity (8G), the fourth redis instance can be split through slot migration to obtain two fifth redis instances. Figure 8 shown.

[0085] See also Fig. 9 , Fig. 9 This application shows Figure 5 The flowchart of an embodiment of step S360 of the redis cluster expansion method shown in FIG. Fig. 9The process shown is described in detail, and the method may specifically include the following steps:

[0086] Step S361A: Obtain the current business request volume.

[0087] In this embodiment, the current service request volume can be obtained. In some implementations, the current service request volume can be obtained in real time, at preset time intervals, at preset time points, or according to other preset rules, which are not limited here.

[0088] Step S362A: When the current business request amount is less than the specified request amount, the fourth redis instance is split to obtain the multiple fifth redis instances.

[0089] In some embodiments, a specified request amount can be pre-set and stored, and the specified request amount is used as a basis for judging the current business request amount. Therefore, in this embodiment, after obtaining the current business request amount, the current business request amount can be compared with the specified request amount to determine whether the current business request amount is less than the specified request amount, wherein when the judgment result indicates that the current business request amount is less than the specified request amount, it indicates that the current business request amount is small, and even if the fourth redis instance is split, it will not affect the business, therefore, the fourth redis instance can be split to obtain multiple fifth redis instances; when the judgment result indicates that the current business request amount is not less than the specified request amount, it indicates that the current business request amount is large, and splitting the fourth redis instance will affect the business, therefore, the current business request amount can continue to be obtained until the current business request amount is less than the specified request amount.

[0090] See also Fig.10 , Fig.10 This application shows Figure 5 The flowchart of step S360 of another embodiment of the redis cluster expansion method shown in FIG. Fig.10 The process shown is described in detail, and the method may specifically include the following steps:

[0091] Step S361B: Get the current time.

[0092] In this embodiment, the current time can be obtained. In some implementations, the current time can be obtained in real time, at a preset time interval, at a preset time point, or according to other preset rules, which are not limited here.

[0093] Step S362B: When the current time is in the specified time period, the fourth redis instance is split to obtain the multiple fifth redis instances.

[0094] In some embodiments, a specified request amount can be pre-set and stored, and the specified request amount is used as a basis for judging the current business request amount. Therefore, in this embodiment, after obtaining the current business request amount, the current business request amount can be compared with the specified request amount to determine whether the current business request amount is less than the specified request amount, wherein when the judgment result indicates that the current business request amount is less than the specified request amount, it indicates that the current business request amount is small, and even if the fourth redis instance is split, it will not affect the business, therefore, the fourth redis instance can be split to obtain multiple fifth redis instances; when the judgment result indicates that the current business request amount is not less than the specified request amount, it indicates that the current business request amount is large, and splitting the fourth redis instance will affect the business, therefore, the current business request amount can continue to be obtained until the current business request amount is less than the specified request amount.

[0095] Step S370: replacing the first redis instance with the multiple fifth redis instances in the redis cluster.

[0096] In some embodiments, after obtaining multiple fifth redis instances, the first redis instance can be replaced with multiple fifth redis instances in the redis cluster. That is to say, at this time, the redis cluster includes multiple fifth redis instances and multiple other redis instances, thereby achieving the purpose of expanding the redis cluster by expanding the first redis instance to multiple fifth redis instances.

[0097] Another embodiment of the present application provides a method for expanding the capacity of a redis cluster. When migrating the first redis instance in the redis cluster deployed on the first machine to the second machine, deploy and start a second redis instance on the second machine, wherein the capacity of the second redis instance is not greater than a specified capacity, add the second redis instance as a copy of the first redis instance to the redis cluster, and copy the data in the first redis instance to the second redis instance, replace the first redis instance with the second redis instance in the redis cluster, and when migrating the first redis instance in the redis cluster deployed on the first machine to the second machine, deploy and start a fourth redis instance on the second machine, the capacity of the fourth redis instance is greater than the specified capacity, add the fourth redis instance as a copy of the first redis instance to the redis cluster, copy the data in the first redis instance to the fourth redis instance, split the fourth redis instance to obtain multiple fifth instances, each of the multiple fifth instances is not greater than the specified capacity, and replace the first redis instance with multiple fifth redis instances in the redis cluster. Compared to Figure 1 The redis cluster expansion method shown in the figure, this embodiment also temporarily deploys an instance larger than the specified capacity to apply sudden traffic and improve the availability of the business.

[0098] See also Fig.11 , Fig.11 A schematic diagram of a redis cluster expansion method provided by another embodiment of the present application is shown below. Fig.11 The process shown is described in detail, and the redis cluster expansion method may specifically include the following steps:

[0099] Step S410: when migrating a first redis instance in a redis cluster deployed on a first machine to a second machine, deploying and starting a second redis instance on the second machine, the capacity of the second redis instance is not greater than a specified capacity.

[0100] Step S420: adding the second redis instance as a copy of the first redis instance to the redis cluster, and copying the data in the first redis instance to the second redis instance.

[0101] For the detailed description of step S410 to step S420, please refer to step S110 to step S120, which will not be repeated here.

[0102] Step S430: promoting the second redis instance to a master node in the redis cluster, and removing the first redis instance from the redis cluster.

[0103] In this embodiment, the method of replacing the first redis instance with the second redis instance in the redis cluster can be: promoting the second redis instance to a master node in the redis cluster and removing the first redis instance in the redis cluster. In some embodiments, the second redis instance can be promoted to a master node in the redis cluster through cluster failover. In some embodiments, the first redis instance can be removed from the redis cluster through cluster forget.

[0104] See also Fig.12 , Fig.12 This application shows Fig.11 The flowchart of step S430 of the redis cluster expansion method shown in FIG. Fig.12 The process shown is described in detail, and the method may specifically include the following steps:

[0105] Step S431: promoting the second redis instance to a master node in the redis cluster, and shutting down the first redis instance in the redis cluster.

[0106] In some implementations, when the first redis instance is replaced with the second redis instance in the redis cluster, the second redis instance can be promoted to a master node in the redis cluster, and the first redis instance can be shut down in the redis cluster.

[0107] Step S432: removing the closed first redis instance from the redis cluster.

[0108] In some implementations, after the first redis instance is closed in the redis cluster, the closed first redis instance can be removed from the redis cluster.

[0109] In some embodiments, if the first redis instance includes a slave node, when the first redis instance is removed from the redis cluster, the slave node of the first redis instance is also removed.

[0110] Another embodiment of the present application provides a redis cluster expansion method, when migrating a first redis instance in a redis cluster deployed on a first machine to a second machine, deploying and starting a second redis instance on the second machine, wherein the capacity of the second redis instance is not greater than a specified capacity, adding the second redis instance as a copy of the first redis instance to the redis cluster, and copying the data in the first redis instance to the second redis instance, promoting the second redis instance to a master node in the redis cluster, and removing the first redis instance from the redis cluster. Figure 1 The redis cluster expansion method shown in the figure, this embodiment also realizes the expansion of the redis cluster by promoting the second redis instance to the master node and removing the first redis instance, thereby improving the convenience of redis cluster expansion.

[0111] See also Fig.13 , Fig.13 The module block diagram of the redis cluster expansion device 200 provided in the embodiment of the present application is shown below. Fig.13 The block diagram shown in FIG. 1 is used to illustrate that the redis cluster expansion device 200 includes: a first redis instance deployment module 210, a first data replication module 220, and a first redis instance replacement module 230, wherein:

[0112] The first redis instance deployment module 210 is used to deploy and start a second redis instance on a second machine when migrating a first redis instance in a redis cluster deployed on a first machine to a second machine, and the capacity of the second redis instance is not greater than a specified capacity.

[0113] The first data replication module 220 is used to add the second redis instance as a copy of the first redis instance to the redis cluster, and replicate the data in the first redis instance to the second redis instance.

[0114] The first redis instance replacement module 230 is used to replace the first redis instance with the second redis instance in the redis cluster.

[0115] Furthermore, the redis instance replacement module 230 includes:

[0116] The redis instance promotion submodule is used to promote the second redis instance to a master node in the redis cluster and remove the first redis instance in the redis cluster.

[0117] Furthermore, the redis instance promotion submodule includes: a redis instance promotion unit and a redis instance removal unit, wherein:

[0118] The first redis instance promotion unit is used to promote the second redis instance to a master node in the redis cluster and shut down the first redis instance in the redis cluster.

[0119] The redis instance removal unit is used to remove the first redis instance after it is closed in the redis cluster.

[0120] Further, the first redis instance includes a slave node, and the redis instance promotion submodule includes: a second redis instance promotion unit, wherein:

[0121] The second redis instance promotion unit is used to promote the second redis instance to a master node in the redis cluster, and remove the first redis instance and the slave nodes of the first redis instance in the redis cluster.

[0122] Furthermore, the redis instance promotion submodule includes: a third redis instance promotion unit, wherein:

[0123] The third redis instance promotion unit is used to promote the second redis instance to a master node in the redis cluster through cluster failover.

[0124] Furthermore, the redis instance promotion module includes: an instance removal unit, wherein:

[0125] The instance removal unit is used to remove the first redis instance in the redis cluster through cluster forget.

[0126] Furthermore, the redis cluster expansion device 200 further includes: a second redis instance deployment module, a second data replication module and a second redis instance replacement module, wherein:

[0127] A second redis instance deployment module is used to deploy and start a third redis instance on the third machine when migrating the second redis instance in the redis cluster deployed on the second machine to the third machine, and the capacity of the third redis instance is not greater than the specified capacity;

[0128] The second data replication module is used to add the third redis instance as a copy of the second redis instance to the redis cluster, and replicate the data in the second redis instance to the third redis instance.

[0129] The second redis instance replacement module is used to replace the second redis instance with the third redis instance in the redis cluster.

[0130] Furthermore, the redis cluster expansion device 200 further includes: a third redis instance deployment module, a third data replication module, a redis instance splitting module and a third redis instance replacement module, wherein:

[0131] The third redis instance deployment module is used to deploy and start a fourth redis instance on the second machine when migrating the first redis instance in the redis cluster deployed on the first machine to the second machine, and the capacity of the fourth redis instance is greater than the specified capacity.

[0132] Furthermore, the third redis instance deployment module includes: a capacity acquisition submodule and a third redis instance deployment submodule, wherein:

[0133] The capacity acquisition submodule is used to obtain the capacity occupied by data in the first redis instance when migrating the first redis instance in the redis cluster deployed on the first machine to the second machine.

[0134] The first redis instance deployment submodule is used to deploy and start a fourth redis instance on the second machine when the capacity occupied by the data in the first redis instance is greater than the specified capacity, and the capacity of the fourth redis instance is greater than the capacity occupied by the data in the first redis instance.

[0135] Furthermore, the third redis instance deployment module includes: a second redis instance deployment submodule, wherein:

[0136] The second redis instance deployment submodule is used to deploy and start a fourth redis instance on the second machine when migrating the first redis instance in the redis cluster deployed on the first machine to the second machine, and the capacity of the fourth redis instance is greater than the specified capacity and not greater than the target capacity.

[0137] The third data replication module is used to add the fourth redis instance as a copy of the first redis instance to the redis cluster, and replicate the data in the first redis instance to the fourth redis instance.

[0138] The redis instance splitting module is used to split the fourth redis instance to obtain multiple fifth redis instances, wherein each of the multiple fifth redis instances is not greater than a specified capacity.

[0139] Furthermore, the redis instance splitting module includes: a first redis instance splitting submodule, wherein:

[0140] The first redis instance splitting submodule is used to split the fourth redis instance through slot migration to obtain the multiple fifth redis instances.

[0141] Furthermore, the redis instance splitting module includes: a business request volume acquisition submodule and a second redis instance splitting submodule, wherein:

[0142] The business request volume acquisition submodule is used to obtain the current business request volume.

[0143] The second redis instance splitting submodule is used to split the fourth redis instance to obtain the multiple fifth redis instances when the current business request amount is less than the specified request amount.

[0144] Furthermore, the redis instance splitting module includes: a current time acquisition submodule and a third redis instance splitting submodule, wherein:

[0145] The current time acquisition submodule is used to obtain the current time.

[0146] The third redis instance splitting submodule is used to split the fourth redis instance when the current time is in a specified time period to obtain the multiple fifth redis instances.

[0147] Further, the redis instance splitting module includes: a fourth redis instance splitting submodule, wherein:

[0148] The fourth redis instance splitting submodule is used to configure the memory usage upper limit of each fifth redis instance in the multiple fifth redis instances to be no greater than the specified capacity through max memory.

[0149] The third redis instance replacement module is used to replace the first redis instance with the multiple fifth redis instances in the redis cluster.

[0150] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices and modules can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here.

[0151] In several embodiments provided in the present application, the coupling between modules may be electrical, mechanical or other forms of coupling.

[0152] In addition, each functional module in each embodiment of the present application can be integrated into a processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The above integrated modules can be implemented in the form of hardware or software functional modules.

[0153] See also Fig.14 , which shows a structural block diagram of an electronic device 100 provided in an embodiment of the present application. The electronic device 100 may be an electronic device capable of running applications, such as a smart phone, a tablet computer, an e-book, etc. The electronic device 100 in the present application may include one or more of the following components: a processor 110, a memory 120, and one or more applications, wherein the one or more applications may be stored in the memory 120 and configured to be executed by one or more processors 110, and the one or more programs are configured to execute the method described in the aforementioned method embodiment.

[0154] Among them, the processor 110 may include one or more processing cores. The processor 110 uses various interfaces and lines to connect various parts of the entire electronic device 100, and executes various functions and processes data of the electronic device 100 by running or executing instructions, programs, code sets or instruction sets stored in the memory 120, and calling data stored in the memory 120. Optionally, the processor 110 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 110 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing the content to be displayed; and the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 110, but may be implemented separately through a communication chip.

[0155] The memory 120 may include a random access memory (RAM) or a read-only memory (ROM). The memory 120 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 120 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the following various method embodiments, etc. The data storage area may also store data (such as a phone book, audio and video data, chat record data) created by the electronic device 100 during use.

[0156] See also Fig.15 , which shows a structural block diagram of a computer-readable storage medium provided in an embodiment of the present application. The computer-readable medium 300 stores program codes, which can be called by a processor to execute the method described in the above method embodiment.

[0157] The computer readable storage medium 300 may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk, or a ROM. Optionally, the computer readable storage medium 300 includes a non-transitory computer-readable storage medium. The computer readable storage medium 300 has storage space for program code 310 that performs any method steps in the above method. These program codes can be read from or written to one or more computer program products. The program code 310 can be compressed, for example, in an appropriate form.

[0158] To summarize, the redis cluster expansion method, device, electronic device and storage medium provided in the embodiments of the present application, when migrating the first redis instance in the redis cluster deployed on the first machine to the second machine, deploys and starts the second redis instance on the second machine, wherein the capacity of the second redis instance is not greater than the specified capacity, adds the second redis instance as a copy of the first redis instance to the redis cluster, and copies the data in the first redis instance to the second redis instance, and replaces the first redis instance with the second redis instance in the redis cluster, thereby achieving the purpose of rapid expansion of the redis cluster by replication instead of migration, and improving the availability of the business.

[0159] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A redis cluster expansion method, characterized in that: The method comprises: When migrating a first redis instance in a redis cluster deployed on a first machine to a second machine, deploying and starting a second redis instance on the second machine, wherein the capacity of the second redis instance is not greater than a specified capacity; Add the second redis instance to the redis cluster as a copy of the first redis instance, and copy the data in the first redis instance to the second redis instance; Replacing the first redis instance with the second redis instance in the redis cluster; When migrating a first redis instance in a redis cluster deployed on a first machine to a second machine, deploying and starting a fourth redis instance on the second machine, wherein the capacity of the fourth redis instance is greater than a specified capacity; Add the fourth redis instance as a copy of the first redis instance to the redis cluster, and copy the data in the first redis instance to the fourth redis instance; Splitting the fourth redis instance to obtain multiple fifth redis instances, wherein each of the multiple fifth redis instances is not larger than a specified capacity; The first redis instance is replaced with the multiple fifth redis instances in the redis cluster.

2. The method according to claim 1, characterized in that After replacing the first redis instance with the second redis instance in the redis cluster, the method further includes: When migrating the second redis instance in the redis cluster deployed on the second machine to the third machine, deploying and starting a third redis instance on the third machine, the capacity of the third redis instance is not greater than the specified capacity; Add the third redis instance as a copy of the second redis instance to the redis cluster, and copy the data in the second redis instance to the third redis instance; The second redis instance is replaced with the third redis instance in the redis cluster.

3. The method according to claim 1, characterized in that: The splitting of the fourth redis instance to obtain multiple fifth redis instances includes: The fourth redis instance is split through slot migration to obtain the multiple fifth redis instances.

4. The method according to claim 1, characterized in that: The splitting of the fourth redis instance to obtain multiple fifth redis instances includes: Get the current business request volume; When the current business request amount is less than the specified request amount, the fourth redis instance is split to obtain the multiple fifth redis instances.

5. The method according to any one of claims 1 to 4, characterized in that: The splitting of the fourth redis instance to obtain multiple fifth redis instances includes: Get the current time; When the current time is in a specified time period, the fourth redis instance is split to obtain the plurality of fifth redis instances.

6. The method according to any one of claims 1 to 4, characterized in that: After splitting the fourth redis instance to obtain multiple fifth redis instances, the method further includes: The memory occupancy limit of each fifth Redis instance in the multiple fifth Redis instances is configured by max memory to be no greater than the specified capacity.

7. The method according to any one of claims 1 to 4, characterized in that: When migrating the first redis instance in the redis cluster deployed on the first machine to the second machine, deploying and starting the fourth redis instance on the second machine includes: When migrating a first redis instance in a redis cluster deployed on the first machine to the second machine, obtaining a capacity occupied by data in the first redis instance; When the capacity occupied by the data in the first redis instance is greater than the specified capacity, a fourth redis instance is deployed and started on the second machine, and the capacity of the fourth redis instance is greater than the capacity occupied by the data in the first redis instance.

8. The method according to any one of claims 1 to 4, characterized in that: When migrating the first redis instance in the redis cluster deployed on the first machine to the second machine, deploying and starting the fourth redis instance on the second machine includes: When migrating a first redis instance in a redis cluster deployed on the first machine to a second machine, a fourth redis instance is deployed and started on the second machine, and a capacity of the fourth redis instance is greater than a specified capacity and not greater than a target capacity.

9. The method according to claim 8, characterized in that The specified capacity includes 8G, and the target capacity includes 16G.

10. The method according to any one of claims 1 to 4, characterized in that: The replacing the first redis instance with the second redis instance in the redis cluster includes: The second redis instance is promoted to a master node in the redis cluster, and the first redis instance is removed from the redis cluster.

11. The method according to claim 10, characterized in that The step of promoting the second redis instance to a master node in the redis cluster and removing the first redis instance in the redis cluster includes: In the redis cluster, the second redis instance is promoted to a master node, and the first redis instance is shut down in the redis cluster; The closed first redis instance is removed from the redis cluster.

12. The method according to claim 10, characterized in that The first redis instance includes a slave node, and the step of promoting the second redis instance to a master node in the redis cluster and removing the first redis instance from the redis cluster includes: The second redis instance is promoted to a master node in the redis cluster, and the first redis instance and the slave nodes of the first redis instance are removed from the redis cluster.

13. The method according to claim 10, characterized in that The step of promoting the second redis instance to a master node in the redis cluster includes: The second Redis instance is promoted to a primary node in the Redis cluster through cluster failover.

14. The method according to claim 10, characterized in that The removing the first redis instance from the redis cluster includes: Remove the first Redis instance from the Redis cluster through cluster forget.

15. A redis cluster expansion device, characterized in that: The device comprises: A first redis instance deployment module, used for deploying and starting a second redis instance on a second machine when migrating a first redis instance in a redis cluster deployed on a first machine to a second machine, wherein the capacity of the second redis instance is not greater than a specified capacity; A first data replication module, used to add the second redis instance as a copy of the first redis instance to the redis cluster, and replicate the data in the first redis instance to the second redis instance; A first redis instance replacement module, used to replace the first redis instance with the second redis instance in the redis cluster; a third redis instance deployment module, configured to deploy and start a fourth redis instance on the second machine when migrating a first redis instance in a redis cluster deployed on the first machine to the second machine, wherein the capacity of the fourth redis instance is greater than a specified capacity; A third data replication module is used to add the fourth redis instance as a copy of the first redis instance to the redis cluster, and replicate the data in the first redis instance to the fourth redis instance; a redis instance splitting module, used for splitting the fourth redis instance to obtain a plurality of fifth redis instances, wherein each of the plurality of fifth redis instances is not greater than a specified capacity; The third redis instance replacement module is used to replace the first redis instance with the multiple fifth redis instances in the redis cluster.

16. The device according to claim 15, characterized in that The device also includes: A second redis instance deployment module is used to deploy and start a third redis instance on the third machine when migrating the second redis instance in the redis cluster deployed on the second machine to the third machine, and the capacity of the third redis instance is not greater than the specified capacity; A second data replication module is used to add the third redis instance as a copy of the second redis instance to the redis cluster, and replicate the data in the second redis instance to the third redis instance; The second redis instance replacement module is used to replace the second redis instance with the third redis instance in the redis cluster.

17. An electronic device, characterized in that: The method comprises a memory and a processor, wherein the memory is coupled to the processor, and the memory stores instructions. When the instructions are executed by the processor, the processor executes the method according to any one of claims 1 to 14.

18. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program codes, which can be called by a processor to execute the method according to any one of claims 1 to 14.

Citation Information

Patent Citations

  • Data online migration method and agent node

    CN106934048A

  • Real-time user data migration method, storage medium, electronic equipment and system

    CN109660576A