Expansion and node data Linux system architecture ----- redis-cluster cluster recovery

I. Case Summary

  • An electricity supplier of large projects, due to the massive upgrade business. Project pre-caching node, has been unable to meet current business needs. Now redis-cluster clustering expansion redis redis a standby node, the actual production environment, typically at night operation planning is 12:00. Well in advance before the operation redis installation and deployment, around 0:00, less traffic volume, relatively small sphere of influence, redis docking underlying database (MySQL), first to lock the library, lock table, does not produce traffic flow data, such redis clusters It may produce less affected.

Two .redis-cluster cluster planning

  • Environmental deployment
category IP addresses system Package
master

ens33: 192.168.43.101

ens37: 192.168.43.247

ens38: 192.168.43.248

The master node of the newly added ens39: 192.168.43.131

centos7

redis-5.0.7.tar.gz

rvm-1.29.9.tar.gz

slave

ens33: 192.168.43.102

ens36: 192.168.43.156

ens37: 192.168.43.185

slave node newly added ens38: 192.168.43.132

centos7 redis-5.0.7.tar.gz
  • To conserve resources, in a virtual machine add multiple NICs, simulate the production environment
  • To simulate the deployment of three master and three slave to build redis-cluster cluster
  • Add a group redis server, a node operating expansion

Deployment of the redis-cluster cluster

Four .redis node expansion

  • In the master, add two nodes to the cluster, and view state (default is added to the cluster master node)
[root@master ~]# redis-cli --cluster add-node 192.168.43.131:6379 192.168.43.101:6379
[root@master ~]# redis-cli --cluster add-node 192.168.43.132:6379 192.168.43.101:6379
  • View Node (ID required number of nodes), where there will be all the node information
[root@master ~]# redis-cli -h 192.168.43.101 -p 6379
192.168.43.101:6379> cluster nodes
  • Balancing hash tank, automatic migration information
#根据redis 槽位分析,一共有16384个槽位,如果分4个配套节点:每个节点是4096个槽位

[root@master ~]# redis-cli --cluster reshard 192.168.43.101:6379
How many slots do you want to move (from 1 to 16384)? 4096  #要迁移多少个槽

What is the receiving node ID? 99521b7fd126b694bcb9a22ffa5a490f31f66543  #迁移到哪个节点(192.168.43.131的ID)

Please enter all the source node IDs.
  
Type 'all' to use all the nodes as source nodes for the hash slots.
  
Type 'done' once you entered all the source nodes IDs.

#要求输入源节点的id,这里输入101,247,248三个节点,输入done表示结束

Source node #1: 7f112f82bcf28a5d0627ea81b48cb76f4ea8605d
Source node #2: df195a34a91d756157a0fda7c71e99d5bd8fad09
Source node #3: a233a23541f431107fed79908318394d8bb30b51
Source node #4: done

最后会有一个迁移方案,输入yes表示同意,迁移开始。输入no表示不同意,重新设置迁移方案。
  • Equilibrium testing each node slot
[root@master~]# redis-cli --cluster rebalance 192.168.43.101:6379
  • The expansion 192.168.43.132, this node becomes the slave node by the master node
[root@master1 ~]# redis-cli -h 192.168.43.132 -p 6379
192.168.43.132:6379> cluster replicate 99521b7fd126b694bcb9a22ffa5a490f31f66543
OK
192.168.43.132:6379> cluster nodes      //查看节点信息,验证是否转变成功
  • The balance of the number of grooves each node
[root@master ~]# redis-cli --cluster rebalance --cluster-threshold 1 192.168.43.132:6379
>>> Performing Cluster Check (using node 192.168.43.132:6379)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
*** No rebalancing needed! All nodes are within the 1.00% threshold.

 

Published 139 original articles · won praise 168 · views 40000 +

Guess you like

Origin blog.csdn.net/qq_42761527/article/details/105053669