preface

Before redis5.0.0, the redis cluster was operated with the script redis-trib.rb written by Ruby. The problem is that you need to install Ruby and gems environment. The official docker image does not have the ruby environment such as redis-trib.rb. In the domestic network environment, it is time-consuming and complicated, and it is not easy to succeed. Moreover, the docker image finally made is also large. In addition, the installation of ruby, Redis extension version is not correct, will also lead to the operation of the cluster, reported various errors.

The most important flaw is that redis-trib.rb cannot operate a Redis cluster with a password, although someone on Github has added password support to the redis-trib.rb script. However, I did not add the migration card slots related operation to move_slots. You can view the following submission records:

Redis-Cluster: Add support to auth in redis-trib.rb #4288

Redis after Redis5.0.0 – CLI can directly operate the Redis cluster, can support with password operation, can be said to bring great convenience. The password auth parameter is not supported before redis4.0.7.

MIGRATE host port key|"" destination-db timeout [COPY] [REPLACE] [AUTH password] [KEYS key [key ...]]Copy the code

You can view the official documentation: MIGRATE

Options COPY — Do not remove the key from the local instance. REPLACE — Replace existing key on the remote instance. KEYS — If the key argument is an empty string, the command will instead migrate all the keys that follow the KEYS option (see the above section for more info). AUTH — Authenticate with the given password to the remote instance. COPY and REPLACE are available only in 3.0 and above.keys AUTH is available starting with Redis 4.0.7.

Redis3.2.6 is used in our recent containerization. When the redis cluster has data (hash data is required) and has password, when the scale is expanded from 3 master 3 to 5 master 5 slave, redis:3.2.6 cluster is operated by 5.0.7 redis- CLI. ERR syntax error was reported.

[ERR] Calling MIGRATE: ERR Target instance can be noticed with error: NOAUTH Authentication required:

This is because github redis-trib.rb does not add a password to move_slots. So I tried passing in the password parameters myself in the migration slot, like this:

source.r.client.call(["migrate",target.info[:host],target.info[:port],"",0,@timeout,:auth,target.info[:password],:keys,* keys])Copy the code

Error “ERR syntax Error” is reported when slot migration is performed. As you can see, the redis3.2.6 cluster does not support password parameters at Migrate. Verify whether the card slots can be migrated normally on the redis4.0.7 cluster.

Create a master/slave cluster

Create configmaps

Save the following to the redis-test.conf file:

Pidfile redis-6397.pid #Redis service port number port 6379 #Redis service binding IP #bind 192.168.100.144 Bind {PODIP} # maxMemory 2g # cluster-enabled yes # cluster-config-file nodes-6397.conf # Cluster node timeout (unit: Cluster-node-timeout 15000 Dir /data #tcp-backlog tcp-backlog 511 # How many seconds does the client idle before closing the connection? The number of seconds in which TCP connection activity is detected. Tcp-keepalive 60 #redis password requirepass test123 masterauth test123 # loglevel loglevel notice # log directory logfile "Redis - 6397. The log" # 16 # RDB database several databases available preservation conditions save 900 # 1 save 300 10 save 60 10000 bgsave perform error, Stop-writes -on-bgsave-error no # Whether RDB files are compressed rdbcompression yes # Whether RDB files use checksum rdbChecksum yes #RDB file name Dbfilename dump-6397. RDB # When the secondary node is disconnected from the primary node, if this parameter value is set to yes, the secondary node can continue to process # requests from the client. SYNC with master in #progress" slave-serve-stale-data yes # Check whether the slave node is in read-only mode. In the cluster architecture, the slave nodes are unavailable for reading and writing by default. You need to invoke the readyonly command # enable the read-only mode slave-read-only yes # Whether to enable the diskless replication repl-diskless-sync no # How many seconds should the RDB be created after the diskless replication is enabled? RDB repl-diskless-sync-delay 5 Check whether the NO_DELAY option of the socket for primary/secondary replication is enabled. Yes :Redis will merge small TCP packets to save bandwidth, but this will increase the synchronization delay, resulting in master/slave data inconsistency; No: The master node immediately sends synchronization data. Repl -disable-tcp-nodelay no # Slave node priority slave-priority 100 # Whether to enable persistent mode of AOF appendonly no #Lua Slowlog-log-slower than 10000 # Maximum number of slow slowlog-max-len 1000 #Redis service memory delay monitoring latency-monitor-threshold 0 notify-keyspace-events "" hash-max-ziplist-entries 512 hash-max-ziplist-value 64 list-max-ziplist-entries 512 list-max-ziplist-value 64 set-max-intset-entries 512 zset-max-ziplist-entries 128 Zset-max-ziplist-value 64 HL-SPARSE-max-bytes 3000 # Whether to enable rehash hash activerehashing yes # Client-output-buffer-limit Normal 0 0 0 client-output-buffer-limit slave 512mb 128mb 60 client-output-buffer-limit pubsub 32mb 8mb 60 # copy the size of the backlog cache Repl-backlog -size 256MB # Redis Server performs background tasks at a frequency of 10 Hz by default. 10 # MaxClients 15000Copy the code

Create ConfigMaps using the following command:

kubectl create cm redis-test-conf --from-file=redis.conf=redis-test.confCopy the code

Create a Redis instance

Save the following yamL contents to redis-sts.yaml:

apiVersion: apps/v1 kind: StatefulSet metadata: name: redis-test namespace: default spec: podManagementPolicy: OrderedReady replicas: 10 revisionHistoryLimit: 10 selector: matchLabels: name: redis-test serviceName: redis-test template: metadata: labels: name: redis-test spec: containers: - command: - sh - -c - cp /config/redis.conf /data/; sed -i "s? {PODIP}? ${PODIP}? g" /data/redis.conf ; Conf image: redis:4.0.7 env: -name: PODIP valueFrom: fieldRef: apiVersion: v1 fieldPath: status.podIP imagePullPolicy: IfNotPresent name: redis ports: - containerPort: 6379 name: redis protocol: TCP resources: {} terminationMessagePath: /dev/termination-log terminationMessagePolicy: File volumeMounts: - mountPath: /config name: redis-config - mountPath: /tmp name: tmp-dir dnsPolicy: ClusterFirst restartPolicy: Always schedulerName: default-scheduler securityContext: {} terminationGracePeriodSeconds: 30 volumes: - configMap: defaultMode: 420 name: redis-test-conf name: redis-config - emptyDir: {} name: tmp-dir updateStrategy: rollingUpdate: partition: 0 type: RollingUpdateCopy the code

Docker image of Redis :4.0.7 is used to create the following 10 pods:

[root@liabio ~]# kubectl apply -f redis-sts.yaml [root@liabio ~]# kubectl get pod -owide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES Redis-test-0 1/1 Running 0 60s 192.168.155.117 liabio < None > < None > Redis-test-1 1/1 Running 0 59s 192.168.155.91 liabio <none> <none> redis-test-2 1/1 Running 0 58s 192.168.155.112 liabio <none> <none> redis-test-3 1/1 Running 0 55s 192.168.155.103 liabio <none> <none> Redis-test-4 1/1 Running 0 54s 192.168.155.102 liabio <none> < None > redis-test-5 1/1 Running 0 52s 192.168.155.78 liabio < None > < None > Redis-test-6 1/1 Running 0 51s 192.168.155.108 liabio <none> <none> redis-test-7 1/1 Running 0 49s 192.168.155.111 liabio <none> <none> Redis-test-8 1/1 Running 0 47s 192.168.155.114 liabio <none> < None > Redis-test-9 1/1 Running 0 45s 192.168.155.73 liabio  <none> <none>Copy the code

Use redis-CLI 5.0.7 to operate the cluster

Operating clusters with Redis-CLI5.0.7:

[root@liabio ~]# redis-cli -v
redis-cli 5.0.7Copy the code

Create a 3Master cluster

Select 3 master nodes and create a cluster:

/ root @ liabio ~ # echo yes | redis - cli - cluster create 192.168.155.117:6379 192.168.155.91:6379 192.168.155.112:6379 - a test123 Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe. >>> Performing hash slots allocation on 3 nodes... Master[0] -> Slots 0 - 5460 Master[1] -> Slots 5461 - 10922 Master[2] -> Slots 10923 - 16383 M: F070ddf68e39896af42dc08251199cda7c8b9b92 192.168.155.117:6379 slots: [0-5460] (5461 slots) master M: C4ab027656d55b800cc54063493bca198a5e1385 192.168.155.91:6379 slots: [5461-10922] (5462 slots) master M: 8 d1e71502b9f1c29b3170eb9bf1391ae5aa50650 192.168.155.112:6379 slots: [10923-16383] (5461 slots), the master Can I set the above configuration? (type 'yes' to accept): >>> Nodes configuration updated >>> Assign a different config epoch to each node >>> Sending CLUSTER MEET messages to Join the cluster Waiting for the cluster to join. >>> Performing Cluster Check (using node 192.168.155.117:6379) M: F070ddf68e39896af42dc08251199cda7c8b9b92 192.168.155.117:6379 slots: [0-5460] (5461 slots) master M: C4ab027656d55b800cc54063493bca198a5e1385 192.168.155.91:6379 slots: [5461-10922] (5462 slots) master M: 8 d1e71502b9f1c29b3170eb9bf1391ae5aa50650 192.168.155.112:6379 slots: [10923-16383] (5461 slots) master [OK] All nodes agree about slots configuration. >>> Check for open slots... >>> Check slots coverage... [OK] All 16384 slots covered.Copy the code

Add a slave1

[root@liabio ~]# redis-cli --cluster add-node 192.168.155.103:6379 192.168.155.117:6379 --cluster-slave --cluster-master-id f070ddf68e39896af42dc08251199cda7c8b9b92 -a test123 Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe. >>> Adding node 192.168.155.103:6379 to Cluster 192.168.155.117:6379 >>> Performing Cluster Check (using node 192.168.155.117:6379) M: F070ddf68e39896af42dc08251199cda7c8b9b92 192.168.155.117:6379 slots: [0-5460] (5461 slots) master M: C4ab027656d55b800cc54063493bca198a5e1385 192.168.155.91:6379 slots: [5461-10922] (5462 slots) master M: 8 d1e71502b9f1c29b3170eb9bf1391ae5aa50650 192.168.155.112:6379 slots: [10923-16383] (5461 slots) master [OK] All nodes agree about slots configuration. >>> Check for open slots... >>> Check slots coverage... [OK] All 16384 slots covered. >>> Send CLUSTER MEET to node 192.168.155.103:6379 to make it join the CLUSTER For the cluster to join >>> Configure node as replica of 192.168.155.117:6379. [OK] New node added correctly.Copy the code

Add slave2

[root@liabio ~]# redis-cli --cluster add-node 192.168.155.102:6379 192.168.155.117:6379 --cluster-slave --cluster-master-id c4ab027656d55b800cc54063493bca198a5e1385 -a test123 Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe. >>> Adding node 192.168.155.102:6379 to Cluster 192.168.155.117:6379 >>> Performing Cluster Check (using node 192.168.155.117:6379) M: F070ddf68e39896af42dc08251199cda7c8b9b92 192.168.155.117:6379 slots: [0-5460] (5461 slots) master 1 additional up (s) S: 1121 a45980f1d5964f0010b331aeb514ff9dedb8 192.168.155.103:6379 slots: (0 slots) slave replicates f070ddf68e39896af42dc08251199cda7c8b9b92 M: C4ab027656d55b800cc54063493bca198a5e1385 192.168.155.91:6379 slots: [5461-10922] (5462 slots) master M: 8 d1e71502b9f1c29b3170eb9bf1391ae5aa50650 192.168.155.112:6379 slots: [10923-16383] (5461 slots) master [OK] All nodes agree about slots configuration. >>> Check for open slots... >>> Check slots coverage... All 16384 slots covered. >>> Send CLUSTER MEET to node 192.168.155.102:6379 to make it join the cluster.waiting For the cluster to join >>> Configure node as replica of 192.168.155.91:6379. [OK] New node added correctly.Copy the code

Add slave3

[root@liabio ~]# redis-cli --cluster add-node 192.168.155.78:6379 192.168.155.117:6379 --cluster-slave --cluster-master-id 8d1e71502b9f1c29b3170eb9bf1391ae5aa50650 -a test123 Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe. >>> Adding node 192.168.155.78:6379 to Cluster 192.168.155.117:6379 >>> Performing Cluster Check (using node 192.168.155.117:6379) M: F070ddf68e39896af42dc08251199cda7c8b9b92 192.168.155.117:6379 slots: [0-5460] (5461 slots) master 1 additional up (s) S: 1121 a45980f1d5964f0010b331aeb514ff9dedb8 192.168.155.103:6379 slots: (0 slots) slave replicates f070ddf68e39896af42dc08251199cda7c8b9b92 M: 8 d1e71502b9f1c29b3170eb9bf1391ae5aa50650 192.168.155.112:6379 slots: [10923-16383] (5461 slots) master S: 941108 cab0121fc840f909da080d92770dbbdee1 192.168.155.102:6379 slots: (0 slots) slave replicates c4ab027656d55b800cc54063493bca198a5e1385 M: C4ab027656d55b800cc54063493bca198a5e1385 192.168.155.91:6379 slots: [5461-10922] (5462 slots) 1 additional master replica(s) [OK] All nodes agree about slots configuration. >>> Check for open slots... >>> Check slots coverage... [OK] All 16384 slots covered. >>> Send CLUSTER MEET to node 192.168.155.78:6379 to make it join the CLUSTER The cluster to join >>> Configure node as replica of 192.168.155.112:6379. [OK] New node added correctly. [root@liabio ~] #Copy the code

Add various data types to the cluster

Set hash1 of hash type to cluster; List1 of type list; Sorted set type in zset1; String a; Set1 of type set

[root@liabio ~]# redis-cli -c -h 192.168.155.112 -p 6379 -a test123 Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe. 192.168.155.112:6379> 192.168.155.112:6379> HMSET hash1 name1 "Redis sasa" -> Redirected to slot [4414] located at 192.168.155.119:6379 OK 192.168.155.117:6379> LPUSH list1 AA -> Redirected to slot [7141] located at 192.168.155.91:6379 (INTEGER) 1 192.168.155.91:6379> Zadd Zset1 1 AA -> Redirected to slot [4341] located at 192.168.155.117:6379 (INTEGER) 1 192.168.155.117:6379> Set a B -> Redirected to slot [15495] located at 192.168.155.112:6379 OK 192.168.155.112:6379> SADD set1 redis -> Redirected to slot [3037] located at 192.168.155.117:6379 (INTEGER) 1 192.168.155.117:6379> [root@liabio ~]# [root@liabio ~]# redis-cli -a test123 --cluster check 192.168.155.117:6379 Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe. 192.168.155.117:6379 (f070ddf6...) - > 3 keys 5461 slots | | 1 slaves. 192.168.155.112:6379 (8 d1e7150...). - > 1 keys 5461 slots | | 1 slaves. 192.168.155.91:6379 (c4ab0276...). - > 1 keys 5462 slots | | 1 slaves. [OK] 5 keys in 3 masters. 0.00 keys per slot on business. > > > Performing Cluster Check (using the node 192.168.155.117:6379) M: F070ddf68e39896af42dc08251199cda7c8b9b92 192.168.155.117:6379 slots: [0-5460] (5461 slots) master 1 additional up (s) S: 1121 a45980f1d5964f0010b331aeb514ff9dedb8 192.168.155.103:6379 slots: (0 slots) slave replicates f070ddf68e39896af42dc08251199cda7c8b9b92 M: 8 d1e71502b9f1c29b3170eb9bf1391ae5aa50650 192.168.155.112:6379 slots: [10923-16383] (5461 slots) 1 additional master Up (s) s: 0 a6188b6bf590c928a2f7b1b0de9aeb206977d72 192.168.155.78:6379 slots: (0 slots) slave replicates 8d1e71502b9f1c29b3170eb9bf1391ae5aa50650 S: 941108 cab0121fc840f909da080d92770dbbdee1 192.168.155.102:6379 slots: (0 slots) slave replicates c4ab027656d55b800cc54063493bca198a5e1385 M: C4ab027656d55b800cc54063493bca198a5e1385 192.168.155.91:6379 slots: [5461-10922] (5462 slots) 1 additional master replica(s) [OK] All nodes agree about slots configuration. >>> Check for open slots... >>> Check slots coverage... [OK] All 16384 slots covered.Copy the code

Expand the cluster to a five-master and five-slave cluster

Add a new master1

[root@liabio ~]# redis-cli --cluster add-node 192.168.155.108:6379 192.168.155.117:6379 -a test123 Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe. >>> Adding node 192.168.155.108:6379 to Cluster 192.168.155.117:6379 >>> Performing Cluster Check (using node 192.168.155.117:6379) M: F070ddf68e39896af42dc08251199cda7c8b9b92 192.168.155.117:6379 slots: [0-5460] (5461 slots) master 1 additional up (s) S: 1121 a45980f1d5964f0010b331aeb514ff9dedb8 192.168.155.103:6379 slots: (0 slots) slave replicates f070ddf68e39896af42dc08251199cda7c8b9b92 M: 8 d1e71502b9f1c29b3170eb9bf1391ae5aa50650 192.168.155.112:6379 slots: [10923-16383] (5461 slots) 1 additional master Up (s) s: 0 a6188b6bf590c928a2f7b1b0de9aeb206977d72 192.168.155.78:6379 slots: (0 slots) slave replicates 8d1e71502b9f1c29b3170eb9bf1391ae5aa50650 S: 941108 cab0121fc840f909da080d92770dbbdee1 192.168.155.102:6379 slots: (0 slots) slave replicates c4ab027656d55b800cc54063493bca198a5e1385 M: C4ab027656d55b800cc54063493bca198a5e1385 192.168.155.91:6379 slots: [5461-10922] (5462 slots) 1 additional master replica(s) [OK] All nodes agree about slots configuration. >>> Check for open slots... >>> Check slots coverage... [OK] All 16384 slots covered. >>> Send CLUSTER MEET to node 192.168.155.108:6379 to make it join the CLUSTER node added correctly.Copy the code

Add new Master2

[root@liabio ~]# redis-cli --cluster add-node 192.168.155.111:6379 192.168.155.117:6379 -a test123 Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe. >>> Adding node 192.168.155.111:6379 to Cluster 192.168.155.117:6379 >>> Performing Cluster Check (using node 192.168.155.117:6379) M: F070ddf68e39896af42dc08251199cda7c8b9b92 192.168.155.117:6379 slots: [0-5460] (5461 slots) master 1 additional up (s) S: 1121 a45980f1d5964f0010b331aeb514ff9dedb8 192.168.155.103:6379 slots: (0 slots) slave replicates f070ddf68e39896af42dc08251199cda7c8b9b92 M: 8 d1e71502b9f1c29b3170eb9bf1391ae5aa50650 192.168.155.112:6379 slots: [10923-16383] (5461 slots) 1 additional master Up (s) s: 0 a6188b6bf590c928a2f7b1b0de9aeb206977d72 192.168.155.78:6379 slots: (0 slots) slave replicates 8d1e71502b9f1c29b3170eb9bf1391ae5aa50650 S: 941108 cab0121fc840f909da080d92770dbbdee1 192.168.155.102:6379 slots: (0 slots) slave replicates c4ab027656d55b800cc54063493bca198a5e1385 M: 78 ad24899c7a7b1c0cad99e2c1afab82e8c98ec2 192.168.155.108:6379 slots: (0 slots) master M: C4ab027656d55b800cc54063493bca198a5e1385 192.168.155.91:6379 slots: [5461-10922] (5462 slots) 1 additional master replica(s) [OK] All nodes agree about slots configuration. >>> Check for open slots... >>> Check slots coverage... [OK] All 16384 slots covered. >>> Send CLUSTER MEET to node 192.168.155.111:6379 to make it join the CLUSTER [root@liabio ~]# redis-cli -a test123 --cluster check 192.168.155.117:6379 Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe. 192.168.155.117:6379 (f070ddf6...) - > 3 keys 5461 slots | | 1 slaves. 192.168.155.111:6379 (1 b3b59ff...). - > 0 keys | 0 slots | 0 slaves. 192.168.155.112:6379 (8 d1e7150...). - > 1 keys 5461 slots | | 1 slaves. 192.168.155.108:6379 (78 ad2489...). - > 0 keys | 0 slots | 0 slaves. 192.168.155.91:6379 (c4ab0276...). - > 1 keys 5462 slots | | 1 slaves. [OK] 5 keys in 5 masters. 0.00 keys per slot on business. > > > Performing Cluster Check (using the node 192.168.155.117:6379) M: F070ddf68e39896af42dc08251199cda7c8b9b92 192.168.155.117:6379 slots: [0-5460] (5461 slots) master 1 additional up (s) M: 1 b3b59ff2b7ecf0ae67568104501450b94aa9ac0 192.168.155.111:6379 slots: (0 slots) master S: 1121 a45980f1d5964f0010b331aeb514ff9dedb8 192.168.155.103:6379 slots: (0 slots) slave replicates f070ddf68e39896af42dc08251199cda7c8b9b92 M: 8 d1e71502b9f1c29b3170eb9bf1391ae5aa50650 192.168.155.112:6379 slots: [10923-16383] (5461 slots) 1 additional master Up (s) s: 0 a6188b6bf590c928a2f7b1b0de9aeb206977d72 192.168.155.78:6379 slots: (0 slots) slave replicates 8d1e71502b9f1c29b3170eb9bf1391ae5aa50650 S: 941108 cab0121fc840f909da080d92770dbbdee1 192.168.155.102:6379 slots: (0 slots) slave replicates c4ab027656d55b800cc54063493bca198a5e1385 M: 78 ad24899c7a7b1c0cad99e2c1afab82e8c98ec2 192.168.155.108:6379 slots: (0 slots) master M: C4ab027656d55b800cc54063493bca198a5e1385 192.168.155.91:6379 slots: [5461-10922] (5462 slots) 1 additional master replica(s) [OK] All nodes agree about slots configuration. >>> Check for open slots... >>> Check slots coverage... [OK] All 16384 slots covered.Copy the code

Add a new Slave1

[root@liabio ~]# redis-cli --cluster add-node 192.168.155.114:6379 192.168.155.117:6379 --cluster-slave --cluster-master-id 78ad24899c7a7b1c0cad99e2c1afab82e8c98ec2 -a test123 Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe. >>> Adding node >>> Performing Cluster Check (using node 192.168.155.117:6379) M: F070ddf68e39896af42dc08251199cda7c8b9b92 192.168.155.117:6379 slots: [0-5460] (5461 slots) master 1 additional up (s) M: 1 b3b59ff2b7ecf0ae67568104501450b94aa9ac0 192.168.155.111:6379 slots: (0 slots) master S: 1121 a45980f1d5964f0010b331aeb514ff9dedb8 192.168.155.103:6379 slots: (0 slots) slave replicates f070ddf68e39896af42dc08251199cda7c8b9b92 M: 8 d1e71502b9f1c29b3170eb9bf1391ae5aa50650 192.168.155.112:6379 slots: [10923-16383] (5461 slots) 1 additional master Up (s) s: 0 a6188b6bf590c928a2f7b1b0de9aeb206977d72 192.168.155.78:6379 slots: (0 slots) slave replicates 8d1e71502b9f1c29b3170eb9bf1391ae5aa50650 S: 941108 cab0121fc840f909da080d92770dbbdee1 192.168.155.102:6379 slots: (0 slots) slave replicates c4ab027656d55b800cc54063493bca198a5e1385 M: 78 ad24899c7a7b1c0cad99e2c1afab82e8c98ec2 192.168.155.108:6379 slots: (0 slots) master M: C4ab027656d55b800cc54063493bca198a5e1385 192.168.155.91:6379 slots: [5461-10922] (5462 slots) 1 additional master replica(s) [OK] All nodes agree about slots configuration. >>> Check for open slots... >>> Check slots coverage... [OK] All 16384 slots covered. >>> Send CLUSTER MEET to node 192.168.155.114:6379 to make it join the cluster.waiting For the cluster to join >>> Configure node as replica of 192.168.155.108:6379. [OK] New node added correctly.Copy the code

Added new Slave2

[root@liabio ~]# redis-cli --cluster add-node 192.168.155.73:6379 192.168.155.117:6379 --cluster-slave --cluster-master-id 1b3b59ff2b7ecf0ae67568104501450b94aa9ac0 -a test123 Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe. >>> Adding node 192.168.155.73:6379 to Cluster 192.168.155.117:6379 >>> Performing Cluster Check (using node 192.168.155.117:6379) M: F070ddf68e39896af42dc08251199cda7c8b9b92 192.168.155.117:6379 slots: [0-5460] (5461 slots) master 1 additional up (s) S: 941108 cab0121fc840f909da080d92770dbbdee1 192.168.155.102:6379 slots: (0 slots) slave replicates c4ab027656d55b800cc54063493bca198a5e1385 M: C4ab027656d55b800cc54063493bca198a5e1385 192.168.155.91:6379 slots: [5461-10922] (5462 slots) 1 additional master Up (s) s: 1121 a45980f1d5964f0010b331aeb514ff9dedb8 192.168.155.103:6379 slots: (0 slots) slave replicates f070ddf68e39896af42dc08251199cda7c8b9b92 M: 1 b3b59ff2b7ecf0ae67568104501450b94aa9ac0 192.168.155.111:6379 slots: master (0 slots) M: 8 d1e71502b9f1c29b3170eb9bf1391ae5aa50650 192.168.155.112:6379 slots: [10923-16383] (5461 slots) 1 additional master Up (s) s: 0 a6188b6bf590c928a2f7b1b0de9aeb206977d72 192.168.155.78:6379 slots: (0 slots) slave replicates 8d1e71502b9f1c29b3170eb9bf1391ae5aa50650 S: 9 dc374d48b730432f726147828cde001ea5a7dc4 192.168.155.114:6379 slots: (0 slots) slave replicates 78ad24899c7a7b1c0cad99e2c1afab82e8c98ec2 M: 78 ad24899c7a7b1c0cad99e2c1afab82e8c98ec2 192.168.155.108:6379 slots: (0 slots) master 1 additional replica(s) [OK] All nodes agree about slots configuration. >>> Check for open slots... >>> Check slots coverage... [OK] All 16384 slots covered. >>> Send CLUSTER MEET to node 192.168.155.73:6379 to make it join the CLUSTER The cluster to join >>> Configure node as replica of 192.168.155.111:6379. [OK] New node added correctly.Copy the code

Migration card slot

Rebalance using the rebalance subcommand:

[root@liabio ~]# redis-cli --cluster rebalance --cluster-use-empty-masters --cluster-pipeline 100 192.168.155.117:6379 -a test123
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
>>> Performing Cluster Check (using node 192.168.155.117:6379)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
>>> Rebalancing across 5 nodes. Total weight = 5.00
Moving 2186 slots from 192.168.155.91:6379 to 192.168.155.111:6379
##########################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################
Moving 1092 slots from 192.168.155.112:6379 to 192.168.155.111:6379
####################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################
Moving 1093 slots from 192.168.155.112:6379 to 192.168.155.108:6379
#####################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################
Moving 2185 slots from 192.168.155.117:6379 to 192.168.155.108:6379
#########################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################
[root@liabio ~]# Copy the code

conclusion

As you can see from the above,Redis - cli5.0.7Version of the client can be operatedWith the passwordtheRedis cluster version 4.0.7The following syntax error is not reported for card slot migrationERR syntax error

The author is simple

Author: Xiaowantang, a passionate and serious writer, currently maintains the original public account “My Xiaowantang”, focusing on writing the go language, Docker, Kubernetes, Java and other development, operation and maintenance knowledge to enhance the hard power of the article, looking forward to your attention. Note: Be sure to specify the source (note: from the official account: My Small bowl of soup, author: Small bowl of soup)