Beispiel #1
0
def setOffsetAndIncrement(host, configFile, offset, increment):
    cmd = 'ssh {0} python /tmp/sectionKey.py -c {1} -s mysqld -k auto_increment_offset -v {2}'.format(host, configFile, offset)
    ret = doCommand(cmd)
    if ret != 0:
        return ret

    cmd = 'ssh {0} python /tmp/sectionKey.py -c {1} -s mysqld -k auto_increment_increment -v {2}'.format(host, configFile, increment)
    return doCommand(cmd)
Beispiel #2
0
def allowRemoteLogin(host, userName, password):
    cmd = '\\"update mysql.user set host=\'%\' where user=\'root\' and host=\'localhost\';\\"'
    cmd = 'ssh {0} "mysql -u{1} -p{2} -e {3}"'.format(host, userName, password, cmd)
    ret = doCommand(cmd)
    if ret != 0:
        return ret

    cmd = 'ssh {0} "mysql -u{1} -p{2} -e \\"flush privileges;\\""'.format(host, userName, password)
    ret = doCommand(cmd)
    if ret != 0:
        return ret

    return 0
Beispiel #3
0
def setEncodingWithUtf8(host, configFile):
    cmd = 'ssh {0} python /tmp/sectionKey.py -c {1} -s client -k default-character-set -v utf8'.format(host, configFile)
    ret = doCommand(cmd)
    if ret != 0:
        return ret

    cmd = 'ssh {0} python /tmp/sectionKey.py -c {1} -s mysql -k default-character-set -v utf8'.format(host, configFile)
    ret = doCommand(cmd)
    if ret != 0:
        return ret

    cmd = 'ssh {0} python /tmp/sectionKey.py -c {1} -s mysqld -k character_set_server -v utf8'.format(host, configFile)
    ret = doCommand(cmd)
    if ret != 0:
        return ret

    return 0
Beispiel #4
0
def connectMasterAndSlave(slave, userName, password, master, logFile, logPos):
    cmd = 'ssh {0} "mysql -u{1} -p{2} -e \\"stop slave;\\""'.format(slave, userName, password)
    ret = doCommand(cmd)
    if ret != 0:
        print 'stop slave falied'
        return ret

    cmd = '\\"change master to master_host=\'{0}\', master_user=\'{1}\', master_password=\'{2}\', master_log_file=\'{3}\', master_log_pos={4};\\"'.format(master, repUser, repPassword, logFile, logPos)
    cmd = 'ssh {0} "mysql -u{1} -p{2} -e {3}"'.format(slave, userName, password, cmd)
    ret = doCommand(cmd)
    if ret != 0:
        print 'change master falied'
        return ret

    cmd = 'ssh {0} "mysql -u{1} -p{2} -e \\"start slave;\\""'.format(slave, userName, password)
    ret = doCommand(cmd)
    if ret != 0:
        print 'start slave falied'
        return ret

    return 0
Beispiel #5
0
def teardownRemoteScripts(host):
    cmd = 'ssh ' + host + ' rm -f /tmp/sectionKey.py'
    return doCommand(cmd)
Beispiel #6
0
def setupRemoteScripts(host):
    cmd = 'scp sectionKey.py ' + host + ':/tmp/'
    return doCommand(cmd)
Beispiel #7
0
def restartMySQL(host):
    cmd = 'ssh ' + host + ' service mysql restart'
    return doCommand(cmd)
Beispiel #8
0
def setServerId(host, configFile, ID):
    cmd = 'ssh {0} python /tmp/sectionKey.py -c {1} -s mysqld -k server-id -v {2}'.format(host, configFile, ID)
    return doCommand(cmd)
Beispiel #9
0
def enableBinlog(host, configFile):
    cmd = 'ssh {0} python /tmp/sectionKey.py -c {1} -s mysqld -k log_bin -v MySQL-bin'.format(host, configFile)
    return doCommand(cmd)
Beispiel #10
0
def setBindAddress(host, configFile):
    cmd = 'ssh {0} python /tmp/sectionKey.py -c {1} -s mysqld -k bind-address -v 0.0.0.0'.format(host, configFile)
    return doCommand(cmd)
Beispiel #11
0
def disableDNS(host, configFile):
    cmd = 'ssh {0} python /tmp/sectionKey.py -c {1} -s mysqld -k skip-name-resolve'.format(host, configFile)
    return doCommand(cmd)
Beispiel #12
0
def checkReplicateUser(slave, master):
    cmd = 'ssh {0} "mysql -u{1} -p{2} -h{3} -e \\"\\""'.format(slave, repUser, repPassword, master)
    return doCommand(cmd)
Beispiel #13
0
def createReplicateUser(master, userName, password, slave):
    cmd = '\\"Grant replication slave on *.* to {1}@{0} identified by \'{2}\';\\"'.format(slave, repUser, repPassword)
    cmd = 'ssh {0} "mysql -u{1} -p{2} -e {3}"'.format(master, userName, password, cmd)
    return doCommand(cmd)
Beispiel #14
0
import command
import guide
from log import Logger
from error import ErrorList
from os import system

print("欢迎使用6.0版本的本系统了(连名字都没有,哎呀我去")
print("有不懂不要问,去命令行模式输入 do -help ")
print("汇总文件仅支持“.xlsx“格式, 退款文件仅支持”.xls“格式,出错了检查一下是不是这个问题\n")

mode = input("输入点东西就进入命令行模式,啥也不输就进入引导模式:")

if mode == "":
    Logger.addLog("输入:{},进入引导模式。".format(mode))
    guide.doGuide("../data")
else:
    Logger.addLog("输入:{},进入命令模式。".format(mode))
    command.doCommand()

ErrorList.printErrorList()
Logger.writeLog()
system("pause")