From 42d8d828c53561ad6eb6f11317ea2f733adb4b0a Mon Sep 17 00:00:00 2001 From: midoks Date: Fri, 5 Aug 2022 20:53:44 +0800 Subject: [PATCH] ip --- plugins/mysql/conf/my.cnf | 3 ++- plugins/mysql/conf/my5.7.cnf | 3 ++- plugins/mysql/conf/my8.0.cnf | 3 ++- plugins/mysql/index.py | 33 +++++++++++++++++++++++---------- 4 files changed, 29 insertions(+), 13 deletions(-) diff --git a/plugins/mysql/conf/my.cnf b/plugins/mysql/conf/my.cnf index 3b8877bb8..39f337d81 100644 --- a/plugins/mysql/conf/my.cnf +++ b/plugins/mysql/conf/my.cnf @@ -66,7 +66,8 @@ binlog-ignore-db = information_schema binlog-ignore-db = performance_schema #slave -log-slave-updates +log-slave-updates = 1 +skip-slave-start = 1 #replicate-do-db replicate-ignore-db = information_schema replicate-ignore-db = performance_schema diff --git a/plugins/mysql/conf/my5.7.cnf b/plugins/mysql/conf/my5.7.cnf index 0abb062c5..15e61c4b3 100644 --- a/plugins/mysql/conf/my5.7.cnf +++ b/plugins/mysql/conf/my5.7.cnf @@ -66,7 +66,8 @@ binlog-ignore-db = information_schema binlog-ignore-db = performance_schema #slave -log-slave-updates +log-slave-updates = 1 +skip-slave-start = 1 #replicate-do-db replicate-ignore-db = information_schema replicate-ignore-db = performance_schema diff --git a/plugins/mysql/conf/my8.0.cnf b/plugins/mysql/conf/my8.0.cnf index 2bfd30770..cde7766e4 100644 --- a/plugins/mysql/conf/my8.0.cnf +++ b/plugins/mysql/conf/my8.0.cnf @@ -68,7 +68,8 @@ binlog-ignore-db = information_schema binlog-ignore-db = performance_schema #slave -log_replica_updates +log_replica_updates = 1 +skip-slave-start = 1 #replicate-do-db replicate-ignore-db = information_schema replicate-ignore-db = performance_schema diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index 8e178b2c7..1bcfc1124 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -1777,18 +1777,31 @@ def getMasterRepSlaveUserCmd(version): if len(mstatus) == 0: return mw.returnJson(False, '未开启!') - sql = "CHANGE MASTER TO MASTER_HOST='" + ip + "', MASTER_PORT=" + port + ", MASTER_USER='" + \ - clist[0]['username'] + "', MASTER_PASSWORD='" + \ - clist[0]['password'] + \ - "', MASTER_LOG_FILE='" + mstatus[0]["File"] + \ - "',MASTER_LOG_POS=" + str(mstatus[0]["Position"]) + mode = recognizeDbMode() - if version == "8.0": - sql = "CHANGE REPLICATION SOURCE TO SOURCE_HOST='" + ip + "', SOURCE_PORT=" + port + ", SOURCE_USER='" + \ - clist[0]['username'] + "', SOURCE_PASSWORD='" + \ + if mode == "gtid": + sql = "CHANGE MASTER TO MASTER_HOST='" + ip + "', MASTER_PORT=" + port + ", MASTER_USER='" + \ + clist[0]['username'] + "', MASTER_PASSWORD='" + \ + clist[0]['password'] + \ + "', MASTER_AUTO_POSITION=1" + if version == '8.0': + sql = "CHANGE REPLICATION SOURCE TO SOURCE_HOST='" + ip + "', SOURCE_PORT=" + port + ", SOURCE_USER='" + \ + clist[0]['username'] + "', SOURCE_PASSWORD='" + \ + clist[0]['password'] + \ + "', MASTER_AUTO_POSITION=1" + else: + sql = "CHANGE MASTER TO MASTER_HOST='" + ip + "', MASTER_PORT=" + port + ", MASTER_USER='" + \ + clist[0]['username'] + "', MASTER_PASSWORD='" + \ clist[0]['password'] + \ - "', SOURCE_LOG_FILE='" + mstatus[0]["File"] + \ - "',SOURCE_LOG_POS=" + str(mstatus[0]["Position"]) + "', MASTER_LOG_FILE='" + mstatus[0]["File"] + \ + "',MASTER_LOG_POS=" + str(mstatus[0]["Position"]) + + if version == "8.0": + sql = "CHANGE REPLICATION SOURCE TO SOURCE_HOST='" + ip + "', SOURCE_PORT=" + port + ", SOURCE_USER='" + \ + clist[0]['username'] + "', SOURCE_PASSWORD='" + \ + clist[0]['password'] + \ + "', SOURCE_LOG_FILE='" + mstatus[0]["File"] + \ + "',SOURCE_LOG_POS=" + str(mstatus[0]["Position"]) data = {} data['cmd'] = sql