Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to close the master library aof and turn on the slave library aof in batch for 100th redis

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces 100 sets of redis how to batch close the master library aof to open the slave library aof, the article introduces in great detail, has a certain reference value, interested friends must read it!

#! / usr/bin/env python#encoding = utf-8 "" author: luhuijuncreate on time: 20171002config File Mode127.0.0.1,6379,xxxxxxxx,0127.0.0.1,6380,xxxxxxxx,0 "" import datetimeimport redis def redis_conect (host,port,passwd,db): r = redis.Redis (host=host, port=port, db=0) return r def readconfig (path): file=open (path) "r") result=file.readlines () return result file.close () def main (): try: result= readconfig ('.. / etc/check_redis_cluster_config.ini') for i in result: i=i.split (",") mhost,mport,mpasswd, mdb = I [0], I [1], I [2], I [3] m = redis_conect (mhost,mport,mpasswd) Mdb) # this sentence ignores, this will write a key with a date, used to monitor master-slave synchronization, business-based monitoring. KBEI v = 'dba_check' Datetime.datetime.now () .strftime ("% Y-%m-%d% H:%M:%S") roles = m.info ("replication") ['role'] if roles = =' master': # print m.info () if m.config_get ("appendonly") ['appendonly'] = =' yes': m.config_set ('appendonly' ") 'no') m.config_rewrite () else: continue else: if m.config_get ("appendonly") [' appendonly'] = 'no': m.config_set ("appendonly") "yes") m.config_rewrite () else: continue except Exception,ex: print Exception, ":", ex if _ _ name__== "_ _ main__": main () above are all the contents of the article "how to shut down the master library aof and enable the slave library aof in batch by 100redis" Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report