mysql 的重要参数,监控需要

以下是个人整理的Mysql一些重要的参数,需要通过监视工具监视

show status like 'Threads_connected';                    --变量的值是表示当前有多少个客户连接该mysql服务器,连接数是否过多,网络时候存在问题!特别是在pconnect的情况下:)
show status like 'created_tmp_tables';                    --在硬盘上建立的临时表数目,如果这个值比较大的话,那么查询时需要建立临时表(CREATE TEMPORARY TABLE)的操作 就要消耗更多的时间
show status like 'handler_read_first';                    --读表索引的第一行,如果这个值变化比较大的话,可以认为表索引建立的有问题,全索引的扫描操作比较多

show status like 'key_reads';                            --读文件系统上面的索引的次数,如果这个值太大的话,就需要考虑key cache设置是否正常了
show status like 'max_used_connections';                --重起后到现在最大连接数,服务器负载和可能需要调节的连接数
show status like 'Open_tables';                            --当前打开的表的数目;如果这个值很低,table cache很大,则减小table cache的设置是没有问题的,如果这个值很大,并接近了table cache的值,我们就需要加大talbe cache的设置
flush tables;
show status like 'select_full_join';                    --全连接的查询数目,数值过大,需要建立更多的索引来避免
show status like 'Slow_queries';                        --慢查询的数目,过大的话就要察看慢查询的日志,并且检查sql语句书写是否恰当
show status like 'uptime';                                --运行时间,单位秒

select * from performance_schema.replication_group_members; --MGR查看 show status like 'table_locks_immediate'; --产生表锁的次数,表示可以立即获取锁的查询次数,每立即获取锁加1 show status like 'table_locks_waited'; --出现表锁争用而发生的次数(不能立即获取锁的次数,每等待一次加1),此值较高说明存在着较严重的表级锁争用情况 show status like 'innodb_row_lock_current_waits'; --当前正在等待锁定的数量 show status like 'innodb_row_lock_time' --从系统启动到现在锁定总时间的长度 show status like 'innodb_row_lock_time_avg'; --每次等待所花平均时间 show status like 'innodb_row_lock_time_max'; --从系统启动到现在等待最常的一次所花的时间 show status like 'innodb_row_lock_waits'; --系统启动到现在总共等待的次数 show global status like 'Innodb_buffer_pool_read_requests'; --逻辑读 ,从缓冲池中读取页的次数 show global status like 'Innodb_buffer_pool_reads'; --物理读 show global status like 'Innodb_data_reads'; --发起读取请求的次数,每次读取可能需要读取多个页 show global status like 'Innodb_data_read'; --总共读入的字节数 show global status like 'Innodb_rows_read'; --总共读入的行数 show global status like 'Innodb_pages_read'; --总共读入的页数 show global status like 'Innodb_buffer_pool_read_ahead'; --预读的次数 show global status like 'Innodb_buffer_pool_read_ahead_evicted'; --预读的页,但是没有被读取就从缓冲池中被替换的页的数量,一般用来判断预读的效率 show status like 'innodb_buffer_pool_wait_free'; --If this variable is high, it suggests that MySQL's memory buffer is incorrectly configured for the amount of writes the server is currently performing. show status like 'Innodb_buffer_pool_pages_free'; --free pages show variables like 'innodb_buffer_pool_size'; --total page for buffer 分配给缓冲池的页面总数量(数量*页面大小=缓冲池大小),默认每个Page为16k。(8192X16K/1024=128M) show status like 'Qcache_hits'; --查询缓存命中次数 show variables like 'innodb_log_file_size'; --log file size show variables like 'innodb_log_files_in_group'; --log file number show variables like 'innodb_data_file_path'; --undo file show variables like 'innodb_file_per_table'; --共享表空间 mysql -uroot -p -P 3306 -e "show engine innodb status G"|grep "srv_master_thread " --负载 show variables like 'innodb_max_dirty_pages_pct'; --脏页百分比 mysql -uroot -p -P 3306 -e "show engine innodb status G"|grep insert --inserted,update,deleted read count mysql> show global status like 'Innodb%dblwr%';         --Innodb_dblwr_pages_written/Innodb_dblwr_writes <64 表示IO 没压力,反之则有 +----------------------------+-------+ | Variable_name | Value | +----------------------------+-------+ | Innodb_dblwr_pages_written | 285 | | Innodb_dblwr_writes | 62 | +----------------------------+-------+ 2 rows in set (0.00 sec) SELECT SUM(stat_value) pages, index_name, SUM(stat_value)*@@innodb_page_size size FROM mysql.innodb_index_stats WHERE table_name='dept_emp' AND stat_name = 'size' GROUP BY index_name;
原文地址:https://www.cnblogs.com/tingxin/p/14111564.html