优化参数
set profiling=1;
select version();
set global slow_query_log=1;
set global long_query_time = 1;
set global max_connections=1000;
set global innodb_buffer_pool_size = 6442450944;# 4227858432
set global wait_timeout=180;
set global interactive_timeout=180;
show full processlist;
show variables like 'log_error';
show variables like 'innodb_buffer_pool_size';
show variables like 'slow_query_log';
show variables like 'long_query_time';
show variables like '%max_connections%';
show variables like '%max_user_connections%';
show table status ;
show status like 'Thread%';
show variables like 'back_log';
show variables like 'wait_timeout';
show OPEN TABLES where In_use > 0;
show global status like 'Max_used_connections';
show global variables like 'slow_query_log_file';
show profiles;
show profile;
show variables like '%engine%';
show variables like '%pro%';
show table status from xindun19 where name='dev_securityinfo';
show global status like '%wait%fre%';
-- information_schema.innodb_lock_waits–锁等待的对应关系
select * from information_schema.innodb_lock_waits;
#观察innodb利用率,如果Innodb_buffer_pool_wait_free值大于0,说明buffer_pool不够用;
show global status like '%wait%fre%';
性能监控
#1. QPS(每秒Query量)
#QPS = Questions(or Queries) / seconds
#show global status like 'Question%';
#2. TPS(每秒事务量)
#TPS = (Com_commit + Com_rollback) / seconds
show global status like 'Com_commit';
show global status like 'Com_rollback';
#3. key Buffer 命中率
show global status like 'key%';
key_buffer_read_hits = (1-key_reads / key_read_requests) * 100%
key_buffer_write_hits = (1-key_writes / key_write_requests) * 100%
#4. InnoDB Buffer命中率
show status like 'innodb_buffer_pool_read%';
innodb_buffer_read_hits = (1 - innodb_buffer_pool_reads / innodb_buffer_pool_read_requests) * 100%
#5. Query Cache命中率
show status like 'Qcache%';
Query_cache_hits = (Qcahce_hits / (Qcache_hits + Qcache_inserts )) * 100%;
#6. Table Cache状态量
show global status like 'open%';
#比较 open_tables 与 opend_tables 值
#7. Thread Cache 命中率
show global status like 'Thread%';
show global status like 'Connections';
#Thread_cache_hits = (1 - Threads_created / connections ) * 100%
#8. 锁定状态
show global status like '%lock%';
#Table_locks_waited/Table_locks_immediate=0.3% 如果这个比值比较大的话,说明表锁造成的阻塞比较严重
#Innodb_row_lock_waits innodb行锁,太大可能是间隙锁造成的
#9. 复制延时量
show slave status
#查看延时时间
#10. Tmp Table 状况(临时表状况)
show status like 'Create_tmp%';
#Created_tmp_disk_tables/Created_tmp_tables比值最好不要超过10%,如果Created_tmp_tables值比较大,
#可能是排序句子过多或者是连接句子不够优化
#11. Binlog Cache 使用状况
show status like 'Binlog_cache%';
#如果Binlog_cache_disk_use值不为0 ,可能需要调大 binlog_cache_size大小
#12. Innodb_log_waits 量
show status like 'innodb_log_waits';
#Innodb_log_waits值不等于0的话,表明 innodb log buffer 因为空间不足而等待
如果你喜欢我的分享,欢迎关注微信公众号 java学长分享技术干货!
悄悄告诉你免费赠送重磅互联网架构师教程,提升职场技术水平!
![](https://i-blog.csdnimg.cn/blog_migrate/2a06e920ddfceb5166dbd0905a22c125.png)