您好,登錄后才能下訂單哦!
這篇文章主要介紹100臺(tái)redis如何批量關(guān)閉主庫(kù)aof開(kāi)啟從庫(kù)aof,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!
#!/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) #此句忽略,這會(huì)寫(xiě)一個(gè)帶日期的key,用來(lái)監(jiān)控主從同步,基于業(yè)務(wù)的監(jiān)控. 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臺(tái)redis如何批量關(guān)閉主庫(kù)aof開(kāi)啟從庫(kù)aof”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。