diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index accc94a14..fa49fd719 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -1544,10 +1544,30 @@ def doFullSync(): paramiko.util.log_to_file('paramiko.log') ssh = paramiko.SSHClient() - SSH_PRIVATE_KEY = '/Users/midoks/.ssh/id_rsa' - key = paramiko.RSAKey.from_private_key_file(SSH_PRIVATE_KEY) - ssh.load_system_host_keys() - ssh.connect(hostname=ip, port=22, username='root', pkey=key) + SSH_PRIVATE_KEY = '/root/.ssh/id_rsa' + + if mw.getOs() == 'darwin': + user = mw.execShell( + "who | sed -n '2, 1p' |awk '{print $1}'")[0].strip() + SSH_PRIVATE_KEY = '/User/' + user + '/.ssh/id_rsa' + + if not os.path.exists(SSH_PRIVATE_KEY): + status_data['code'] = 0 + status_data['msg'] = '需要配置免登录...' + mw.writeFile(status_file, json.dumps(status_data)) + return + + try: + key = paramiko.RSAKey.from_private_key_file(SSH_PRIVATE_KEY) + # ssh.load_system_host_keys() + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + ssh.connect(hostname=ip, port=22, username='root', pkey=key) + except Exception as e: + status_data['code'] = 0 + status_data['msg'] = '需要配置免登录....' + mw.writeFile(status_file, json.dumps(status_data)) + return + cmd = "cd /www/server/mdserver-web && python /www/server/mdserver-web/plugins/mysql/index.py dump_mysql_data {\"db\":'" + args[ 'db'] + "'}" stdin, stdout, stderr = ssh.exec_command(cmd) diff --git a/plugins/mysql/js/mysql.js b/plugins/mysql/js/mysql.js index 15ae6e42f..7be89beca 100755 --- a/plugins/mysql/js/mysql.js +++ b/plugins/mysql/js/mysql.js @@ -1411,6 +1411,25 @@ function getFullSyncStatus(db){ }); } +function handlerRun(){ + cmd = 'cd /www/server/mdserver-web && python /www/server/mdserver-web/plugins/mysql/index.py do_full_sync {"db":"all"}'; + var loadOpen = layer.open({ + type: 1, + title: '手动执行', + area: '500px', + content:"
", + }); + copyPass(cmd); + $('.class-copy-cmd').click(function(){ + copyPass(cmd); + }); +} + function masterOrSlaveConf(version=''){ function getMasterDbList(){ @@ -1541,7 +1560,7 @@ function masterOrSlaveConf(version=''){ \ \ \ ';