|
|
@ -88,7 +88,7 @@ def getConf(): |
|
|
|
def getDbPort(): |
|
|
|
def getDbPort(): |
|
|
|
file = getConf() |
|
|
|
file = getConf() |
|
|
|
content = mw.readFile(file) |
|
|
|
content = mw.readFile(file) |
|
|
|
rep = 'port\s*=\s*(.*)' |
|
|
|
rep = r'port\s*=\s*(.*)' |
|
|
|
tmp = re.search(rep, content) |
|
|
|
tmp = re.search(rep, content) |
|
|
|
return tmp.groups()[0].strip() |
|
|
|
return tmp.groups()[0].strip() |
|
|
|
|
|
|
|
|
|
|
@ -96,7 +96,7 @@ def getDbPort(): |
|
|
|
def getDbServerId(): |
|
|
|
def getDbServerId(): |
|
|
|
file = getConf() |
|
|
|
file = getConf() |
|
|
|
content = mw.readFile(file) |
|
|
|
content = mw.readFile(file) |
|
|
|
rep = 'server-id\s*=\s*(.*)' |
|
|
|
rep = r'server-id\s*=\s*(.*)' |
|
|
|
tmp = re.search(rep, content) |
|
|
|
tmp = re.search(rep, content) |
|
|
|
return tmp.groups()[0].strip() |
|
|
|
return tmp.groups()[0].strip() |
|
|
|
|
|
|
|
|
|
|
@ -104,7 +104,7 @@ def getDbServerId(): |
|
|
|
def getSocketFile(): |
|
|
|
def getSocketFile(): |
|
|
|
file = getConf() |
|
|
|
file = getConf() |
|
|
|
content = mw.readFile(file) |
|
|
|
content = mw.readFile(file) |
|
|
|
rep = 'socket\s*=\s*(.*)' |
|
|
|
rep = r'socket\s*=\s*(.*)' |
|
|
|
tmp = re.search(rep, content) |
|
|
|
tmp = re.search(rep, content) |
|
|
|
return tmp.groups()[0].strip() |
|
|
|
return tmp.groups()[0].strip() |
|
|
|
|
|
|
|
|
|
|
@ -112,14 +112,14 @@ def getSocketFile(): |
|
|
|
def getErrorLogsFile(): |
|
|
|
def getErrorLogsFile(): |
|
|
|
file = getConf() |
|
|
|
file = getConf() |
|
|
|
content = mw.readFile(file) |
|
|
|
content = mw.readFile(file) |
|
|
|
rep = 'log-error\s*=\s*(.*)' |
|
|
|
rep = r'log-error\s*=\s*(.*)' |
|
|
|
tmp = re.search(rep, content) |
|
|
|
tmp = re.search(rep, content) |
|
|
|
return tmp.groups()[0].strip() |
|
|
|
return tmp.groups()[0].strip() |
|
|
|
|
|
|
|
|
|
|
|
def getAuthPolicy(): |
|
|
|
def getAuthPolicy(): |
|
|
|
file = getConf() |
|
|
|
file = getConf() |
|
|
|
content = mw.readFile(file) |
|
|
|
content = mw.readFile(file) |
|
|
|
rep = 'authentication_policy\s*=\s*(.*)' |
|
|
|
rep = r'authentication_policy\s*=\s*(.*)' |
|
|
|
tmp = re.search(rep, content) |
|
|
|
tmp = re.search(rep, content) |
|
|
|
if tmp: |
|
|
|
if tmp: |
|
|
|
return tmp.groups()[0].strip() |
|
|
|
return tmp.groups()[0].strip() |
|
|
@ -302,7 +302,7 @@ def status(version=''): |
|
|
|
def getDataDir(): |
|
|
|
def getDataDir(): |
|
|
|
file = getConf() |
|
|
|
file = getConf() |
|
|
|
content = mw.readFile(file) |
|
|
|
content = mw.readFile(file) |
|
|
|
rep = 'datadir\s*=\s*(.*)' |
|
|
|
rep = r'datadir\s*=\s*(.*)' |
|
|
|
tmp = re.search(rep, content) |
|
|
|
tmp = re.search(rep, content) |
|
|
|
return tmp.groups()[0].strip() |
|
|
|
return tmp.groups()[0].strip() |
|
|
|
|
|
|
|
|
|
|
@ -310,7 +310,7 @@ def getDataDir(): |
|
|
|
def getLogBinName(): |
|
|
|
def getLogBinName(): |
|
|
|
file = getConf() |
|
|
|
file = getConf() |
|
|
|
content = mw.readFile(file) |
|
|
|
content = mw.readFile(file) |
|
|
|
rep = 'log-bin\s*=\s*(.*)' |
|
|
|
rep = r'log-bin\s*=\s*(.*)' |
|
|
|
tmp = re.search(rep, content) |
|
|
|
tmp = re.search(rep, content) |
|
|
|
return tmp.groups()[0].strip() |
|
|
|
return tmp.groups()[0].strip() |
|
|
|
|
|
|
|
|
|
|
@ -318,7 +318,7 @@ def getLogBinName(): |
|
|
|
def getPidFile(): |
|
|
|
def getPidFile(): |
|
|
|
file = getConf() |
|
|
|
file = getConf() |
|
|
|
content = mw.readFile(file) |
|
|
|
content = mw.readFile(file) |
|
|
|
rep = 'pid-file\s*=\s*(.*)' |
|
|
|
rep = r'pid-file\s*=\s*(.*)' |
|
|
|
tmp = re.search(rep, content) |
|
|
|
tmp = re.search(rep, content) |
|
|
|
return tmp.groups()[0].strip() |
|
|
|
return tmp.groups()[0].strip() |
|
|
|
|
|
|
|
|
|
|
@ -424,7 +424,7 @@ def getErrorLog(): |
|
|
|
def getShowLogFile(): |
|
|
|
def getShowLogFile(): |
|
|
|
file = getConf() |
|
|
|
file = getConf() |
|
|
|
content = mw.readFile(file) |
|
|
|
content = mw.readFile(file) |
|
|
|
rep = 'slow-query-log-file\s*=\s*(.*)' |
|
|
|
rep = r'slow-query-log-file\s*=\s*(.*)' |
|
|
|
tmp = re.search(rep, content) |
|
|
|
tmp = re.search(rep, content) |
|
|
|
return tmp.groups()[0].strip() |
|
|
|
return tmp.groups()[0].strip() |
|
|
|
|
|
|
|
|
|
|
@ -743,7 +743,7 @@ def initdUinstall(): |
|
|
|
def getMyDbPos(): |
|
|
|
def getMyDbPos(): |
|
|
|
file = getConf() |
|
|
|
file = getConf() |
|
|
|
content = mw.readFile(file) |
|
|
|
content = mw.readFile(file) |
|
|
|
rep = 'datadir\s*=\s*(.*)' |
|
|
|
rep = r'datadir\s*=\s*(.*)' |
|
|
|
tmp = re.search(rep, content) |
|
|
|
tmp = re.search(rep, content) |
|
|
|
return tmp.groups()[0].strip() |
|
|
|
return tmp.groups()[0].strip() |
|
|
|
|
|
|
|
|
|
|
@ -793,7 +793,7 @@ def setMyDbPos(version): |
|
|
|
def getMyPort(): |
|
|
|
def getMyPort(): |
|
|
|
file = getConf() |
|
|
|
file = getConf() |
|
|
|
content = mw.readFile(file) |
|
|
|
content = mw.readFile(file) |
|
|
|
rep = 'port\s*=\s*(.*)' |
|
|
|
rep = r'port\s*=\s*(.*)' |
|
|
|
tmp = re.search(rep, content) |
|
|
|
tmp = re.search(rep, content) |
|
|
|
return tmp.groups()[0].strip() |
|
|
|
return tmp.groups()[0].strip() |
|
|
|
|
|
|
|
|
|
|
@ -807,7 +807,7 @@ def setMyPort(version): |
|
|
|
port = args['port'] |
|
|
|
port = args['port'] |
|
|
|
file = getConf() |
|
|
|
file = getConf() |
|
|
|
content = mw.readFile(file) |
|
|
|
content = mw.readFile(file) |
|
|
|
rep = "port\s*=\s*([0-9]+)\s*\n" |
|
|
|
rep = r"port\s*=\s*([0-9]+)\s*\n" |
|
|
|
content = re.sub(rep, 'port = ' + port + '\n', content) |
|
|
|
content = re.sub(rep, 'port = ' + port + '\n', content) |
|
|
|
mw.writeFile(file, content) |
|
|
|
mw.writeFile(file, content) |
|
|
|
restart(version) |
|
|
|
restart(version) |
|
|
@ -898,7 +898,7 @@ def setDbStatus(version): |
|
|
|
s = 'K' |
|
|
|
s = 'K' |
|
|
|
if g in emptys: |
|
|
|
if g in emptys: |
|
|
|
s = '' |
|
|
|
s = '' |
|
|
|
rep = '\s*' + g + '\s*=\s*\d+(M|K|k|m|G)?\n' |
|
|
|
rep = r'\s*' + g + r'\s*=\s*\d+(M|K|k|m|G)?\n' |
|
|
|
c = g + ' = ' + args[g] + s + '\n' |
|
|
|
c = g + ' = ' + args[g] + s + '\n' |
|
|
|
if content.find(g) != -1: |
|
|
|
if content.find(g) != -1: |
|
|
|
content = re.sub(rep, '\n' + c, content, 1) |
|
|
|
content = re.sub(rep, '\n' + c, content, 1) |
|
|
@ -1571,7 +1571,7 @@ def addDb(): |
|
|
|
dataAccess = args['dataAccess'].strip() |
|
|
|
dataAccess = args['dataAccess'].strip() |
|
|
|
ps = args['ps'].strip() |
|
|
|
ps = args['ps'].strip() |
|
|
|
|
|
|
|
|
|
|
|
reg = "^[\w-]+$" |
|
|
|
reg = r"^[\w-]+$" |
|
|
|
if not re.match(reg, args['name']): |
|
|
|
if not re.match(reg, args['name']): |
|
|
|
return mw.returnJson(False, '数据库名称不能带有特殊符号!') |
|
|
|
return mw.returnJson(False, '数据库名称不能带有特殊符号!') |
|
|
|
checks = ['root', 'mysql', 'test', 'sys', 'performance_schema','information_schema'] |
|
|
|
checks = ['root', 'mysql', 'test', 'sys', 'performance_schema','information_schema'] |
|
|
@ -2163,8 +2163,7 @@ def setDbMaster(version): |
|
|
|
|
|
|
|
|
|
|
|
if not isHas: |
|
|
|
if not isHas: |
|
|
|
prefix = '#binlog-do-db' |
|
|
|
prefix = '#binlog-do-db' |
|
|
|
con = con.replace( |
|
|
|
con = con.replace(prefix, prefix + "\nbinlog-do-db=" + args['name']) |
|
|
|
prefix, prefix + "\nbinlog-do-db=" + args['name']) |
|
|
|
|
|
|
|
mw.writeFile(conf, con) |
|
|
|
mw.writeFile(conf, con) |
|
|
|
|
|
|
|
|
|
|
|
restart(version) |
|
|
|
restart(version) |
|
|
@ -2326,7 +2325,7 @@ def addMasterRepSlaveUser(version=''): |
|
|
|
# address = args['address'].strip() |
|
|
|
# address = args['address'].strip() |
|
|
|
# dataAccess = args['dataAccess'].strip() |
|
|
|
# dataAccess = args['dataAccess'].strip() |
|
|
|
|
|
|
|
|
|
|
|
reg = "^[\w-]+$" |
|
|
|
reg = r"^[\w-]+$" |
|
|
|
if not re.match(reg, username): |
|
|
|
if not re.match(reg, username): |
|
|
|
return mw.returnJson(False, '用户名不能带有特殊符号!') |
|
|
|
return mw.returnJson(False, '用户名不能带有特殊符号!') |
|
|
|
checks = ['root', 'mysql', 'test', 'sys', 'performance_schema','information_schema'] |
|
|
|
checks = ['root', 'mysql', 'test', 'sys', 'performance_schema','information_schema'] |
|
|
@ -3392,7 +3391,7 @@ def doFullSyncUserImportContentForChannel(file, channel_name): |
|
|
|
content = content.replace('STOP SLAVE;', "STOP SLAVE for channel '{}';".format(channel_name)) |
|
|
|
content = content.replace('STOP SLAVE;', "STOP SLAVE for channel '{}';".format(channel_name)) |
|
|
|
content = content.replace('START SLAVE;', "START SLAVE for channel '{}';".format(channel_name)) |
|
|
|
content = content.replace('START SLAVE;', "START SLAVE for channel '{}';".format(channel_name)) |
|
|
|
|
|
|
|
|
|
|
|
find_head = "CHANGE MASTER TO " |
|
|
|
find_head = r"CHANGE MASTER TO " |
|
|
|
find_re = find_head+"(.*?);" |
|
|
|
find_re = find_head+"(.*?);" |
|
|
|
find_r = re.search(find_re, content, re.I|re.M) |
|
|
|
find_r = re.search(find_re, content, re.I|re.M) |
|
|
|
if find_r: |
|
|
|
if find_r: |
|
|
|