Created
July 25, 2014 17:46
-
-
Save therealbill/56379cbb3645e7ddad03 to your computer and use it in GitHub Desktop.
A simple means for replication a sentinel's in-memory config to a new sentinel.
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 python | |
import redis | |
import sys | |
origin_ip,origin_port = sys.argv[1].split(":") | |
target_ip,target_port = sys.argv[2].split(":") | |
origin = redis.Redis(origin_ip,origin_port) | |
target = redis.Redis(target_ip,target_port) | |
masters = origin.sentinel_masters() | |
copy_keys = [ 'down-after-milliseconds', 'failover-timeout', 'parallel-syncs' ] | |
for pod in masters.values(): | |
p = target.pipeline(transaction=False) | |
p.sentinel_monitor(pod['name'], pod['ip'],pod['port'],pod['quorum'] ) | |
for key in copy_keys: | |
print key, pod[key] | |
p.sentinel_set(pod['name'],key, pod[key]) | |
print p.execute() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment