Preface
Before redis 5.0.0, the script redis-trib.rb written by ruby was used to operate redis cluster. The disadvantage of this is that Ruby and gems environment need to be installed. There is no Ruby environment such as redis-trib.rb in the official docker image, which needs to be installed by itself. It is time-consuming, complex and not easy to succeed in the domestic network environment, and the final docker image made is also large.Additionally, incorrect Ruby and redis extensions can cause various errors when operating clusters.
The most important hard injury is that redis-trib.rb cannot operate on a passwordd redis cluster, although some on github already have password support based on the redis-trib.rb script.But for the operation related to the migration slot of move_slots, I tried it or did not add it.You can view the following submission records:
Redis-Cluster: Add support to auth in redis-trib.rb #4288
After redis 5.0.0, redis-cli can directly operate the redis cluster and support password operation, which brings great convenience.However, before redis4.0.7, the password auth parameter was not supported by the migration card slot, and [AUTH password] in the following command was only supported by redis4.0.7.
MIGRATE host port key|"" destination-db timeout [COPY] [REPLACE] [AUTH password] [KEYS key [key ...]]
Specifically, you can view the official documents: MIGRATE Description Document
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 is available starting with Redis 3.0.6. AUTH is available starting with Redis 4.0.7.
When we recently containerized, we used version redis 3.2.6. When redis cluster had data (when hash data is present) and had passwords, when 3 Masters 3 expanded from 3 Masters to 5 Masters 5 Slaves, we operated redis 3.2.6 cluster with 5.0.7 redis-cli and reported ERR syntax error error when executing the migration card slot command.
An error [ERR] Calling MIGRATE: ERR Target instance response with error: NOAUTH Authentication required:
This is because redis-trib.rb on github does not encrypt the code parameters during the move_slots operation.So, I try to pass in the password parameter myself at the location of the migration card slot, like the following:
source.r.client.call(["migrate",target.info[:host],target.info[:port],"",0,@timeout,:auth,target.info[:password],:keys,*keys])
ERR syntax error is also reported when slot migration is performed after adding.As you can see, the redis3.2.6 cluster does not support password parameters when migrating.The following verifies that the card slots can be migrate d properly on the redis4.0.7 cluster.
Create a three-master, three-slave cluster
Create configmaps
Save the following to the redis-test.conf file:
#Set as Daemon daemonize no #Process pid file run by Redis pidfile redis-6397.pid #Redis Service Port Number port 6379 #Redis service binding ip #bind 192.168.100.144 bind {PODIP} #Maximum memory maxmemory 2g #Turn on cluster mode cluster-enabled yes #Node Profile cluster-config-file nodes-6397.conf #Cluster node timeout (in milliseconds) cluster-node-timeout 15000 #Does the cluster require all slot s to be allocated to online nodes for normal access cluster-require-full-coverage no #Working directory (aof, rdb, log files) dir /data #tcp-backlog tcp-backlog 511 #Close the connection after how many seconds the client is idle (in seconds) timeout 300 #Cycle (in seconds) to detect TCP connection activity tcp-keepalive 60 #redis password requirepass test123 masterauth test123 #log level loglevel notice #Logging Directory logfile "redis-6397.log" #Number of databases available databases 16 #RDB Save Conditions save 900 1 save 300 10 save 60 10000 #bgsave execution error, stop Redis accepting request stop-writes-on-bgsave-error no #Is RDB file compressed rdbcompression yes #Whether RDB files use checksums rdbchecksum yes #RDB File Name dbfilename dump-6397.rdb #If this parameter value is set to "yes" when the connection between the slave node and the primary node is broken, the slave node can continue to process the client's #Request.Otherwise except info and slaveof All requests rejected and unified responses except commands"SYNC with master in #progress" slave-serve-stale-data yes #Whether read-only mode is enabled from a node or not, default read-write from a node is unavailable under the cluster architecture and needs to be invoked readyonly command#Turn on read-only mode slave-read-only yes #Whether to turn on diskless copy repl-diskless-sync no #How many seconds to delay creation after turning on diskless copy RDB Operation, typically used when joining multiple slave nodes at the same time,#Ensure multiple slave nodes can share RDB repl-diskless-sync-delay 5 #Whether to turn on master-slave replication socket Of NO_DELAY Options: yes:Redis Will merge small TCP Packets save bandwidth, but##This increases the synchronization delay, causing the primary#Inconsistent secondary data; no: primary node sends synchronized data immediately with no delay repl-disable-tcp-nodelay no #Priority of slave nodes slave-priority 100 #Whether to turn on AOF persistence mode appendonly no #Lua script "Timeout" (in milliseconds) lua-time-limit 5000 #Slow query logged threshold (in microseconds) slowlog-log-slower-than 10000 #Maximum number of records for slow queries slowlog-max-len 1000 #Redis Service Memory Latency 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 hll-sparse-max-bytes 3000 #Is Reset Hash Activated activerehashing yes #Client Output Buffer Limit 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 backlog cache size repl-backlog-size 256mb #The frequency at which redis server executes background tasks, defaulting to 10 hz 10 #Maximum number of client connections maxclients 15000
Use the following command to create configmaps:
kubectl create cm redis-test-conf --from-file=redis.conf=redis-test.conf
Create a redis instance
Save the following yaml content in 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 ;redis-server /data/redis.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: RollingUpdate
Using a docker image of redis:4.0.7, create the following 10 pod s:
[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>
Operating clusters using redis-cli 5.0.7
Operating clusters using redis-cli version 5.0.7:
[root@liabio ~]# redis-cli -v redis-cli 5.0.7
Create a 3master cluster
Start with three master s to 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: 8d1e71502b9f1c29b3170eb9bf1391ae5aa50650 192.168.155.112:6379 slots:[10923-16383] (5461 slots) 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: 8d1e71502b9f1c29b3170eb9bf1391ae5aa50650 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.
Add 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: 8d1e71502b9f1c29b3170eb9bf1391ae5aa50650 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. Waiting for the cluster to join >>> Configure node as replica of 192.168.155.117:6379. [OK] New node added correctly.
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 replica(s) S: 1121a45980f1d5964f0010b331aeb514ff9dedb8 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: 8d1e71502b9f1c29b3170eb9bf1391ae5aa50650 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.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.
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 replica(s) S: 1121a45980f1d5964f0010b331aeb514ff9dedb8 192.168.155.103:6379 slots: (0 slots) slave replicates f070ddf68e39896af42dc08251199cda7c8b9b92 M: 8d1e71502b9f1c29b3170eb9bf1391ae5aa50650 192.168.155.112:6379 slots:[10923-16383] (5461 slots) master S: 941108cab0121fc840f909da080d92770dbbdee1 192.168.155.102:6379 slots: (0 slots) slave replicates c4ab027656d55b800cc54063493bca198a5e1385 M: c4ab027656d55b800cc54063493bca198a5e1385 192.168.155.91:6379 slots:[5461-10922] (5462 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.78:6379 to make it join the cluster. Waiting for the cluster to join >>> Configure node as replica of 192.168.155.112:6379. [OK] New node added correctly. [root@liabio ~]#
Add various data types to the cluster
Set hash1 of hash type in cluster; list1 of list type; zset1 of sorted set type; a of string type; set1 of set type
[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.117: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 (8d1e7150...) -> 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 average. >>> 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 replica(s) S: 1121a45980f1d5964f0010b331aeb514ff9dedb8 192.168.155.103:6379 slots: (0 slots) slave replicates f070ddf68e39896af42dc08251199cda7c8b9b92 M: 8d1e71502b9f1c29b3170eb9bf1391ae5aa50650 192.168.155.112:6379 slots:[10923-16383] (5461 slots) master 1 additional replica(s) S: 0a6188b6bf590c928a2f7b1b0de9aeb206977d72 192.168.155.78:6379 slots: (0 slots) slave replicates 8d1e71502b9f1c29b3170eb9bf1391ae5aa50650 S: 941108cab0121fc840f909da080d92770dbbdee1 192.168.155.102:6379 slots: (0 slots) slave replicates c4ab027656d55b800cc54063493bca198a5e1385 M: c4ab027656d55b800cc54063493bca198a5e1385 192.168.155.91:6379 slots:[5461-10922] (5462 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.
Expand capacity to five-master-five-slave cluster
Add a new master 1
[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 replica(s) S: 1121a45980f1d5964f0010b331aeb514ff9dedb8 192.168.155.103:6379 slots: (0 slots) slave replicates f070ddf68e39896af42dc08251199cda7c8b9b92 M: 8d1e71502b9f1c29b3170eb9bf1391ae5aa50650 192.168.155.112:6379 slots:[10923-16383] (5461 slots) master 1 additional replica(s) S: 0a6188b6bf590c928a2f7b1b0de9aeb206977d72 192.168.155.78:6379 slots: (0 slots) slave replicates 8d1e71502b9f1c29b3170eb9bf1391ae5aa50650 S: 941108cab0121fc840f909da080d92770dbbdee1 192.168.155.102:6379 slots: (0 slots) slave replicates c4ab027656d55b800cc54063493bca198a5e1385 M: c4ab027656d55b800cc54063493bca198a5e1385 192.168.155.91:6379 slots:[5461-10922] (5462 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.108:6379 to make it join the cluster. [OK] New node added correctly.
Add a 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 replica(s) S: 1121a45980f1d5964f0010b331aeb514ff9dedb8 192.168.155.103:6379 slots: (0 slots) slave replicates f070ddf68e39896af42dc08251199cda7c8b9b92 M: 8d1e71502b9f1c29b3170eb9bf1391ae5aa50650 192.168.155.112:6379 slots:[10923-16383] (5461 slots) master 1 additional replica(s) S: 0a6188b6bf590c928a2f7b1b0de9aeb206977d72 192.168.155.78:6379 slots: (0 slots) slave replicates 8d1e71502b9f1c29b3170eb9bf1391ae5aa50650 S: 941108cab0121fc840f909da080d92770dbbdee1 192.168.155.102:6379 slots: (0 slots) slave replicates c4ab027656d55b800cc54063493bca198a5e1385 M: 78ad24899c7a7b1c0cad99e2c1afab82e8c98ec2 192.168.155.108:6379 slots: (0 slots) master M: c4ab027656d55b800cc54063493bca198a5e1385 192.168.155.91:6379 slots:[5461-10922] (5462 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.111:6379 to make it join the cluster. [OK] New node added correctly. [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 (1b3b59ff...) -> 0 keys | 0 slots | 0 slaves. 192.168.155.112:6379 (8d1e7150...) -> 1 keys | 5461 slots | 1 slaves. 192.168.155.108:6379 (78ad2489...) -> 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 average. >>> 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 replica(s) M: 1b3b59ff2b7ecf0ae67568104501450b94aa9ac0 192.168.155.111:6379 slots: (0 slots) master S: 1121a45980f1d5964f0010b331aeb514ff9dedb8 192.168.155.103:6379 slots: (0 slots) slave replicates f070ddf68e39896af42dc08251199cda7c8b9b92 M: 8d1e71502b9f1c29b3170eb9bf1391ae5aa50650 192.168.155.112:6379 slots:[10923-16383] (5461 slots) master 1 additional replica(s) S: 0a6188b6bf590c928a2f7b1b0de9aeb206977d72 192.168.155.78:6379 slots: (0 slots) slave replicates 8d1e71502b9f1c29b3170eb9bf1391ae5aa50650 S: 941108cab0121fc840f909da080d92770dbbdee1 192.168.155.102:6379 slots: (0 slots) slave replicates c4ab027656d55b800cc54063493bca198a5e1385 M: 78ad24899c7a7b1c0cad99e2c1afab82e8c98ec2 192.168.155.108:6379 slots: (0 slots) master M: c4ab027656d55b800cc54063493bca198a5e1385 192.168.155.91:6379 slots:[5461-10922] (5462 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.
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 192.168.155.114: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 replica(s) M: 1b3b59ff2b7ecf0ae67568104501450b94aa9ac0 192.168.155.111:6379 slots: (0 slots) master S: 1121a45980f1d5964f0010b331aeb514ff9dedb8 192.168.155.103:6379 slots: (0 slots) slave replicates f070ddf68e39896af42dc08251199cda7c8b9b92 M: 8d1e71502b9f1c29b3170eb9bf1391ae5aa50650 192.168.155.112:6379 slots:[10923-16383] (5461 slots) master 1 additional replica(s) S: 0a6188b6bf590c928a2f7b1b0de9aeb206977d72 192.168.155.78:6379 slots: (0 slots) slave replicates 8d1e71502b9f1c29b3170eb9bf1391ae5aa50650 S: 941108cab0121fc840f909da080d92770dbbdee1 192.168.155.102:6379 slots: (0 slots) slave replicates c4ab027656d55b800cc54063493bca198a5e1385 M: 78ad24899c7a7b1c0cad99e2c1afab82e8c98ec2 192.168.155.108:6379 slots: (0 slots) master M: c4ab027656d55b800cc54063493bca198a5e1385 192.168.155.91:6379 slots:[5461-10922] (5462 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.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.
Add a 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 replica(s) S: 941108cab0121fc840f909da080d92770dbbdee1 192.168.155.102:6379 slots: (0 slots) slave replicates c4ab027656d55b800cc54063493bca198a5e1385 M: c4ab027656d55b800cc54063493bca198a5e1385 192.168.155.91:6379 slots:[5461-10922] (5462 slots) master 1 additional replica(s) S: 1121a45980f1d5964f0010b331aeb514ff9dedb8 192.168.155.103:6379 slots: (0 slots) slave replicates f070ddf68e39896af42dc08251199cda7c8b9b92 M: 1b3b59ff2b7ecf0ae67568104501450b94aa9ac0 192.168.155.111:6379 slots: (0 slots) master M: 8d1e71502b9f1c29b3170eb9bf1391ae5aa50650 192.168.155.112:6379 slots:[10923-16383] (5461 slots) master 1 additional replica(s) S: 0a6188b6bf590c928a2f7b1b0de9aeb206977d72 192.168.155.78:6379 slots: (0 slots) slave replicates 8d1e71502b9f1c29b3170eb9bf1391ae5aa50650 S: 9dc374d48b730432f726147828cde001ea5a7dc4 192.168.155.114:6379 slots: (0 slots) slave replicates 78ad24899c7a7b1c0cad99e2c1afab82e8c98ec2 M: 78ad24899c7a7b1c0cad99e2c1afab82e8c98ec2 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. Waiting for the cluster to join >>> Configure node as replica of 192.168.155.111:6379. [OK] New node added correctly.
Migration card slot
Make slot assignments 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 ~]#
epilogue
As you can see from the above, the redis-cli version 5.0.7 client can operate the 4.0.7 redis cluster with a password, and slot migration will not report the following syntax error ERR syntax error
Author concise
Author: Xiao Bou Tang, a devoted and conscientious writer, currently maintains the original public number:'My Small Bowl Soup', focusing on the development of go language, docker, kubernetes, java, operation and maintenance knowledge and other articles to improve hard power, and looking forward to your attention.Reprint instructions: Always indicate the source (Note: From Public Number: My Small Bowl Soup, Author: Small Bowl Soup)