From 580b6234224213add9d4c2da78eda4c7e93e5b7c Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 16 Feb 2021 15:05:53 +0800 Subject: [PATCH] up --- plugins/mysql/conf/my.cnf | 2 +- plugins/mysql/conf/my8.0.cnf | 2 +- plugins/mysql/index.py | 19 ++++++++++++++++++- plugins/mysql/js/mysql.js | 24 ++++++++++++------------ 4 files changed, 32 insertions(+), 15 deletions(-) diff --git a/plugins/mysql/conf/my.cnf b/plugins/mysql/conf/my.cnf index 2a6b58fbd..9d44bab02 100644 --- a/plugins/mysql/conf/my.cnf +++ b/plugins/mysql/conf/my.cnf @@ -47,7 +47,7 @@ long_query_time=3 relay-log=mdserver relay-log-index=mdserver -#master config +#master #binlog-do-db binlog-ignore-db = test binlog-ignore-db = mysql diff --git a/plugins/mysql/conf/my8.0.cnf b/plugins/mysql/conf/my8.0.cnf index 8b3cc872a..ab5352f30 100644 --- a/plugins/mysql/conf/my8.0.cnf +++ b/plugins/mysql/conf/my8.0.cnf @@ -45,7 +45,7 @@ long_query_time=3 relay-log=mdserver relay-log-index=mdserver -#master config +#master #binlog-do-db binlog-ignore-db = test binlog-ignore-db = mysql diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index 034604d4e..c3bd690c3 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -1371,7 +1371,6 @@ def setDbSlave(version): isHas = False for x in xrange(0, len(dodb)): - if dodb[x][1] == args['name']: isHas = True @@ -1415,6 +1414,24 @@ def setMasterStatus(version=''): if con.find('#log-bin') != -1: return mw.returnJson(False, '必须开启二进制日志') + + sign = 'mdserver_ms_open' + + dodb = findBinlogDoDb() + if not sign in dodb: + prefix = '#binlog-do-db' + con = con.replace(prefix, prefix + "\nbinlog-do-db=" + sign) + mw.writeFile(conf, con) + else: + con = con.replace("binlog-do-db=" + sign + "\n", '') + rep = r"(binlog-do-db\s*?=\s*?(.*))" + dodb = re.findall(rep, con, re.M) + for x in xrange(0, len(dodb)): + con = con.replace(dodb[x][0] + "\n", '') + mw.writeFile(conf, con) + + restart(version) + time.sleep(2) return mw.returnJson(True, '设置成功') diff --git a/plugins/mysql/js/mysql.js b/plugins/mysql/js/mysql.js index b29e9769b..a4cd35aa6 100755 --- a/plugins/mysql/js/mysql.js +++ b/plugins/mysql/js/mysql.js @@ -1688,15 +1688,15 @@ function masterOrSlaveConf(version=''){ $(".soft-man-con").html(limitCon); //设置主服务器配置 - // $(".btn-master").click(function () { - // myPost('set_master_status', 'close=change', function(data){ - // var rdata = $.parseJSON(data.data); - // layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 }); - // setTimeout(function(){ - // getMasterStatus(); - // }, 3000); - // }); - // }); + $(".btn-master").click(function () { + myPost('set_master_status', 'close=change', function(data){ + var rdata = $.parseJSON(data.data); + layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 }); + setTimeout(function(){ + getMasterStatus(); + }, 3000); + }); + }); $(".btn-slave").click(function () { myPost('set_slave_status', 'close=change', function(data){ @@ -1708,9 +1708,9 @@ function masterOrSlaveConf(version=''){ }); }); - // if (rdata.status){ - getMasterDbList(); - // } + if (rdata.status){ + getMasterDbList(); + } if (rdata.data.slave_status){ getAsyncMasterDbList();