|
|
@ -37,7 +37,7 @@ function runInfo(){ |
|
|
|
// console.log(rdata);
|
|
|
|
// console.log(rdata);
|
|
|
|
var cache_size = ((parseInt(rdata.Qcache_hits) / (parseInt(rdata.Qcache_hits) + parseInt(rdata.Qcache_inserts))) * 100).toFixed(2) + '%'; |
|
|
|
var cache_size = ((parseInt(rdata.Qcache_hits) / (parseInt(rdata.Qcache_hits) + parseInt(rdata.Qcache_inserts))) * 100).toFixed(2) + '%'; |
|
|
|
if (cache_size == 'NaN%') cache_size = 'OFF'; |
|
|
|
if (cache_size == 'NaN%') cache_size = 'OFF'; |
|
|
|
var Con = '<div class="divtable"><table class="table table-hover table-bordered" style="width: 490px;margin-bottom:10px;background-color:#fafafa">\ |
|
|
|
var Con = '<div class="divtable"><table class="table table-hover table-bordered" style="margin-bottom:10px;background-color:#fafafa">\ |
|
|
|
<tbody>\ |
|
|
|
<tbody>\ |
|
|
|
<tr><th>启动时间</th><td>' + getLocalTime(rdata.Run) + '</td><th>每秒查询</th><td>' + parseInt(rdata.Questions / rdata.Uptime) + '</td></tr>\ |
|
|
|
<tr><th>启动时间</th><td>' + getLocalTime(rdata.Run) + '</td><th>每秒查询</th><td>' + parseInt(rdata.Questions / rdata.Uptime) + '</td></tr>\ |
|
|
|
<tr><th>总连接次数</th><td>' + rdata.Connections + '</td><th>每秒事务</th><td>' + parseInt((parseInt(rdata.Com_commit) + parseInt(rdata.Com_rollback)) / rdata.Uptime) + '</td></tr>\ |
|
|
|
<tr><th>总连接次数</th><td>' + rdata.Connections + '</td><th>每秒事务</th><td>' + parseInt((parseInt(rdata.Com_commit) + parseInt(rdata.Com_rollback)) / rdata.Uptime) + '</td></tr>\ |
|
|
@ -45,7 +45,7 @@ function runInfo(){ |
|
|
|
<tr><th>接收</th><td>' + toSize(rdata.Bytes_received) + '</td><th>Position</th><td>' + rdata.Position + '</td></tr>\ |
|
|
|
<tr><th>接收</th><td>' + toSize(rdata.Bytes_received) + '</td><th>Position</th><td>' + rdata.Position + '</td></tr>\ |
|
|
|
</tbody>\ |
|
|
|
</tbody>\ |
|
|
|
</table>\ |
|
|
|
</table>\ |
|
|
|
<table class="table table-hover table-bordered" style="width: 490px;">\ |
|
|
|
<table class="table table-hover table-bordered">\ |
|
|
|
<thead style="display:none;"><th></th><th></th><th></th><th></th></thead>\ |
|
|
|
<thead style="display:none;"><th></th><th></th><th></th><th></th></thead>\ |
|
|
|
<tbody>\ |
|
|
|
<tbody>\ |
|
|
|
<tr><th>活动/峰值连接数</th><td>' + rdata.Threads_running + '/' + rdata.Max_used_connections + '</td><td colspan="2">若值过大,增加max_connections</td></tr>\ |
|
|
|
<tr><th>活动/峰值连接数</th><td>' + rdata.Threads_running + '/' + rdata.Max_used_connections + '</td><td colspan="2">若值过大,增加max_connections</td></tr>\ |
|
|
@ -77,7 +77,6 @@ function myPort(){ |
|
|
|
|
|
|
|
|
|
|
|
$('#btn_change_port').click(function(){ |
|
|
|
$('#btn_change_port').click(function(){ |
|
|
|
var port = $("input[name='port']").val(); |
|
|
|
var port = $("input[name='port']").val(); |
|
|
|
// console.log(port);
|
|
|
|
|
|
|
|
myPost('set_my_port','port='+port,function(data){ |
|
|
|
myPost('set_my_port','port='+port,function(data){ |
|
|
|
var rdata = $.parseJSON(data.data); |
|
|
|
var rdata = $.parseJSON(data.data); |
|
|
|
if (rdata.status){ |
|
|
|
if (rdata.status){ |
|
|
@ -90,55 +89,39 @@ function myPort(){ |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function dbList(){ |
|
|
|
function selectChange() { |
|
|
|
var con = '<div class="safe bgw">\ |
|
|
|
$("#SelectVersion,#selectVer").change(function() { |
|
|
|
<button onclick="database.add_database()" title="添加数据库" class="btn btn-success btn-sm" type="button" style="margin-right: 5px;">添加数据库</button>\ |
|
|
|
var info = $(this).val(); |
|
|
|
<button onclick="bt.database.set_root()" title="设置MySQL管理员密码" class="btn btn-default btn-sm" type="button" style="margin-right: 5px;">root密码</button>\ |
|
|
|
var name = info.split(" ")[0]; |
|
|
|
<button onclick="bt.database.open_phpmyadmin(\'\',\'root\',\'bce2de353cba1ce2\')" title="打开phpMyadmin" class="btn btn-default btn-sm" type="button" style="margin-right: 5px;">phpMyAdmin</button>\ |
|
|
|
var version = info.split(" ")[1]; |
|
|
|
<span style="float:right"> \ |
|
|
|
max = 64 |
|
|
|
<button batch="true" style="float: right;display: none;margin-left:10px;" onclick="database.batch_database(\'del\');" title="删除选中项" class="btn btn-default btn-sm">删除选中</button>\ |
|
|
|
msg = "64M" |
|
|
|
<button onclick="bt.recycle_bin.open_recycle_bin(6)" id="dataRecycle" title="删除选中项" class="btn btn-default btn-sm" style="margin-left: 5px;"><span class="glyphicon glyphicon-trash" style="margin-right: 5px;"></span>回收站</button>\ |
|
|
|
if (name == 'mysql') { |
|
|
|
</span>\ |
|
|
|
memSize = getCookie('memSize'); |
|
|
|
<div class="divtable mtb10">\ |
|
|
|
switch (version) { |
|
|
|
<div class="tablescroll">\ |
|
|
|
case '5.1': |
|
|
|
<table id="DataBody" class="table table-hover" width="100%" cellspacing="0" cellpadding="0" border="0" style="border: 0 none;">\ |
|
|
|
max = 256; |
|
|
|
<thead><tr><th width="30"><input class="check" onclick="bt.check_select();" type="checkbox"></th>\ |
|
|
|
msg = '256M'; |
|
|
|
<th>数据库名</th>\ |
|
|
|
break; |
|
|
|
<th>用户名</th>\ |
|
|
|
case '8.0': |
|
|
|
<th>密码</th>\ |
|
|
|
max = 5200; |
|
|
|
<th>备份</th><th>备注</th>\ |
|
|
|
msg = '6GB'; |
|
|
|
<th style="text-align:right;">操作</th></tr></thead>\ |
|
|
|
break; |
|
|
|
<tbody>\ |
|
|
|
case '5.7': |
|
|
|
</tbody></table>\ |
|
|
|
max = 1500; |
|
|
|
</div>\ |
|
|
|
msg = '2GB'; |
|
|
|
<div id="databasePage" class="dataTables_paginate paging_bootstrap page"><div><span class="Pcurrent">1</span><span class="Pcount">共2条数据</span></div></div>\ |
|
|
|
break; |
|
|
|
<div class="table_toolbar">\ |
|
|
|
case '5.6': |
|
|
|
<span class="sync btn btn-default btn-sm" style="margin-right:5px" onclick="database.sync_to_database(1)" title="将选中数据库信息同步到服务器">同步选中</span>\ |
|
|
|
max = 800; |
|
|
|
<span class="sync btn btn-default btn-sm" style="margin-right:5px" onclick="database.sync_to_database(0)" title="将所有数据库信息同步到服务器">同步所有</span>\ |
|
|
|
msg = '1GB'; |
|
|
|
<span class="sync btn btn-default btn-sm" onclick="database.sync_database()" title="从服务器获取数据库列表">从服务器获取</span>\ |
|
|
|
break; |
|
|
|
</div>\ |
|
|
|
case 'AliSQL': |
|
|
|
</div>\ |
|
|
|
max = 800; |
|
|
|
</div>'; |
|
|
|
msg = '1GB'; |
|
|
|
|
|
|
|
break; |
|
|
|
$(".soft-man-con").html(con); |
|
|
|
case 'mariadb_10.0': |
|
|
|
|
|
|
|
max = 800; |
|
|
|
|
|
|
|
msg = '1GB'; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'mariadb_10.1': |
|
|
|
|
|
|
|
max = 1500; |
|
|
|
|
|
|
|
msg = '2GB'; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (memSize < max) { |
|
|
|
|
|
|
|
layer.msg(lan.bt.insatll_mem.replace('{1}', msg).replace('{2}', version), { icon: 5 }); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//设置二进制日志
|
|
|
|
//设置二进制日志
|
|
|
|
function SetBinLog() { |
|
|
|
function SetBinLog() { |
|
|
|
var loadT = layer.msg(lan.public.the, { icon: 16, time: 0, shade: 0.3 }); |
|
|
|
var loadT = layer.msg(lan.public.the, { icon: 16, time: 0, shade: 0.3 }); |
|
|
@ -159,14 +142,18 @@ function closeMySqlLog() { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//数据库端口
|
|
|
|
|
|
|
|
function changeMySQLPort(act) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//数据库存储信置
|
|
|
|
|
|
|
|
function changeMySQLDataPath(act) { |
|
|
|
if (act != undefined) { |
|
|
|
if (act != undefined) { |
|
|
|
layer.confirm(lan.soft.mysql_port_title, { closeBtn: 2, icon: 3 }, function() { |
|
|
|
layer.confirm(lan.soft.mysql_to_msg, { closeBtn: 2, icon: 3 }, function() { |
|
|
|
var port = $("#dataport").val(); |
|
|
|
var datadir = $("#datadir").val(); |
|
|
|
var data = 'port=' + port; |
|
|
|
var data = 'datadir=' + datadir; |
|
|
|
var loadT = layer.msg(lan.public.the, { icon: 16, time: 0, shade: [0.3, '#000'] }); |
|
|
|
var loadT = layer.msg(lan.soft.mysql_to_msg1, { icon: 16, time: 0, shade: [0.3, '#000'] }); |
|
|
|
$.post('/database?action=SetMySQLPort', data, function(rdata) { |
|
|
|
$.post('/database?action=SetDataDir', data, function(rdata) { |
|
|
|
layer.close(loadT) |
|
|
|
layer.close(loadT) |
|
|
|
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 }); |
|
|
|
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 }); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -176,50 +163,130 @@ function changeMySQLPort(act) { |
|
|
|
|
|
|
|
|
|
|
|
$.post('/database?action=GetMySQLInfo', '', function(rdata) { |
|
|
|
$.post('/database?action=GetMySQLInfo', '', function(rdata) { |
|
|
|
var LimitCon = '<p class="conf_p">\ |
|
|
|
var LimitCon = '<p class="conf_p">\ |
|
|
|
<input id="dataport" class="phpUploadLimit bt-input-text mr20" type="number" value="' + rdata.port + '" name="dataport">\ |
|
|
|
<input id="datadir" class="phpUploadLimit bt-input-text mr5" style="width:350px;" type="text" value="' + rdata.datadir + '" name="datadir">\ |
|
|
|
<button style="margin-top: -1px;" class="btn btn-success btn-sm" onclick="changeMySQLPort(1)">' + lan.public.edit + '</button>\ |
|
|
|
<span onclick="ChangePath(\'datadir\')" class="glyphicon glyphicon-folder-open cursor mr20" style="width:auto"></span><button class="btn btn-success btn-sm" onclick="changeMySQLDataPath(1)">' + lan.soft.mysql_to + '</button>\ |
|
|
|
</p>'; |
|
|
|
</p>'; |
|
|
|
|
|
|
|
|
|
|
|
$(".soft-man-con").html(LimitCon); |
|
|
|
$(".soft-man-con").html(LimitCon); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//软件切换版本
|
|
|
|
|
|
|
|
function softChangeVer(name, version) { |
|
|
|
|
|
|
|
if (name == "mysqld") name = "mysql"; |
|
|
|
|
|
|
|
var veropt = version.split("|"); |
|
|
|
|
|
|
|
var SelectVersion = ''; |
|
|
|
|
|
|
|
for (var i = 0; i < veropt.length; i++) { |
|
|
|
|
|
|
|
SelectVersion += '<option>' + name + ' ' + veropt[i] + '</option>'; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var body = "<div class='ver line'><span class='tname'>" + lan.soft.select_version + "</span><select id='selectVer' class='bt-input-text mr20' name='phpVersion' style='width:160px'>"; |
|
|
|
//数据库日志
|
|
|
|
body += SelectVersion + '</select><button class="btn btn-success btn-sm">' + lan.soft.version_to + '</button></div>'; |
|
|
|
function mysqlLog(act) { |
|
|
|
|
|
|
|
//获取二进制日志相关信息
|
|
|
|
|
|
|
|
$.post('/database?action=BinLog', "status=1", function(rdata) { |
|
|
|
|
|
|
|
var limitCon = '<p class="conf_p">\ |
|
|
|
|
|
|
|
<span class="f14 c6 mr20">' + lan.soft.mysql_log_bin + ' </span><span class="f14 c6 mr20">' + ToSize(rdata.msg) + '</span>\ |
|
|
|
|
|
|
|
<button class="btn btn-success btn-xs va0" onclick="SetBinLog();">' + (rdata.status ? lan.soft.off : lan.soft.on) + '</button>\ |
|
|
|
|
|
|
|
<p class="f14 c6 mtb10" style="border-top:#ddd 1px solid; padding:10px 0">' + lan.soft.mysql_log_err + '<button class="btn btn-default btn-xs" style="float:right;" onclick="closeMySqlLog();">' + lan.soft.mysql_log_close + '</button></p>\ |
|
|
|
|
|
|
|
<textarea readonly style="margin: 0px;width: 515px;height: 440px;background-color: #333;color:#fff; padding:0 5px" id="error_log"></textarea>\ |
|
|
|
|
|
|
|
</p>' |
|
|
|
|
|
|
|
|
|
|
|
if (name == 'mysql') { |
|
|
|
$(".soft-man-con").html(limitCon); |
|
|
|
body += "<ul class='help-info-text c7 ptb15'><li style='color:red;'>" + lan.soft.mysql_f + "</li></ul>" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(".soft-man-con").html(body); |
|
|
|
//获取错误日志
|
|
|
|
$(".btn-success").click(function() { |
|
|
|
$.post('/database?action=GetErrorLog', "", function(error_body) { |
|
|
|
var ver = $("#selectVer").val(); |
|
|
|
if (error_body.status === false) { |
|
|
|
oneInstall(name, ver.split(" ")[1]); |
|
|
|
layer.msg(error_body.msg, { icon: 5 }); |
|
|
|
|
|
|
|
error_body = lan.soft.mysql_log_ps1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (error_body == "") error_body = lan.soft.mysql_log_ps1; |
|
|
|
|
|
|
|
$("#error_log").text(error_body); |
|
|
|
|
|
|
|
var ob = document.getElementById('error_log'); |
|
|
|
|
|
|
|
ob.scrollTop = ob.scrollHeight; |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
selectChange(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//数据库配置状态
|
|
|
|
|
|
|
|
function myPerfOpt() { |
|
|
|
|
|
|
|
//获取MySQL配置
|
|
|
|
|
|
|
|
myPost('db_status','',function(data){ |
|
|
|
|
|
|
|
var rdata = $.parseJSON(data.data); |
|
|
|
|
|
|
|
console.log(rdata); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var key_buffer_size = toSizeM(rdata.mem.key_buffer_size); |
|
|
|
|
|
|
|
var query_cache_size = toSizeM(rdata.mem.query_cache_size); |
|
|
|
|
|
|
|
var tmp_table_size = toSizeM(rdata.mem.tmp_table_size); |
|
|
|
|
|
|
|
var innodb_buffer_pool_size = toSizeM(rdata.mem.innodb_buffer_pool_size); |
|
|
|
|
|
|
|
var innodb_additional_mem_pool_size = toSizeM(rdata.mem.innodb_additional_mem_pool_size); |
|
|
|
|
|
|
|
var innodb_log_buffer_size = toSizeM(rdata.mem.innodb_log_buffer_size); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var sort_buffer_size = toSizeM(rdata.mem.sort_buffer_size); |
|
|
|
|
|
|
|
var read_buffer_size = toSizeM(rdata.mem.read_buffer_size); |
|
|
|
|
|
|
|
var read_rnd_buffer_size = toSizeM(rdata.mem.read_rnd_buffer_size); |
|
|
|
|
|
|
|
var join_buffer_size = toSizeM(rdata.mem.join_buffer_size); |
|
|
|
|
|
|
|
var thread_stack = toSizeM(rdata.mem.thread_stack); |
|
|
|
|
|
|
|
var binlog_cache_size = toSizeM(rdata.mem.binlog_cache_size); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var a = key_buffer_size + query_cache_size + tmp_table_size + innodb_buffer_pool_size + innodb_additional_mem_pool_size + innodb_log_buffer_size; |
|
|
|
|
|
|
|
var b = sort_buffer_size + read_buffer_size + read_rnd_buffer_size + join_buffer_size + thread_stack + binlog_cache_size; |
|
|
|
|
|
|
|
var memSize = a + rdata.mem.max_connections * b; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var memCon = '<div class="conf_p" style="margin-bottom:0">\ |
|
|
|
|
|
|
|
<div style="border-bottom:#ccc 1px solid;padding-bottom:10px;margin-bottom:10px"><span><b>最大使用内存: </b></span>\ |
|
|
|
|
|
|
|
<select class="bt-input-text" name="mysql_set" style="margin-left:-4px">\ |
|
|
|
|
|
|
|
<option value="0">请选择</option>\ |
|
|
|
|
|
|
|
<option value="1">1-2GB</option>\ |
|
|
|
|
|
|
|
<option value="2">2-4GB</option>\ |
|
|
|
|
|
|
|
<option value="3">4-8GB</option>\ |
|
|
|
|
|
|
|
<option value="4">8-16GB</option>\ |
|
|
|
|
|
|
|
<option value="5">16-32GB</option>\ |
|
|
|
|
|
|
|
</select>\ |
|
|
|
|
|
|
|
<span>' + lan.soft.mysql_set_maxmem + ': </span><input style="width:70px;background-color:#eee;" class="bt-input-text mr5" name="memSize" type="text" value="' + memSize.toFixed(2) + '" readonly>MB\ |
|
|
|
|
|
|
|
</div>\ |
|
|
|
|
|
|
|
<p><span>key_buffer_size</span><input style="width: 70px;" class="bt-input-text mr5" name="key_buffer_size" value="' + key_buffer_size + '" type="number" >MB, <font>' + lan.soft.mysql_set_key_buffer_size + '</font></p>\ |
|
|
|
|
|
|
|
<p><span>query_cache_size</span><input style="width: 70px;" class="bt-input-text mr5" name="query_cache_size" value="' + query_cache_size + '" type="number" >MB, <font>' + lan.soft.mysql_set_query_cache_size + '</font></p>\ |
|
|
|
|
|
|
|
<p><span>tmp_table_size</span><input style="width: 70px;" class="bt-input-text mr5" name="tmp_table_size" value="' + tmp_table_size + '" type="number" >MB, <font>' + lan.soft.mysql_set_tmp_table_size + '</font></p>\ |
|
|
|
|
|
|
|
<p><span>innodb_buffer_pool_size</span><input style="width: 70px;" class="bt-input-text mr5" name="innodb_buffer_pool_size" value="' + innodb_buffer_pool_size + '" type="number" >MB, <font>' + lan.soft.mysql_set_innodb_buffer_pool_size + '</font></p>\ |
|
|
|
|
|
|
|
<p><span>innodb_log_buffer_size</span><input style="width: 70px;" class="bt-input-text mr5" name="innodb_log_buffer_size" value="' + innodb_log_buffer_size + '" type="number">MB, <font>' + lan.soft.mysql_set_innodb_log_buffer_size + '</font></p>\ |
|
|
|
|
|
|
|
<p style="display:none;"><span>innodb_additional_mem_pool_size</span><input style="width: 70px;" class="bt-input-text mr5" name="innodb_additional_mem_pool_size" value="' + innodb_additional_mem_pool_size + '" type="number" >MB</p>\ |
|
|
|
|
|
|
|
<p><span>sort_buffer_size</span><input style="width: 70px;" class="bt-input-text mr5" name="sort_buffer_size" value="' + (sort_buffer_size * 1024) + '" type="number" >KB * ' + lan.soft.mysql_set_conn + ', <font>' + lan.soft.mysql_set_sort_buffer_size + '</font></p>\ |
|
|
|
|
|
|
|
<p><span>read_buffer_size</span><input style="width: 70px;" class="bt-input-text mr5" name="read_buffer_size" value="' + (read_buffer_size * 1024) + '" type="number" >KB * ' + lan.soft.mysql_set_conn + ', <font>' + lan.soft.mysql_set_read_buffer_size + ' </font></p>\ |
|
|
|
|
|
|
|
<p><span>read_rnd_buffer_size</span><input style="width: 70px;" class="bt-input-text mr5" name="read_rnd_buffer_size" value="' + (read_rnd_buffer_size * 1024) + '" type="number" >KB * ' + lan.soft.mysql_set_conn + ', <font>' + lan.soft.mysql_set_read_rnd_buffer_size + ' </font></p>\ |
|
|
|
|
|
|
|
<p><span>join_buffer_size</span><input style="width: 70px;" class="bt-input-text mr5" name="join_buffer_size" value="' + (join_buffer_size * 1024) + '" type="number" >KB * ' + lan.soft.mysql_set_conn + ', <font>' + lan.soft.mysql_set_join_buffer_size + '</font></p>\ |
|
|
|
|
|
|
|
<p><span>thread_stack</span><input style="width: 70px;" class="bt-input-text mr5" name="thread_stack" value="' + (thread_stack * 1024) + '" type="number" >KB * ' + lan.soft.mysql_set_conn + ', <font>' + lan.soft.mysql_set_thread_stack + '</font></p>\ |
|
|
|
|
|
|
|
<p><span>binlog_cache_size</span><input style="width: 70px;" class="bt-input-text mr5" name="binlog_cache_size" value="' + (binlog_cache_size * 1024) + '" type="number" >KB * ' + lan.soft.mysql_set_conn + ', <font>' + lan.soft.mysql_set_binlog_cache_size + '</font></p>\ |
|
|
|
|
|
|
|
<p><span>thread_cache_size</span><input style="width: 70px;" class="bt-input-text mr5" name="thread_cache_size" value="' + rdata.mem.thread_cache_size + '" type="number" ><font> ' + lan.soft.mysql_set_thread_cache_size + '</font></p>\ |
|
|
|
|
|
|
|
<p><span>table_open_cache</span><input style="width: 70px;" class="bt-input-text mr5" name="table_open_cache" value="' + rdata.mem.table_open_cache + '" type="number" > <font>' + lan.soft.mysql_set_table_open_cache + '</font></p>\ |
|
|
|
|
|
|
|
<p><span>max_connections</span><input style="width: 70px;" class="bt-input-text mr5" name="max_connections" value="' + rdata.mem.max_connections + '" type="number" ><font> ' + lan.soft.mysql_set_max_connections + '</font></p>\ |
|
|
|
|
|
|
|
<div style="margin-top:10px; padding-right:15px" class="text-right"><button class="btn btn-success btn-sm mr5" onclick="reBootMySqld()">重启数据库</button><button class="btn btn-success btn-sm" onclick="setMySQLConf()">保存</button></div>\ |
|
|
|
|
|
|
|
</div>' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(".soft-man-con").html(memCon); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(".conf_p input[name*='size'],.conf_p input[name='max_connections'],.conf_p input[name='thread_stack']").change(function() { |
|
|
|
|
|
|
|
comMySqlMem(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(".conf_p select[name='mysql_set']").change(function() { |
|
|
|
|
|
|
|
mySQLMemOpt($(this).val()); |
|
|
|
|
|
|
|
comMySqlMem(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function reBootMySqld(){ |
|
|
|
|
|
|
|
pluginOpService('mysql','restart',''); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//设置MySQL配置参数
|
|
|
|
//设置MySQL配置参数
|
|
|
|
function SetMySQLConf() { |
|
|
|
function setMySQLConf() { |
|
|
|
$.post('/system?action=GetMemInfo', '', function(memInfo) { |
|
|
|
$.post('/system/system_total', '', function(memInfo) { |
|
|
|
//var memSize = memInfo['memTotal'];
|
|
|
|
var memSize = memInfo['memTotal']; |
|
|
|
//var setSize = parseInt($("input[name='memSize']").val());
|
|
|
|
var setSize = parseInt($("input[name='memSize']").val()); |
|
|
|
//if(memSize < setSize){
|
|
|
|
|
|
|
|
// var msg = lan.soft.mysql_set_err.replace('{1}',memSize).replace('{2}',setSize);
|
|
|
|
if(memSize < setSize){ |
|
|
|
// layer.msg(msg,{icon:2,time:5000});
|
|
|
|
var errMsg = "错误,内存分配过高!<p style='color:red;'>物理内存: {1}MB<br>最大使用内存: {2}MB<br>可能造成的后果: 导致数据库不稳定,甚至无法启动MySQLd服务!"; |
|
|
|
// return;
|
|
|
|
var msg = errMsg.replace('{1}',memSize).replace('{2}',setSize); |
|
|
|
//}
|
|
|
|
layer.msg(msg,{icon:2,time:5000}); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var query_cache_size = parseInt($("input[name='query_cache_size']").val()); |
|
|
|
var query_cache_size = parseInt($("input[name='query_cache_size']").val()); |
|
|
|
var query_cache_type = 0; |
|
|
|
var query_cache_type = 0; |
|
|
|
if (query_cache_size > 0) { |
|
|
|
if (query_cache_size > 0) { |
|
|
@ -244,17 +311,35 @@ function SetMySQLConf() { |
|
|
|
max_connections: parseInt($("input[name='max_connections']").val()) |
|
|
|
max_connections: parseInt($("input[name='max_connections']").val()) |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
$.post('/database?action=SetDbConf', data, function(rdata) { |
|
|
|
myPost('set_db_status', data, function(data){ |
|
|
|
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); |
|
|
|
var rdata = $.parseJSON(data.data); |
|
|
|
|
|
|
|
showMsg(rdata.msg,function(){ |
|
|
|
|
|
|
|
reBootMySqld(); |
|
|
|
|
|
|
|
},{ icon: rdata.status ? 1 : 2 }); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}) |
|
|
|
},'json'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//MySQL内存优化方案
|
|
|
|
//MySQL内存优化方案
|
|
|
|
function MySQLMemOpt(opt) { |
|
|
|
function mySQLMemOpt(opt) { |
|
|
|
var query_size = parseInt($("input[name='query_cache_size']").val()); |
|
|
|
var query_size = parseInt($("input[name='query_cache_size']").val()); |
|
|
|
switch (opt) { |
|
|
|
switch (opt) { |
|
|
|
|
|
|
|
case '0': |
|
|
|
|
|
|
|
$("input[name='key_buffer_size']").val(8); |
|
|
|
|
|
|
|
if (query_size) $("input[name='query_cache_size']").val(4); |
|
|
|
|
|
|
|
$("input[name='tmp_table_size']").val(8); |
|
|
|
|
|
|
|
$("input[name='innodb_buffer_pool_size']").val(16); |
|
|
|
|
|
|
|
$("input[name='sort_buffer_size']").val(256); |
|
|
|
|
|
|
|
$("input[name='read_buffer_size']").val(256); |
|
|
|
|
|
|
|
$("input[name='read_rnd_buffer_size']").val(128); |
|
|
|
|
|
|
|
$("input[name='join_buffer_size']").val(128); |
|
|
|
|
|
|
|
$("input[name='thread_stack']").val(256); |
|
|
|
|
|
|
|
$("input[name='binlog_cache_size']").val(32); |
|
|
|
|
|
|
|
$("input[name='thread_cache_size']").val(4); |
|
|
|
|
|
|
|
$("input[name='table_open_cache']").val(32); |
|
|
|
|
|
|
|
$("input[name='max_connections']").val(500); |
|
|
|
|
|
|
|
break; |
|
|
|
case '1': |
|
|
|
case '1': |
|
|
|
$("input[name='key_buffer_size']").val(128); |
|
|
|
$("input[name='key_buffer_size']").val(128); |
|
|
|
if (query_size) $("input[name='query_cache_size']").val(64); |
|
|
|
if (query_size) $("input[name='query_cache_size']").val(64); |
|
|
@ -333,18 +418,8 @@ function MySQLMemOpt(opt) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//重启MySQL
|
|
|
|
|
|
|
|
function ReBootMySqld() { |
|
|
|
|
|
|
|
var loadT = layer.msg(lan.get('service_the', [lan.bt.restart, 'MySQLd']), { icon: 16, time: 0, shade: 0.3 }); |
|
|
|
|
|
|
|
$.post('/system?action=ServiceAdmin', 'name=mysqld&type=restart', function(rdata) { |
|
|
|
|
|
|
|
layer.close(loadT); |
|
|
|
|
|
|
|
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//计算MySQL内存开销
|
|
|
|
//计算MySQL内存开销
|
|
|
|
function ComMySqlMem() { |
|
|
|
function comMySqlMem() { |
|
|
|
var key_buffer_size = parseInt($("input[name='key_buffer_size']").val()); |
|
|
|
var key_buffer_size = parseInt($("input[name='key_buffer_size']").val()); |
|
|
|
var query_cache_size = parseInt($("input[name='query_cache_size']").val()); |
|
|
|
var query_cache_size = parseInt($("input[name='query_cache_size']").val()); |
|
|
|
var tmp_table_size = parseInt($("input[name='tmp_table_size']").val()); |
|
|
|
var tmp_table_size = parseInt($("input[name='tmp_table_size']").val()); |
|
|
@ -364,125 +439,4 @@ function ComMySqlMem() { |
|
|
|
var b = sort_buffer_size + read_buffer_size + read_rnd_buffer_size + join_buffer_size + thread_stack + binlog_cache_size |
|
|
|
var b = sort_buffer_size + read_buffer_size + read_rnd_buffer_size + join_buffer_size + thread_stack + binlog_cache_size |
|
|
|
var memSize = a + max_connections * b |
|
|
|
var memSize = a + max_connections * b |
|
|
|
$("input[name='memSize']").val(memSize.toFixed(2)); |
|
|
|
$("input[name='memSize']").val(memSize.toFixed(2)); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//数据库存储信置
|
|
|
|
|
|
|
|
function changeMySQLDataPath(act) { |
|
|
|
|
|
|
|
if (act != undefined) { |
|
|
|
|
|
|
|
layer.confirm(lan.soft.mysql_to_msg, { closeBtn: 2, icon: 3 }, function() { |
|
|
|
|
|
|
|
var datadir = $("#datadir").val(); |
|
|
|
|
|
|
|
var data = 'datadir=' + datadir; |
|
|
|
|
|
|
|
var loadT = layer.msg(lan.soft.mysql_to_msg1, { icon: 16, time: 0, shade: [0.3, '#000'] }); |
|
|
|
|
|
|
|
$.post('/database?action=SetDataDir', data, function(rdata) { |
|
|
|
|
|
|
|
layer.close(loadT) |
|
|
|
|
|
|
|
layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 }); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$.post('/database?action=GetMySQLInfo', '', function(rdata) { |
|
|
|
|
|
|
|
var LimitCon = '<p class="conf_p">\ |
|
|
|
|
|
|
|
<input id="datadir" class="phpUploadLimit bt-input-text mr5" style="width:350px;" type="text" value="' + rdata.datadir + '" name="datadir">\ |
|
|
|
|
|
|
|
<span onclick="ChangePath(\'datadir\')" class="glyphicon glyphicon-folder-open cursor mr20" style="width:auto"></span><button class="btn btn-success btn-sm" onclick="changeMySQLDataPath(1)">' + lan.soft.mysql_to + '</button>\ |
|
|
|
|
|
|
|
</p>'; |
|
|
|
|
|
|
|
$(".soft-man-con").html(LimitCon); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//数据库日志
|
|
|
|
|
|
|
|
function mysqlLog(act) { |
|
|
|
|
|
|
|
//获取二进制日志相关信息
|
|
|
|
|
|
|
|
$.post('/database?action=BinLog', "status=1", function(rdata) { |
|
|
|
|
|
|
|
var limitCon = '<p class="conf_p">\ |
|
|
|
|
|
|
|
<span class="f14 c6 mr20">' + lan.soft.mysql_log_bin + ' </span><span class="f14 c6 mr20">' + ToSize(rdata.msg) + '</span>\ |
|
|
|
|
|
|
|
<button class="btn btn-success btn-xs va0" onclick="SetBinLog();">' + (rdata.status ? lan.soft.off : lan.soft.on) + '</button>\ |
|
|
|
|
|
|
|
<p class="f14 c6 mtb10" style="border-top:#ddd 1px solid; padding:10px 0">' + lan.soft.mysql_log_err + '<button class="btn btn-default btn-xs" style="float:right;" onclick="closeMySqlLog();">' + lan.soft.mysql_log_close + '</button></p>\ |
|
|
|
|
|
|
|
<textarea readonly style="margin: 0px;width: 515px;height: 440px;background-color: #333;color:#fff; padding:0 5px" id="error_log"></textarea>\ |
|
|
|
|
|
|
|
</p>' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(".soft-man-con").html(limitCon); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取错误日志
|
|
|
|
|
|
|
|
$.post('/database?action=GetErrorLog', "", function(error_body) { |
|
|
|
|
|
|
|
if (error_body.status === false) { |
|
|
|
|
|
|
|
layer.msg(error_body.msg, { icon: 5 }); |
|
|
|
|
|
|
|
error_body = lan.soft.mysql_log_ps1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (error_body == "") error_body = lan.soft.mysql_log_ps1; |
|
|
|
|
|
|
|
$("#error_log").text(error_body); |
|
|
|
|
|
|
|
var ob = document.getElementById('error_log'); |
|
|
|
|
|
|
|
ob.scrollTop = ob.scrollHeight; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//数据库配置状态
|
|
|
|
|
|
|
|
function mysqlStatus() { |
|
|
|
|
|
|
|
//获取MySQL配置
|
|
|
|
|
|
|
|
$.post('/database?action=GetDbStatus', "", function(rdata) { |
|
|
|
|
|
|
|
var key_buffer_size = ToSizeM(rdata.mem.key_buffer_size) |
|
|
|
|
|
|
|
var query_cache_size = ToSizeM(rdata.mem.query_cache_size) |
|
|
|
|
|
|
|
var tmp_table_size = ToSizeM(rdata.mem.tmp_table_size) |
|
|
|
|
|
|
|
var innodb_buffer_pool_size = ToSizeM(rdata.mem.innodb_buffer_pool_size) |
|
|
|
|
|
|
|
var innodb_additional_mem_pool_size = ToSizeM(rdata.mem.innodb_additional_mem_pool_size) |
|
|
|
|
|
|
|
var innodb_log_buffer_size = ToSizeM(rdata.mem.innodb_log_buffer_size) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var sort_buffer_size = ToSizeM(rdata.mem.sort_buffer_size) |
|
|
|
|
|
|
|
var read_buffer_size = ToSizeM(rdata.mem.read_buffer_size) |
|
|
|
|
|
|
|
var read_rnd_buffer_size = ToSizeM(rdata.mem.read_rnd_buffer_size) |
|
|
|
|
|
|
|
var join_buffer_size = ToSizeM(rdata.mem.join_buffer_size) |
|
|
|
|
|
|
|
var thread_stack = ToSizeM(rdata.mem.thread_stack) |
|
|
|
|
|
|
|
var binlog_cache_size = ToSizeM(rdata.mem.binlog_cache_size) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var a = key_buffer_size + query_cache_size + tmp_table_size + innodb_buffer_pool_size + innodb_additional_mem_pool_size + innodb_log_buffer_size |
|
|
|
|
|
|
|
var b = sort_buffer_size + read_buffer_size + read_rnd_buffer_size + join_buffer_size + thread_stack + binlog_cache_size |
|
|
|
|
|
|
|
var memSize = a + rdata.mem.max_connections * b |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var memCon = '<div class="conf_p" style="margin-bottom:0">\ |
|
|
|
|
|
|
|
<div style="border-bottom:#ccc 1px solid;padding-bottom:10px;margin-bottom:10px"><span><b>' + lan.soft.mysql_set_msg + '</b></span>\ |
|
|
|
|
|
|
|
<select class="bt-input-text" name="mysql_set" style="margin-left:-4px">\ |
|
|
|
|
|
|
|
<option value="0">' + lan.soft.mysql_set_select + '</option>\ |
|
|
|
|
|
|
|
<option value="1">1-2GB</option>\ |
|
|
|
|
|
|
|
<option value="2">2-4GB</option>\ |
|
|
|
|
|
|
|
<option value="3">4-8GB</option>\ |
|
|
|
|
|
|
|
<option value="4">8-16GB</option>\ |
|
|
|
|
|
|
|
<option value="5">16-32GB</option>\ |
|
|
|
|
|
|
|
</select>\ |
|
|
|
|
|
|
|
<span>' + lan.soft.mysql_set_maxmem + ': </span><input style="width:70px;background-color:#eee;" class="bt-input-text mr5" name="memSize" type="text" value="' + memSize.toFixed(2) + '" readonly>MB\ |
|
|
|
|
|
|
|
</div>\ |
|
|
|
|
|
|
|
<p><span>key_buffer_size</span><input style="width: 70px;" class="bt-input-text mr5" name="key_buffer_size" value="' + key_buffer_size + '" type="number" >MB, <font>' + lan.soft.mysql_set_key_buffer_size + '</font></p>\ |
|
|
|
|
|
|
|
<p><span>query_cache_size</span><input style="width: 70px;" class="bt-input-text mr5" name="query_cache_size" value="' + query_cache_size + '" type="number" >MB, <font>' + lan.soft.mysql_set_query_cache_size + '</font></p>\ |
|
|
|
|
|
|
|
<p><span>tmp_table_size</span><input style="width: 70px;" class="bt-input-text mr5" name="tmp_table_size" value="' + tmp_table_size + '" type="number" >MB, <font>' + lan.soft.mysql_set_tmp_table_size + '</font></p>\ |
|
|
|
|
|
|
|
<p><span>innodb_buffer_pool_size</span><input style="width: 70px;" class="bt-input-text mr5" name="innodb_buffer_pool_size" value="' + innodb_buffer_pool_size + '" type="number" >MB, <font>' + lan.soft.mysql_set_innodb_buffer_pool_size + '</font></p>\ |
|
|
|
|
|
|
|
<p><span>innodb_log_buffer_size</span><input style="width: 70px;" class="bt-input-text mr5" name="innodb_log_buffer_size" value="' + innodb_log_buffer_size + '" type="number">MB, <font>' + lan.soft.mysql_set_innodb_log_buffer_size + '</font></p>\ |
|
|
|
|
|
|
|
<p style="display:none;"><span>innodb_additional_mem_pool_size</span><input style="width: 70px;" class="bt-input-text mr5" name="innodb_additional_mem_pool_size" value="' + innodb_additional_mem_pool_size + '" type="number" >MB</p>\ |
|
|
|
|
|
|
|
<p><span>sort_buffer_size</span><input style="width: 70px;" class="bt-input-text mr5" name="sort_buffer_size" value="' + (sort_buffer_size * 1024) + '" type="number" >KB * ' + lan.soft.mysql_set_conn + ', <font>' + lan.soft.mysql_set_sort_buffer_size + '</font></p>\ |
|
|
|
|
|
|
|
<p><span>read_buffer_size</span><input style="width: 70px;" class="bt-input-text mr5" name="read_buffer_size" value="' + (read_buffer_size * 1024) + '" type="number" >KB * ' + lan.soft.mysql_set_conn + ', <font>' + lan.soft.mysql_set_read_buffer_size + ' </font></p>\ |
|
|
|
|
|
|
|
<p><span>read_rnd_buffer_size</span><input style="width: 70px;" class="bt-input-text mr5" name="read_rnd_buffer_size" value="' + (read_rnd_buffer_size * 1024) + '" type="number" >KB * ' + lan.soft.mysql_set_conn + ', <font>' + lan.soft.mysql_set_read_rnd_buffer_size + ' </font></p>\ |
|
|
|
|
|
|
|
<p><span>join_buffer_size</span><input style="width: 70px;" class="bt-input-text mr5" name="join_buffer_size" value="' + (join_buffer_size * 1024) + '" type="number" >KB * ' + lan.soft.mysql_set_conn + ', <font>' + lan.soft.mysql_set_join_buffer_size + '</font></p>\ |
|
|
|
|
|
|
|
<p><span>thread_stack</span><input style="width: 70px;" class="bt-input-text mr5" name="thread_stack" value="' + (thread_stack * 1024) + '" type="number" >KB * ' + lan.soft.mysql_set_conn + ', <font>' + lan.soft.mysql_set_thread_stack + '</font></p>\ |
|
|
|
|
|
|
|
<p><span>binlog_cache_size</span><input style="width: 70px;" class="bt-input-text mr5" name="binlog_cache_size" value="' + (binlog_cache_size * 1024) + '" type="number" >KB * ' + lan.soft.mysql_set_conn + ', <font>' + lan.soft.mysql_set_binlog_cache_size + '</font></p>\ |
|
|
|
|
|
|
|
<p><span>thread_cache_size</span><input style="width: 70px;" class="bt-input-text mr5" name="thread_cache_size" value="' + rdata.mem.thread_cache_size + '" type="number" ><font> ' + lan.soft.mysql_set_thread_cache_size + '</font></p>\ |
|
|
|
|
|
|
|
<p><span>table_open_cache</span><input style="width: 70px;" class="bt-input-text mr5" name="table_open_cache" value="' + rdata.mem.table_open_cache + '" type="number" > <font>' + lan.soft.mysql_set_table_open_cache + '</font></p>\ |
|
|
|
|
|
|
|
<p><span>max_connections</span><input style="width: 70px;" class="bt-input-text mr5" name="max_connections" value="' + rdata.mem.max_connections + '" type="number" ><font> ' + lan.soft.mysql_set_max_connections + '</font></p>\ |
|
|
|
|
|
|
|
<div style="margin-top:10px; padding-right:15px" class="text-right"><button class="btn btn-success btn-sm mr5" onclick="ReBootMySqld()">' + lan.soft.mysql_set_restart + '</button><button class="btn btn-success btn-sm" onclick="SetMySQLConf()">' + lan.public.save + '</button></div>\ |
|
|
|
|
|
|
|
</div>' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(".soft-man-con").html(memCon); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(".conf_p input[name*='size'],.conf_p input[name='max_connections'],.conf_p input[name='thread_stack']").change(function() { |
|
|
|
|
|
|
|
ComMySqlMem(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(".conf_p select[name='mysql_set']").change(function() { |
|
|
|
|
|
|
|
MySQLMemOpt($(this).val()); |
|
|
|
|
|
|
|
ComMySqlMem(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |