mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-18 23:45:52 +08:00
up
This commit is contained in:
+68
-36
@@ -1126,78 +1126,110 @@ def getTotalStatistics():
|
|||||||
return mw.returnJson(False, 'fail', data)
|
return mw.returnJson(False, 'fail', data)
|
||||||
|
|
||||||
|
|
||||||
|
def getMasterStatus(version=''):
|
||||||
|
conf = getConf()
|
||||||
|
con = mw.readFile(conf)
|
||||||
|
master_status = False
|
||||||
|
if con.find('#log-bin') == -1 and con.find('log-bin') > 1:
|
||||||
|
if con.find('#binlog-do-db') == -1 and con.find('binlog-do-db') > 1:
|
||||||
|
master_status = True
|
||||||
|
data = {}
|
||||||
|
data['status'] = master_status
|
||||||
|
return mw.returnJson(master_status, '设置成功')
|
||||||
|
|
||||||
|
|
||||||
|
def setMasterStatus(version=''):
|
||||||
|
|
||||||
|
conf = getConf()
|
||||||
|
con = mw.readFile(conf)
|
||||||
|
|
||||||
|
if con.find('#binlog-do-db') != -1:
|
||||||
|
con = con.replace('#binlog-do-db', 'binlog-do-db')
|
||||||
|
con = con.replace('#binlog-ignore-db', 'binlog-ignore-db')
|
||||||
|
restart()
|
||||||
|
else:
|
||||||
|
con = con.replace('binlog-do-db', '#binlog-do-db')
|
||||||
|
con = con.replace('binlog-ignore-db', '#binlog-ignore-db')
|
||||||
|
restart()
|
||||||
|
mw.writeFile(conf, con)
|
||||||
|
return mw.returnJson(True, '设置成功')
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
func = sys.argv[1]
|
func = sys.argv[1]
|
||||||
version = sys.argv[2]
|
version = sys.argv[2]
|
||||||
if func == 'status':
|
if func == 'status':
|
||||||
print status(version)
|
print(status(version))
|
||||||
elif func == 'start':
|
elif func == 'start':
|
||||||
print start(version)
|
print(start(version))
|
||||||
elif func == 'stop':
|
elif func == 'stop':
|
||||||
print stop(version)
|
print(top(version))
|
||||||
elif func == 'restart':
|
elif func == 'restart':
|
||||||
print restart(version)
|
print(restart(version))
|
||||||
elif func == 'reload':
|
elif func == 'reload':
|
||||||
print reload(version)
|
print(reload(version))
|
||||||
elif func == 'initd_status':
|
elif func == 'initd_status':
|
||||||
print initdStatus()
|
print(initdStatus())
|
||||||
elif func == 'initd_install':
|
elif func == 'initd_install':
|
||||||
print initdInstall()
|
print(initdInstall())
|
||||||
elif func == 'initd_uninstall':
|
elif func == 'initd_uninstall':
|
||||||
print initdUinstall()
|
print(initdUinstall())
|
||||||
elif func == 'run_info':
|
elif func == 'run_info':
|
||||||
print runInfo()
|
print(runInfo())
|
||||||
elif func == 'db_status':
|
elif func == 'db_status':
|
||||||
print myDbStatus()
|
print(myDbStatus())
|
||||||
elif func == 'set_db_status':
|
elif func == 'set_db_status':
|
||||||
print setDbStatus()
|
print(setDbStatus())
|
||||||
elif func == 'conf':
|
elif func == 'conf':
|
||||||
print getConf()
|
print(getConf())
|
||||||
elif func == 'bin_log':
|
elif func == 'bin_log':
|
||||||
print binLog()
|
print(binLog())
|
||||||
elif func == 'error_log':
|
elif func == 'error_log':
|
||||||
print getErrorLog()
|
print(getErrorLog())
|
||||||
elif func == 'show_log':
|
elif func == 'show_log':
|
||||||
print getShowLogFile()
|
print(getShowLogFile())
|
||||||
elif func == 'my_db_pos':
|
elif func == 'my_db_pos':
|
||||||
print getMyDbPos()
|
print(getMyDbPos())
|
||||||
elif func == 'set_db_pos':
|
elif func == 'set_db_pos':
|
||||||
print setMyDbPos()
|
print(setMyDbPos())
|
||||||
elif func == 'my_port':
|
elif func == 'my_port':
|
||||||
print getMyPort()
|
print(getMyPort())
|
||||||
elif func == 'set_my_port':
|
elif func == 'set_my_port':
|
||||||
print setMyPort()
|
print(setMyPort())
|
||||||
elif func == 'init_pwd':
|
elif func == 'init_pwd':
|
||||||
print initMysqlPwd()
|
print(initMysqlPwd())
|
||||||
elif func == 'get_db_list':
|
elif func == 'get_db_list':
|
||||||
print getDbList()
|
print(getDbList())
|
||||||
elif func == 'add_db':
|
elif func == 'add_db':
|
||||||
print addDb()
|
print(addDb())
|
||||||
elif func == 'del_db':
|
elif func == 'del_db':
|
||||||
print delDb()
|
print(delDb())
|
||||||
elif func == 'sync_get_databases':
|
elif func == 'sync_get_databases':
|
||||||
print syncGetDatabases()
|
print(syncGetDatabases())
|
||||||
elif func == 'sync_to_databases':
|
elif func == 'sync_to_databases':
|
||||||
print syncToDatabases()
|
print(syncToDatabases())
|
||||||
elif func == 'set_root_pwd':
|
elif func == 'set_root_pwd':
|
||||||
print setRootPwd()
|
print(setRootPwd())
|
||||||
elif func == 'set_user_pwd':
|
elif func == 'set_user_pwd':
|
||||||
print setUserPwd()
|
print(setUserPwd())
|
||||||
elif func == 'get_db_access':
|
elif func == 'get_db_access':
|
||||||
print getDbAccess()
|
print(getDbAccess())
|
||||||
elif func == 'set_db_access':
|
elif func == 'set_db_access':
|
||||||
print setDbAccess()
|
print(setDbAccess())
|
||||||
elif func == 'set_db_ps':
|
elif func == 'set_db_ps':
|
||||||
print setDbPs()
|
print(setDbPs())
|
||||||
elif func == 'get_db_info':
|
elif func == 'get_db_info':
|
||||||
print getDbInfo()
|
print(getDbInfo())
|
||||||
elif func == 'repair_table':
|
elif func == 'repair_table':
|
||||||
print repairTable()
|
print(repairTable())
|
||||||
elif func == 'opt_table':
|
elif func == 'opt_table':
|
||||||
print optTable()
|
print(optTable())
|
||||||
elif func == 'alter_table':
|
elif func == 'alter_table':
|
||||||
print alterTable()
|
print(alterTable())
|
||||||
elif func == 'get_total_statistics':
|
elif func == 'get_total_statistics':
|
||||||
print getTotalStatistics()
|
print(getTotalStatistics())
|
||||||
|
elif func == 'get_master_status':
|
||||||
|
print(getMasterStatus(version))
|
||||||
|
elif func == 'set_master_status':
|
||||||
|
print(setMasterStatus(version))
|
||||||
else:
|
else:
|
||||||
print 'error'
|
print('error')
|
||||||
|
|||||||
+73
-52
@@ -1104,62 +1104,83 @@ function repTools(db_name, res){
|
|||||||
|
|
||||||
function masterOrSlaveConf(version){
|
function masterOrSlaveConf(version){
|
||||||
|
|
||||||
var _data = {};
|
function getDbList(){
|
||||||
if (typeof(page) =='undefined'){
|
var _data = {};
|
||||||
var page = 1;
|
if (typeof(page) =='undefined'){
|
||||||
}
|
var page = 1;
|
||||||
|
}
|
||||||
_data['page'] = page;
|
|
||||||
_data['page_size'] = 10;
|
_data['page'] = page;
|
||||||
if(typeof(search) != 'undefined'){
|
_data['page_size'] = 10;
|
||||||
_data['search'] = search;
|
if(typeof(search) != 'undefined'){
|
||||||
}
|
_data['search'] = search;
|
||||||
myPost('get_db_list', _data, function(data){
|
|
||||||
var rdata = $.parseJSON(data.data);
|
|
||||||
var list = '';
|
|
||||||
for(i in rdata.data){
|
|
||||||
list += '<tr>';
|
|
||||||
list += '<td>' + rdata.data[i]['name'] +'</td>';
|
|
||||||
list += '<td>' + rdata.data[i]['username'] +'</td>';
|
|
||||||
list += '<td>' +
|
|
||||||
'<span class="password" data-pw="'+rdata.data[i]['password']+'">***</span>' +
|
|
||||||
'<span onclick="showHidePass(this)" class="glyphicon glyphicon-eye-open cursor pw-ico" style="margin-left:10px"></span>'+
|
|
||||||
'<span class="ico-copy cursor btcopy" style="margin-left:10px" title="复制密码" onclick="copyPass(\''+rdata.data[i]['password']+'\')"></span>'+
|
|
||||||
'</td>';
|
|
||||||
list += '<td style="text-align:right">' +
|
|
||||||
'<a href="javascript:;" class="btlink" onclick="setDbAccess(\''+rdata.data[i]['username']+'\')" title="设置数据库权限">权限</a> | ' +
|
|
||||||
'<a href="javascript:;" class="btlink" onclick="setDbPass('+rdata.data[i]['id']+',\''+ rdata.data[i]['username'] +'\',\'' + rdata.data[i]['password'] + '\')">改密</a> | ' +
|
|
||||||
'<a href="javascript:;" class="btlink" onclick="delDb(\''+rdata.data[i]['id']+'\',\''+rdata.data[i]['name']+'\')" title="删除数据库">删除</a>' +
|
|
||||||
'</td>';
|
|
||||||
list += '</tr>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//<button onclick="" id="dataRecycle" title="删除选中项" class="btn btn-default btn-sm" style="margin-left: 5px;"><span class="glyphicon glyphicon-trash" style="margin-right: 5px;"></span>回收站</button>
|
myPost('get_db_list', _data, function(data){
|
||||||
var con = '<div class="safe bgw">\
|
var rdata = $.parseJSON(data.data);
|
||||||
<div class="divtable mtb10">\
|
var list = '';
|
||||||
<div class="tablescroll">\
|
for(i in rdata.data){
|
||||||
<table id="DataBody" class="table table-hover" width="100%" cellspacing="0" cellpadding="0" border="0" style="border: 0 none;">\
|
list += '<tr>';
|
||||||
<thead><tr>\
|
list += '<td>' + rdata.data[i]['name'] +'</td>';
|
||||||
<th>数据库名</th>\
|
list += '<td>' + rdata.data[i]['username'] +'</td>';
|
||||||
<th>用户名</th>\
|
list += '<td>' +
|
||||||
<th>密码</th>\
|
'<span class="password" data-pw="'+rdata.data[i]['password']+'">***</span>' +
|
||||||
<th style="text-align:right;">操作</th></tr></thead>\
|
'<span onclick="showHidePass(this)" class="glyphicon glyphicon-eye-open cursor pw-ico" style="margin-left:10px"></span>'+
|
||||||
<tbody>\
|
'<span class="ico-copy cursor btcopy" style="margin-left:10px" title="复制密码" onclick="copyPass(\''+rdata.data[i]['password']+'\')"></span>'+
|
||||||
'+ list +'\
|
'</td>';
|
||||||
</tbody></table>\
|
list += '<td style="text-align:right">' +
|
||||||
</div>\
|
'<a href="javascript:;" class="btlink" onclick="setDbAccess(\''+rdata.data[i]['username']+'\')" title="设置数据库权限">权限</a> | ' +
|
||||||
<div id="databasePage" class="dataTables_paginate paging_bootstrap page"></div>\
|
'<a href="javascript:;" class="btlink" onclick="setDbPass('+rdata.data[i]['id']+',\''+ rdata.data[i]['username'] +'\',\'' + rdata.data[i]['password'] + '\')">改密</a> | ' +
|
||||||
</div>\
|
'<a href="javascript:;" class="btlink" onclick="delDb(\''+rdata.data[i]['id']+'\',\''+rdata.data[i]['name']+'\')" title="删除数据库">删除</a>' +
|
||||||
</div>';
|
'</td>';
|
||||||
|
list += '</tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
var con = '<div class="divtable mtb10">\
|
||||||
|
<div class="tablescroll">\
|
||||||
|
<table id="DataBody" class="table table-hover" width="100%" cellspacing="0" cellpadding="0" border="0" style="border: 0 none;">\
|
||||||
|
<thead><tr>\
|
||||||
|
<th>数据库名</th>\
|
||||||
|
<th>用户名</th>\
|
||||||
|
<th>密码</th>\
|
||||||
|
<th style="text-align:right;">操作</th></tr></thead>\
|
||||||
|
<tbody>\
|
||||||
|
'+ list +'\
|
||||||
|
</tbody></table>\
|
||||||
|
</div>\
|
||||||
|
<div id="databasePage" class="dataTables_paginate paging_bootstrap page"></div>\
|
||||||
|
</div>';
|
||||||
|
|
||||||
var limitCon = '<p class="conf_p">\
|
$(".table_master_list").html(con);
|
||||||
<span class="f14 c6 mr20">Master[主]配置</span><span class="f14 c6 mr20"></span>\
|
$('#databasePage').html(rdata.page);
|
||||||
<button class="btn btn-success btn-xs btn-bin va0">开启</button><hr/>\
|
});
|
||||||
</p>';
|
}
|
||||||
|
function getMasterStatus(){
|
||||||
|
myPost('get_master_status', '', function(data){
|
||||||
|
var rdata = $.parseJSON(data.data);
|
||||||
|
var limitCon = '<p class="conf_p">\
|
||||||
|
<span class="f14 c6 mr20">Master[主]配置</span><span class="f14 c6 mr20"></span>\
|
||||||
|
<button class="btn btn-success btn-xs btn-master va0">'+(!rdata.status ? '未开启' : '已开启') +'</button><hr/>\
|
||||||
|
</p>\
|
||||||
|
<!-- master list -->\
|
||||||
|
<div class="safe bgw table_master_list"></div>\
|
||||||
|
';
|
||||||
|
|
||||||
$(".soft-man-con").html(limitCon+con);
|
$(".soft-man-con").html(limitCon);
|
||||||
$('#databasePage').html(rdata.page);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
//设置主服务器配置
|
||||||
|
$(".btn-master").click(function () {
|
||||||
|
// console.log('.....');
|
||||||
|
myPost('set_master_status', 'close=change', function(data){
|
||||||
|
var rdata = $.parseJSON(data.data);
|
||||||
|
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 });
|
||||||
|
setTimeout(function(){
|
||||||
|
getMasterStatus();
|
||||||
|
}, 2000);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
getDbList();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
getMasterStatus();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user