通过查看mysql 配置参数、状态来优化你的mysql
2012-08-20 17:03:17 来源:WEB开发网 mysql的监控方法大致分为两类:
1.连接到mysql数据库内部,使用show status,show variables,flush status 来查看mysql的各种性能指标。
2. 直接使用mysqladmin查看其性能指标,例如:
UserParameter=mysql.uptime,mysqladmin -uroot status|cut -f2 -d":"|cut -f1 -d"T"
mysqladmin两个参数,status,extended-status
shell > mysqladmin -uroot -ppassword variables status
可得到以下信息(后面详解)
--------------------------------------------------------------------------------------------------------------------------
Uptime: 4557887 #mysql运行的秒数
Threads: 1 #连接数
Questions: 1684130 #The number of questions (queries) from clients since the server was started.
Slow queries: 0 #The number of queries that have taken more than long_query_time seconds
Opens: 221872 #The number of tables the server has opened.
Flush tables: 1 #The number of flush-*, refresh, and reload commands the server has executed.
Open tables: 64 #The number of tables that currently are open.
Queries per second avg: 0.369 #从上次运行开始计算,每秒钟平均查询次数
-----------------------------------------------------------------------------------------------------
Questions = Com_* + Qcache_hits
最完整的信息
shell > mysqladmin -uroot -ppassword variables extended-status
其他的信息
shell > /usr/libexec/mysqld --verbose --help (这个命令生成所有mysqld选项和可配置变量的列表 )
mysql>SHOW STATUS; (服务器状态变量,运行服务器的统计和状态指标)
mysql> SHOW VARIABLES;(服务器系统变量,实际上使用的变量的值)
或者
mysql>SHOW STATUS LIKE '%变量名% ' ;
对配置参数的说明:
配置参数的格式如下:(shell > mysqladmin -uroot -ppassword variables extended-status)
-----------------------------
+-----------------------------------------+------------------------------------------------------------+
| Variable_name | Value |
+-----------------------------------------+------------------------------------------------------------+
| auto_increment_increment | 1 |
| auto_increment_offset | 1 |
| automatic_sp_privileges | ON |
.........
注:value 值的单位是byte ,要得到M ,需除以2次1024
-----------------------------------
Uptime 4405546
MySQL服务器已经运行的秒数
-----------------------------------
auto_increment_increment 1
auto_increment_offset 1
两个变量值都只能为1到65,535之间的整数值。设置为非整数值,则会给出错误。
更多精彩
赞助商链接