diff --git a/plugins/mysql/index.html b/plugins/mysql/index.html index 861b3d959..381ae98cf 100755 --- a/plugins/mysql/index.html +++ b/plugins/mysql/index.html @@ -6,16 +6,18 @@
配置文件
端口
当前状态
+性能优化
慢日志
+管理列表
启动时间 | ' + getLocalTime(rdata.Run) + ' | 每秒查询 | ' + parseInt(rdata.Questions / rdata.Uptime) + ' |
---|---|---|---|
总连接次数 | ' + rdata.Connections + ' | 每秒事务 | ' + parseInt((parseInt(rdata.Com_commit) + parseInt(rdata.Com_rollback)) / rdata.Uptime) + ' |
接收 | ' + toSize(rdata.Bytes_received) + ' | Position | ' + rdata.Position + ' |
\ \ | ||||||
---|---|---|---|---|---|---|
活动/峰值连接数 | ' + rdata.Threads_running + '/' + rdata.Max_used_connections + ' | 若值过大,增加max_connections |
\ + | 数据库名 | \ +用户名 | \ +密码 | \ +备份 | 备注 | \ +操作 |
---|
\ - \ - \ + \ + \
'; - $(".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 += ''; - } - var body = "\ + ' + lan.soft.mysql_log_bin + ' ' + ToSize(rdata.msg) + '\ + \ +
' + lan.soft.mysql_log_err + '
\ + \ + ' - if (name == 'mysql') { - body += "key_buffer_sizeMB, ' + lan.soft.mysql_set_key_buffer_size + '
\ +query_cache_sizeMB, ' + lan.soft.mysql_set_query_cache_size + '
\ +tmp_table_sizeMB, ' + lan.soft.mysql_set_tmp_table_size + '
\ +innodb_buffer_pool_sizeMB, ' + lan.soft.mysql_set_innodb_buffer_pool_size + '
\ +innodb_log_buffer_sizeMB, ' + lan.soft.mysql_set_innodb_log_buffer_size + '
\ + \ +sort_buffer_sizeKB * ' + lan.soft.mysql_set_conn + ', ' + lan.soft.mysql_set_sort_buffer_size + '
\ +read_buffer_sizeKB * ' + lan.soft.mysql_set_conn + ', ' + lan.soft.mysql_set_read_buffer_size + '
\ +read_rnd_buffer_sizeKB * ' + lan.soft.mysql_set_conn + ', ' + lan.soft.mysql_set_read_rnd_buffer_size + '
\ +join_buffer_sizeKB * ' + lan.soft.mysql_set_conn + ', ' + lan.soft.mysql_set_join_buffer_size + '
\ +thread_stackKB * ' + lan.soft.mysql_set_conn + ', ' + lan.soft.mysql_set_thread_stack + '
\ +binlog_cache_sizeKB * ' + lan.soft.mysql_set_conn + ', ' + lan.soft.mysql_set_binlog_cache_size + '
\ +thread_cache_size ' + lan.soft.mysql_set_thread_cache_size + '
\ +table_open_cache ' + lan.soft.mysql_set_table_open_cache + '
\ +max_connections ' + lan.soft.mysql_set_max_connections + '
\ + \ +物理内存: {1}MB
最大使用内存: {2}MB
可能造成的后果: 导致数据库不稳定,甚至无法启动MySQLd服务!";
+ 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_type = 0;
if (query_cache_size > 0) {
@@ -244,17 +311,35 @@ function SetMySQLConf() {
max_connections: parseInt($("input[name='max_connections']").val())
};
- $.post('/database?action=SetDbConf', data, function(rdata) {
- layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 });
+ myPost('set_db_status', data, function(data){
+ var rdata = $.parseJSON(data.data);
+ showMsg(rdata.msg,function(){
+ reBootMySqld();
+ },{ icon: rdata.status ? 1 : 2 });
});
- })
+ },'json');
}
//MySQL内存优化方案
-function MySQLMemOpt(opt) {
+function mySQLMemOpt(opt) {
var query_size = parseInt($("input[name='query_cache_size']").val());
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':
$("input[name='key_buffer_size']").val(128);
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内存开销
-function ComMySqlMem() {
+function comMySqlMem() {
var key_buffer_size = parseInt($("input[name='key_buffer_size']").val());
var query_cache_size = parseInt($("input[name='query_cache_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 memSize = a + max_connections * b
$("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 = '
\ - \ - \ -
'; - $(".soft-man-con").html(LimitCon); - }); -} - - - -//数据库日志 -function mysqlLog(act) { - //获取二进制日志相关信息 - $.post('/database?action=BinLog', "status=1", function(rdata) { - var limitCon = '\ - ' + lan.soft.mysql_log_bin + ' ' + ToSize(rdata.msg) + '\ - \ -
' + lan.soft.mysql_log_err + '
\ - \ - ' - - $(".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 = 'key_buffer_sizeMB, ' + lan.soft.mysql_set_key_buffer_size + '
\ -query_cache_sizeMB, ' + lan.soft.mysql_set_query_cache_size + '
\ -tmp_table_sizeMB, ' + lan.soft.mysql_set_tmp_table_size + '
\ -innodb_buffer_pool_sizeMB, ' + lan.soft.mysql_set_innodb_buffer_pool_size + '
\ -innodb_log_buffer_sizeMB, ' + lan.soft.mysql_set_innodb_log_buffer_size + '
\ - \ -sort_buffer_sizeKB * ' + lan.soft.mysql_set_conn + ', ' + lan.soft.mysql_set_sort_buffer_size + '
\ -read_buffer_sizeKB * ' + lan.soft.mysql_set_conn + ', ' + lan.soft.mysql_set_read_buffer_size + '
\ -read_rnd_buffer_sizeKB * ' + lan.soft.mysql_set_conn + ', ' + lan.soft.mysql_set_read_rnd_buffer_size + '
\ -join_buffer_sizeKB * ' + lan.soft.mysql_set_conn + ', ' + lan.soft.mysql_set_join_buffer_size + '
\ -thread_stackKB * ' + lan.soft.mysql_set_conn + ', ' + lan.soft.mysql_set_thread_stack + '
\ -binlog_cache_sizeKB * ' + lan.soft.mysql_set_conn + ', ' + lan.soft.mysql_set_binlog_cache_size + '
\ -thread_cache_size ' + lan.soft.mysql_set_thread_cache_size + '
\ -table_open_cache ' + lan.soft.mysql_set_table_open_cache + '
\ -max_connections ' + lan.soft.mysql_set_max_connections + '
\ - \ -