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 之间的整数值。设置为非整数值,则会给出错误。
评论