Created
January 26, 2021 21:24
-
-
Save maguec/a06c3f517d2d4b16c34253ed0915e646 to your computer and use it in GitHub Desktop.
Show Raft Groups
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
# Be sure to run | |
# pip3 install redis-py-cluster | |
# pip3 install redis | |
# for Python Redis Utils | |
from rediscluster import RedisCluster | |
startup_nodes = [{"host": "127.0.0.1", "port": "19901"}] | |
rc = RedisCluster(startup_nodes=startup_nodes, decode_responses=True) | |
slots = rc.cluster_slots() | |
print("%5s - %-5s %-15s %7s %s" %("start", "end", "IP", "Port", "Replicas")) | |
for slot in sorted(slots): | |
print("%5d - %5d %-15s %7d %d" %(slot[0], slot[1], slots[slot]['master'][0], slots[slot]['master'][1], len(slots[slot]['slaves']))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment