Get the master-slave relationship of redis cluster

 

Requirements: Use the cluster slots command to obtain the master-slave correspondence of redis cluster.

 

Description: Field description corresponding to the cluster slots command: http://redis.cn/commands/cluster-slots.html

 

redis-cli -h IP -p PORT -a PASSWD -c cluster slots | xargs  -n8 | awk '{print $3":"$4"->"$6":"$7}' | sort -nk2 -t ':' | uniq

 

Test Results:

[redis@lxd-vm1 ~]$ redis-cli -h 5.5.5.101 -p 29001 -c cluster slots | xargs  -n8 | awk '{print $3":"$4"->"$6":"$7}' | sort -nk2 -t ':' | uniq
5.5.5.102:29001->5.5.5.101:29001
5.5.5.103:29002->5.5.5.102:29002
5.5.5.101:29003->5.5.5.103:29003

 

Requirements: Use the cluster slots command to obtain the master-slave correspondence of redis cluster.

 

Description: Field description corresponding to the cluster slots command: http://redis.cn/commands/cluster-slots.html

 

redis-cli -h IP -p PORT -a PASSWD -c cluster slots | xargs  -n8 | awk '{print $3":"$4"->"$6":"$7}' | sort -nk2 -t ':' | uniq

 

Test Results:

[redis@lxd-vm1 ~]$ redis-cli -h 5.5.5.101 -p 29001 -c cluster slots | xargs  -n8 | awk '{print $3":"$4"->"$6":"$7}' | sort -nk2 -t ':' | uniq
5.5.5.102:29001->5.5.5.101:29001
5.5.5.103:29002->5.5.5.102:29002
5.5.5.101:29003->5.5.5.103:29003

 

Guess you like

Origin www.cnblogs.com/zhangrui153169/p/12697003.html