Merge pull request #243 from midoks/dev

query_cache_size优化
pull/253/head
Mr Chen 3 years ago committed by GitHub
commit 63f9b577aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      plugins/mysql/conf/my5.7.cnf
  2. 26
      plugins/mysql/index.py
  3. 1
      plugins/mysql/js/mysql.js
  4. 22
      rewrite/nginx/cloudfare_real_ip.conf

@ -22,6 +22,7 @@ server-id = {$SERVER_ID}
default_storage_engine = InnoDB default_storage_engine = InnoDB
key_buffer_size = 8M key_buffer_size = 8M
table_open_cache = 32 table_open_cache = 32
sort_buffer_size = 256K sort_buffer_size = 256K
@ -31,6 +32,7 @@ read_rnd_buffer_size = 256K
myisam_sort_buffer_size = 4M myisam_sort_buffer_size = 4M
thread_cache_size = 4 thread_cache_size = 4
lower_case_table_names=0 lower_case_table_names=0
query_cache_size = 4M
tmp_table_size = 8M tmp_table_size = 8M
character-set-server = UTF8MB4 character-set-server = UTF8MB4

@ -681,14 +681,13 @@ def setMyPort():
return mw.returnJson(True, '编辑成功!') return mw.returnJson(True, '编辑成功!')
def runInfo(): def runInfo(version):
if status(version) == 'stop': if status(version) == 'stop':
return mw.returnJson(False, 'MySQL未启动', []) return mw.returnJson(False, 'MySQL未启动', [])
db = pMysqlDb() db = pMysqlDb()
data = db.query('show global status') data = db.query('show global status')
gets = ['Max_used_connections', 'Com_commit', 'Com_rollback', 'Questions', 'Innodb_buffer_pool_reads', 'Innodb_buffer_pool_read_requests', 'Key_reads', 'Key_read_requests', 'Key_writes', gets = ['Max_used_connections', 'Com_commit', 'Com_select', 'Com_rollback', 'Questions', 'Innodb_buffer_pool_reads', 'Innodb_buffer_pool_read_requests', 'Key_reads', 'Key_read_requests', 'Key_writes',
'Key_write_requests', 'Qcache_hits', 'Qcache_inserts', 'Bytes_received', 'Bytes_sent', 'Aborted_clients', 'Aborted_connects', 'Key_write_requests', 'Qcache_hits', 'Qcache_inserts', 'Bytes_received', 'Bytes_sent', 'Aborted_clients', 'Aborted_connects',
'Created_tmp_disk_tables', 'Created_tmp_tables', 'Innodb_buffer_pool_pages_dirty', 'Opened_files', 'Open_tables', 'Opened_tables', 'Select_full_join', 'Created_tmp_disk_tables', 'Created_tmp_tables', 'Innodb_buffer_pool_pages_dirty', 'Opened_files', 'Open_tables', 'Opened_tables', 'Select_full_join',
'Select_range_check', 'Sort_merge_passes', 'Table_locks_waited', 'Threads_cached', 'Threads_connected', 'Threads_created', 'Threads_running', 'Connections', 'Uptime'] 'Select_range_check', 'Sort_merge_passes', 'Table_locks_waited', 'Threads_cached', 'Threads_connected', 'Threads_created', 'Threads_running', 'Connections', 'Uptime']
@ -713,7 +712,7 @@ def runInfo():
return mw.getJson(result) return mw.getJson(result)
def myDbStatus(): def myDbStatus(version):
result = {} result = {}
db = pMysqlDb() db = pMysqlDb()
data = db.query('show variables') data = db.query('show variables')
@ -723,6 +722,10 @@ def myDbStatus():
gets = ['table_open_cache', 'thread_cache_size', 'key_buffer_size', 'tmp_table_size', 'max_heap_table_size', 'innodb_buffer_pool_size', gets = ['table_open_cache', 'thread_cache_size', 'key_buffer_size', 'tmp_table_size', 'max_heap_table_size', 'innodb_buffer_pool_size',
'innodb_additional_mem_pool_size', 'innodb_log_buffer_size', 'max_connections', 'sort_buffer_size', 'read_buffer_size', 'read_rnd_buffer_size', 'join_buffer_size', 'thread_stack', 'binlog_cache_size'] 'innodb_additional_mem_pool_size', 'innodb_log_buffer_size', 'max_connections', 'sort_buffer_size', 'read_buffer_size', 'read_rnd_buffer_size', 'join_buffer_size', 'thread_stack', 'binlog_cache_size']
if version != "8.0":
gets.append('query_cache_size')
result['mem'] = {} result['mem'] = {}
for d in data: for d in data:
vname = d['Variable_name'] vname = d['Variable_name']
@ -733,9 +736,16 @@ def myDbStatus():
return mw.getJson(result) return mw.getJson(result)
def setDbStatus(): def setDbStatus(version):
gets = ['key_buffer_size', 'tmp_table_size', 'max_heap_table_size', 'innodb_buffer_pool_size', 'innodb_log_buffer_size', 'max_connections', gets = ['key_buffer_size', 'tmp_table_size', 'max_heap_table_size', 'innodb_buffer_pool_size', 'innodb_log_buffer_size', 'max_connections',
'table_open_cache', 'thread_cache_size', 'sort_buffer_size', 'read_buffer_size', 'read_rnd_buffer_size', 'join_buffer_size', 'thread_stack', 'binlog_cache_size'] 'table_open_cache', 'thread_cache_size', 'sort_buffer_size', 'read_buffer_size', 'read_rnd_buffer_size', 'join_buffer_size', 'thread_stack', 'binlog_cache_size']
if version != "8.0":
# gets.append('query_cache_size')
gets = ['key_buffer_size', 'query_cache_size', 'tmp_table_size', 'max_heap_table_size', 'innodb_buffer_pool_size', 'innodb_log_buffer_size', 'max_connections',
'table_open_cache', 'thread_cache_size', 'sort_buffer_size', 'read_buffer_size', 'read_rnd_buffer_size', 'join_buffer_size', 'thread_stack', 'binlog_cache_size']
# print(gets)
emptys = ['max_connections', 'thread_cache_size', 'table_open_cache'] emptys = ['max_connections', 'thread_cache_size', 'table_open_cache']
args = getArgs() args = getArgs()
conFile = getConf() conFile = getConf()
@ -2496,11 +2506,11 @@ if __name__ == "__main__":
elif func == 'uninstall_pre_inspection': elif func == 'uninstall_pre_inspection':
print(uninstallPreInspection(version)) print(uninstallPreInspection(version))
elif func == 'run_info': elif func == 'run_info':
print(runInfo()) print(runInfo(version))
elif func == 'db_status': elif func == 'db_status':
print(myDbStatus()) print(myDbStatus(version))
elif func == 'set_db_status': elif func == 'set_db_status':
print(setDbStatus()) print(setDbStatus(version))
elif func == 'conf': elif func == 'conf':
print(getConf()) print(getConf())
elif func == 'bin_log': elif func == 'bin_log':

@ -88,6 +88,7 @@ function runInfo(){
return; return;
} }
// Com_select , Qcache_inserts
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="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">\

@ -1,28 +1,28 @@
location / { location / {
# https://www.cloudflare.com/zh-cn/ips/ # https://www.cloudflare.com/zh-cn/ips/
set_real_ip_from 173.245.48.0/20;
set_real_ip_from 103.21.244.0/22; set_real_ip_from 103.21.244.0/22;
set_real_ip_from 103.22.200.0/22; set_real_ip_from 103.22.200.0/22;
set_real_ip_from 103.31.4.0/22; set_real_ip_from 103.31.4.0/22;
set_real_ip_from 104.16.0.0/13;
set_real_ip_from 104.24.0.0/14;
set_real_ip_from 108.162.192.0/18;
set_real_ip_from 131.0.72.0/22;
set_real_ip_from 141.101.64.0/18; set_real_ip_from 141.101.64.0/18;
set_real_ip_from 162.158.0.0/15; set_real_ip_from 108.162.192.0/18;
set_real_ip_from 172.64.0.0/13; set_real_ip_from 190.93.240.0/20;
set_real_ip_from 173.245.48.0/20; set_real_ip_from 188.114.96.0/20;
set_real_ip_from 188.114.96.0/20; set_real_ip_from 197.234.240.0/22;
set_real_ip_from 190.93.240.0/20;
set_real_ip_from 197.234.240.0/22;
set_real_ip_from 198.41.128.0/17; set_real_ip_from 198.41.128.0/17;
set_real_ip_from 162.158.0.0/15;
set_real_ip_from 104.16.0.0/13;
set_real_ip_from 104.24.0.0/14;
set_real_ip_from 172.64.0.0/13;
set_real_ip_from 131.0.72.0/22;
set_real_ip_from 2400:cb00::/32; set_real_ip_from 2400:cb00::/32;
set_real_ip_from 2606:4700::/32; set_real_ip_from 2606:4700::/32;
set_real_ip_from 2803:f800::/32; set_real_ip_from 2803:f800::/32;
set_real_ip_from 2405:b500::/32; set_real_ip_from 2405:b500::/32;
set_real_ip_from 2405:8100::/32; set_real_ip_from 2405:8100::/32;
set_real_ip_from 2c0f:f248::/32;
set_real_ip_from 2a06:98c0::/29; set_real_ip_from 2a06:98c0::/29;
set_real_ip_from 2c0f:f248::/32;
# use any of the following two # use any of the following two
real_ip_header CF-Connecting-IP; real_ip_header CF-Connecting-IP;
#real_ip_header X-Forwarded-For; #real_ip_header X-Forwarded-For;

Loading…
Cancel
Save