MySQL :: MySQL 5.7 Reference Manual :: 14.18.2 Enabling InnoDB Monitors (original) (raw)

14.18.2 Enabling InnoDB Monitors

When InnoDB monitors are enabled for periodic output, InnoDB writes the output tomysqld server standard error output (stderr) every 15 seconds, approximately.

InnoDB sends the monitor output tostderr rather than to stdout or fixed-size memory buffers to avoid potential buffer overflows.

On Windows, stderr is directed to the default log file unless configured otherwise. If you want to direct the output to the console window rather than to the error log, start the server from a command prompt in a console window with the--console option. For more information, see Section 5.4.2.1, “Error Logging on Windows”.

On Unix and Unix-like systems, stderr is typically directed to the terminal unless configured otherwise. For more information, see Section 5.4.2.2, “Error Logging on Unix and Unix-Like Systems”.

InnoDB monitors should only be enabled when you actually want to see monitor information because output generation causes some performance decrement. Also, if monitor output is directed to the error log, the log may become quite large if you forget to disable the monitor later.

InnoDB monitor output begins with a header containing a timestamp and the monitor name. For example:

=====================================
2014-10-16 18:37:29 0x7fc2a95c1700 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.

The innodb_status_output andinnodb_status_output_locks system variables are used to enable the standardInnoDB Monitor and InnoDB Lock Monitor.

The PROCESS privilege is required to enable or disable InnoDB Monitors.

Enabling the Standard InnoDB Monitor

Enable the standard InnoDB Monitor by setting the innodb_status_output system variable to ON.

SET GLOBAL innodb_status_output=ON;

To disable the standard InnoDB Monitor, setinnodb_status_output toOFF.

When you shut down the server, theinnodb_status_output variable is set to the default OFF value.

Enabling the InnoDB Lock Monitor

InnoDB Lock Monitor data is printed with theInnoDB Standard Monitor output. Both theInnoDB Standard Monitor andInnoDB Lock Monitor must be enabled to haveInnoDB Lock Monitor data printed periodically.

To enable the InnoDB Lock Monitor, set theinnodb_status_output_locks system variable to ON. Both theInnoDB standard Monitor andInnoDB Lock Monitor must be enabled to haveInnoDB Lock Monitor data printed periodically:

SET GLOBAL innodb_status_output=ON;
SET GLOBAL innodb_status_output_locks=ON;

To disable the InnoDB Lock Monitor, setinnodb_status_output_locks toOFF. Setinnodb_status_output toOFF to also disable theInnoDB Standard Monitor.

When you shut down the server, theinnodb_status_output andinnodb_status_output_locks variables are set to the default OFF value.

Obtaining Standard InnoDB Monitor Output On Demand

As an alternative to enabling the standardInnoDB 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:

mysql> SHOW ENGINE INNODB STATUS\G

SHOW ENGINE INNODB STATUS output also includes InnoDB Lock Monitor data if the InnoDB Lock Monitor is enabled.

Directing Standard InnoDB Monitor Output to a Status File

Standard InnoDB Monitor output can be enabled and directed to a status file by specifying the--innodb-status-file option at startup. When this option is used, InnoDB creates a file namedinnodb_status._`pid`_ in the data directory and writes output to it every 15 seconds, approximately.

InnoDB removes the status file when the server is shut down normally. If an abnormal shutdown occurs, the status file may have to be removed manually.

The --innodb-status-file option is intended for temporary use, as output generation can affect performance, and theinnodb_status._`pid`_ file can become quite large over time.