update
This commit is contained in:
parent
8fb3410366
commit
cb9857edf2
|
|
@ -12,4 +12,16 @@ show global variables like 'server_uuid';
|
|||
# drop_db_cmd = 'drop table if exists '+sync_db_import+'.'+tname[table_key]
|
||||
# # print(drop_db_cmd)
|
||||
# db.query(drop_db_cmd)
|
||||
```
|
||||
|
||||
```
|
||||
# 修改同步位置
|
||||
# master_info = sync_mdb.query('show master status')
|
||||
# slave_info = db.query('show slave status')
|
||||
# if len(master_info)>0:
|
||||
# channel_name = slave_info[0]['Channel_Name']
|
||||
# change_cmd = "CHANGE MASTER TO MASTER_LOG_FILE='"+master_info[0]['File']+"', MASTER_LOG_POS="+str(master_info[0]['Position'])+" for channel '"+channel_name+"';"
|
||||
# print(change_cmd)
|
||||
# r = db.execute(change_cmd)
|
||||
# print(r)
|
||||
```
|
||||
|
|
@ -3293,6 +3293,18 @@ def writeDbSyncStatus(data):
|
|||
mw.writeFile(path, json.dumps(data))
|
||||
return True
|
||||
|
||||
def fullSyncCmd():
|
||||
time_all_s = time.time()
|
||||
args = getArgs()
|
||||
data = checkArgs(args, ['db', 'sign'])
|
||||
if not data[0]:
|
||||
return data[1]
|
||||
|
||||
db = args['db']
|
||||
sign = args['sign']
|
||||
|
||||
cmd = 'cd '+mw.getServerDir()+'/mdserver-web && source bin/activate && python3 plugins/mysql/index.py do_full_sync {"db":"'+db+'","sign":"'+sign+'"}'
|
||||
return mw.returnJson(True,'ok',cmd)
|
||||
|
||||
def doFullSync(version=''):
|
||||
mode_file = getSyncModeFile()
|
||||
|
|
@ -3324,6 +3336,7 @@ def getChannelNameForCmd(cmd):
|
|||
return ''
|
||||
|
||||
|
||||
|
||||
def doFullSyncUserImportContentForChannel(file, channel_name):
|
||||
# print(file, channel_name)
|
||||
content = mw.readFile(file)
|
||||
|
|
@ -3443,33 +3456,28 @@ def doFullSyncUser(version=''):
|
|||
db.execute('reset master')
|
||||
|
||||
# 加快导入 - 开始
|
||||
db.execute('set global innodb_flush_log_at_trx_commit = 2')
|
||||
db.execute('set global sync_binlog = 2000')
|
||||
# db.execute('set global innodb_flush_log_at_trx_commit = 2')
|
||||
# db.execute('set global sync_binlog = 2000')
|
||||
|
||||
doFullSyncUserImportContentForChannel(bak_file, channel_name)
|
||||
|
||||
|
||||
pwd = pSqliteDb('config').where('id=?', (1,)).getField('mysql_root')
|
||||
sock = getSocketFile()
|
||||
# my_import_cmd = getServerDir() + '/bin/mysql -S ' + sock + " -uroot -p'" + pwd + \
|
||||
# "' " + sync_db_import + ' < ' + bak_file
|
||||
# print(my_import_cmd)
|
||||
|
||||
my_import_cmd = getServerDir() + '/bin/mysql -S ' + sock + " -uroot -p'" + pwd + \
|
||||
"' " + sync_db_import + ' < ' + bak_file
|
||||
"' " + sync_db_import
|
||||
my_import_cmd = "pv -t -p " + bak_file + '|' + my_import_cmd
|
||||
print(my_import_cmd)
|
||||
r = mw.execShell(my_import_cmd)
|
||||
print(r)
|
||||
os.system(my_import_cmd)
|
||||
|
||||
# 加快导入 - 结束
|
||||
db.execute('set global innodb_flush_log_at_trx_commit = 1')
|
||||
db.execute('set global sync_binlog = 1')
|
||||
# db.execute('set global innodb_flush_log_at_trx_commit = 1')
|
||||
# db.execute('set global sync_binlog = 1')
|
||||
|
||||
# 修改同步位置
|
||||
# master_info = sync_mdb.query('show master status')
|
||||
# slave_info = db.query('show slave status')
|
||||
# if len(master_info)>0:
|
||||
# channel_name = slave_info[0]['Channel_Name']
|
||||
# change_cmd = "CHANGE MASTER TO MASTER_LOG_FILE='"+master_info[0]['File']+"', MASTER_LOG_POS="+str(master_info[0]['Position'])+" for channel '"+channel_name+"';"
|
||||
# print(change_cmd)
|
||||
# r = db.execute(change_cmd)
|
||||
# print(r)
|
||||
time_e = time.time()
|
||||
import_cos = time_e - time_s
|
||||
print("import cos:", import_cos)
|
||||
|
|
@ -3866,6 +3874,8 @@ if __name__ == "__main__":
|
|||
print(fullSync(version))
|
||||
elif func == 'do_full_sync':
|
||||
print(doFullSync(version))
|
||||
elif func == 'full_sync_cmd':
|
||||
print(fullSyncCmd())
|
||||
elif func == 'dump_mysql_data':
|
||||
print(dumpMysqlData(version))
|
||||
elif func == 'sync_database_repair':
|
||||
|
|
|
|||
|
|
@ -1985,6 +1985,7 @@ function getFullSyncStatus(db){
|
|||
</div>\
|
||||
<div class='table_toolbar' style='left:0px;'>\
|
||||
<span data-status='init' class='sync btn btn-default btn-sm' id='begin_full_sync'>开始</span>\
|
||||
<span data-status='init' class='btn btn-default btn-sm' id='full_sync_cmd'>手动命令</span>\
|
||||
</div>\
|
||||
</div>",
|
||||
cancel: function(){
|
||||
|
|
@ -2007,6 +2008,31 @@ function getFullSyncStatus(db){
|
|||
layer.msg("正在同步中..",{icon:0});
|
||||
}
|
||||
});
|
||||
|
||||
$('#full_sync_cmd').click(function(){
|
||||
myPostN('full_sync_cmd', {'db':db,'sign':''}, function(rdata){
|
||||
var rdata = $.parseJSON(rdata.data);
|
||||
layer.open({
|
||||
title: "手动执行命令CMD",
|
||||
area: ['600px', '180px'],
|
||||
type:1,
|
||||
closeBtn: 1,
|
||||
shadeClose: false,
|
||||
btn:["复制","取消"],
|
||||
content: '<div class="pd15">\
|
||||
<div class="divtable">\
|
||||
<pre class="layui-code">'+rdata.data+'</pre>\
|
||||
</div>\
|
||||
</div>',
|
||||
success:function(){
|
||||
copyText(rdata.data);
|
||||
},
|
||||
yes:function(){
|
||||
copyText(rdata.data);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue