首页 > 其他 > 详细

100台redis批量关闭主库aof开启从库aof

时间:2018-07-03 14:19:58      阅读:355      评论:0      收藏:0      [点我收藏+]
#!/usr/bin/env python #encoding = utf-8   """ author: luhuijun create on time: 20171002 config File Mode 127.0.0.1,6379,xxxxxxxx,0 127.0.0.1,6380,xxxxxxxx,0 """ import datetime import 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)             #此句忽略,这会写一个带日期的key,用来监控主从同步,基于业务的监控.             k,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()

100台redis批量关闭主库aof开启从库aof

原文:http://blog.51cto.com/xinle/2135503

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!