Enabling InnoDB Monitors

 Enabling InnoDB Monitors

When you enable InnoDB monitors for periodic output, InnoDB writes their output to the mysqld server standard error output (stderr). In this case, no output is sent to clients. When switched on, InnoDB monitors print data about every 15 seconds. Server output usually is directed to the error log (see Section 5.2.2, “The Error Log”). This data is useful in performance tuning. On Windows, start the server from a command prompt in a console window with the --console option if you want to direct the output to the window rather than to the error log.  >>当你开启innodb monitor以后,innodb会周期性(周期为15秒)的把monitor信息写入到errorlog中。这些信息对于性能调优有很大的帮助。

InnoDB sends diagnostic output to stderr or to files rather than to stdout or fixed-size memory buffers, to avoid potential buffer overflows. As a side effect, the output of SHOW ENGINE INNODB STATUS is written to a status file in the MySQL data directory every fifteen seconds. The name of the file isinnodb_status.pid, where pid is the server process ID. InnoDB removes the file for a normal shutdown. If abnormal shutdowns have occurred, instances of these status files may be present and must be removed manually. Before removing them, you might want to examine them to see whether they contain useful information about the cause of abnormal shutdowns. The innodb_status.pid file is created only if the configuration option innodb-status-file=1 is set.  >>为了避免造成缓冲区溢出,innodb会把monitor结果输出到stderr或者文件中,而不是输出到标准输出。作为开启innodb monitor的一个副作用,如果innodb-status-file=1(命令行参数,可以在mysql启动的时候指定,默认为关闭),那么show engine innodb status 命令的输出会被写入到datadir目录下的innodb_status.pid文件中。 innodb_status.pid文件会在mysql实例正常关闭的时候被删除,如果实例非正常关闭,那么该文件会被保留,需要我们手动删除。当然在删除之前我们可以先查看该文件记录的内容,看是否跟有跟mysql实例异常关闭有关的信息。

InnoDB monitors should be enabled only when you actually want to see monitor information because output generation does result in some performance decrement. Also, if you enable monitor output, your error log may become quite large if you forget to disable it later. >>innodb monitor只有在实际需要的时候才应该被开启,因为开启innodb monitor会对性能产生一定的影响,并且会使errorlog变的相当大。

Note

To assist with troubleshooting, InnoDB temporarily enables standard InnoDB Monitor output under certain conditions. For more information, see Section 14.19, “InnoDB Troubleshooting”.

Each monitor begins with a header containing a timestamp and the monitor name. For example:  >>下面是innodb monitor输出的开头

=====================================
2014-10-16 16:28:15 7feee43c5700 INNODB MONITOR OUTPUT
=====================================

The header for the standard InnoDB Monitor (INNODB MONITOR OUTPUT) is also used for the Lock Monitor because the latter produces the same output with the addition of extra lock information. 

Enabling an InnoDB monitor for periodic output involves using a CREATE TABLE statement to create a specially named InnoDB table that is associated with the monitor. For example, to enable the standard InnoDB Monitor, you would create an InnoDB table named innodb_monitor.  >>可以使用创建innodb_monitor表的方式来开启innodb monitor。

Using CREATE TABLE syntax is just a way to pass a command to the InnoDB engine through MySQL's SQL parser. The only things that matter are the table name and that it be an InnoDB table. The structure of the table is not relevant. If you shut down the server, the monitor does not restart automatically when you restart the server. Drop the monitor table and issue a new CREATE TABLE statement to start the monitor.  >>使用创建表的方式来开启innodb monitor我们需要注意是 创建的表名必须是innodb_monitor,表的存储引擎必须是innodb,跟表结构是无关的。如果你创建过innodb_monitor表后重启mysql实例,此时innodb monitor不会自动启用,我们需要先drop table innodb_monitor,然后create table innodb_monitor来开启monitor。

Note

The CREATE TABLE method of enabling InnoDB monitors is deprecated and may be removed in a future release. As of MySQL 5.6.16, you can enable the standard InnoDB Monitor and InnoDB Lock Monitor using the innodb_status_output andinnodb_status_output_locks system variables.  >>使用create table方法来开启innodb monitor的方法在将来的mysql版本中会把弃用,自MySQL 5.6.16开始 我们可以通过设置innodb_status_output和innodb_status_output_locks参数来开启 innodb monitor。

The PROCESS privilege is required to enable and disable InnoDB Monitors. >>开启innodb monitor功能需要具有process权限

Enabling the Standard InnoDB Monitor

To enable the standard InnoDB Monitor for periodic output, create the innodb_monitor table: >>使用建表方式开启innodb monitor

CREATE TABLE innodb_monitor (a INT) ENGINE=INNODB;

To disable the standard InnoDB Monitor, drop the table: >>对于使用create table方式开启的innodb monitor我们可以通过drop table来关闭innodb monitor

DROP TABLE innodb_monitor;

As of MySQL 5.6.16, you can also enable the standard InnoDB Monitor by setting the innodb_status_output system variable to ON. >>自MySQL 5.6.16开始可以通过innodb_status_output来启用 innodb monitor

set GLOBAL innodb_status_output=ON;

To disable the standard InnoDB Monitor, set innodb_status_output to OFF. >>对于使用innodb_status_output=1开启的innodb monitor我们可以通过设置innodb_status_output=0来关闭 innodb monitor。

When you shut down the server, the innodb_status_output variable is set to the default OFF value. >>当我们关闭mysql实例后,innodb_status_output会被自动设置为off。

Obtaining Standard InnoDB Monitor Output On Demand

As an alternative to enabling the standard InnoDB Monitor for periodic output, you can obtain standard InnoDB Monitor output on demand using the SHOW ENGINE INNODB STATUS SQL statement, which fetches the output to your client program. If you are using the mysql interactive client, the output is more readable if you replace the usual semicolon statement terminator with \G: >>开启innodb monitor后,你可以通过show engine innodb status\G;来查看输出。

mysql> SHOW ENGINE INNODB STATUS\G

SHOW ENGINE INNODB STATUS output also includes InnoDB Lock Monitor data if the InnoDB Lock Monitor is enabled. >>如果innodb lock monitor被启用,show engine innodb status输出信息中会包含innodb lock信息。

Enabling the InnoDB Lock Monitor  >>开启innodb lock monitor

To enable the InnoDB Lock Monitor for periodic output, create the innodb_lock_monitor table: >>通过建innodb_lock_monitor表的方式开启 innodb lock monitor。

CREATE TABLE innodb_lock_monitor (a INT) ENGINE=INNODB;

To disable the InnoDB Lock Monitor, drop the table:  >>通过create table的方式开启的innodb lock monitor,通过drop table 来关闭。

DROP TABLE innodb_lock_monitor;

As of MySQL 5.6.16, you can also enable the InnoDB Lock Monitor by setting the innodb_status_output_locks system variable to ON. As with the CREATE TABLE method for enabling InnoDB Monitors, both the InnoDB standard Monitor and InnoDB Lock Monitor must be enabled to have InnoDBLock Monitor data printed periodically: >>同innodb monitor一样,在MySQL 5.6.16之后可以通过参数设置innodb_status_output_locks=1来开启innodb lock monitor。如果想把lock monitor信息打印到errorlog中,你必须同时创建innodb_monitor和innodb_lock_monitor两张表,或者同时设置innodb_status_output和innodb_status_output_locks为on

set GLOBAL innodb_status_output=ON;
set GLOBAL innodb_status_output_locks=ON;

When you shut down the server, the innodb_status_output and innodb_status_output_locks variables are set to the default OFF value.  >>当你关闭mysql server时,innodb_status_output和innodb_status_output_locks会被自动置为off。

To disable the InnoDB Lock Monitor, set innodb_status_output_locks to OFF. Set innodb_status_output to OFF to also disable the standard InnoDBMonitor.

Note

To enable the InnoDB Lock Monitor for SHOW ENGINE INNODB STATUS output, you are only required to enableinnodb_status_output_locks. >>如果只是通过show engine innodb status来查看lock monitor信息,那么你只需要设置innodb_status_output_locks参数为on即可。

Enabling the InnoDB Tablespace Monitor

To enable the InnoDB Tablespace Monitor for periodic output, create the innodb_tablespace_monitor table: >>使用如下方法开启innodb tablespace监控

CREATE TABLE innodb_tablespace_monitor (a INT) ENGINE=INNODB;

To disable the standard InnoDB Tablespace Monitor, drop the table:  >>使用如下方法关闭innodb tablespace monitor

DROP TABLE innodb_tablespace_monitor;
Note

The Tablespace Monitor is deprecated and will be removed in a future MySQL release.  >>tablespace monitor在以后的版本中将要被去掉

Enabling the InnoDB Table Monitor

To enable the InnoDB Table Monitor for periodic output, create the innodb_table_monitor table:  >>开启innodb table monitor方法如下

CREATE TABLE innodb_table_monitor (a INT) ENGINE=INNODB;

To disable the InnoDB Table Monitor, drop the table:  >>关闭innodb table monitor 方法如下

DROP TABLE innodb_table_monitor;
Note

The Tablespace Monitor is deprecated and will be removed in a future MySQL release.

##摘自官方文档:

http://dev.mysql.com/doc/refman/5.6/en/innodb-enabling-monitors.html



你可能感兴趣的:(InnoDB,monitors,innodb_monitor)