重慶分公司,新征程啟航
為企業提供網站建設、域名注冊、服務器等服務
為企業提供網站建設、域名注冊、服務器等服務
這篇文章主要介紹100臺redis如何批量關閉主庫aof開啟從庫aof,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!
公司主營業務:網站設計制作、網站制作、移動網站開發等業務。幫助企業客戶真正實現互聯網宣傳,提高企業的競爭能力。創新互聯是一支青春激揚、勤奮敬業、活力青春激揚、勤奮敬業、活力澎湃、和諧高效的團隊。公司秉承以“開放、自由、嚴謹、自律”為核心的企業文化,感謝他們對我們的高要求,感謝他們從不同領域給我們帶來的挑戰,讓我們激情的團隊有機會用頭腦與智慧不斷的給客戶帶來驚喜。創新互聯推出武江免費做網站回饋大家。
#!/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”這篇文章的所有內容,感謝各位的閱讀!希望分享的內容對大家有幫助,更多相關知識,歡迎關注創新互聯行業資訊頻道!