当启用 InnoDB 监控器以进行定期输出时,InnoDB 会将输出写入 mysqld 服务器标准错误输出(stderr),大约每 15 秒一次。When InnoDB monitors are enabled for periodic
output, InnoDB writes the output to
mysqld server standard error output
(stderr) every 15 seconds, approximately.
InnoDB 将监控器输出发送到 stderr,而不是 stdout 或固定大小的内存缓冲区,以避免潜在的缓冲区溢出。InnoDB sends the monitor output to
stderr rather than to stdout
or fixed-size memory buffers to avoid potential buffer overflows.
在 Windows 上,stderr 会被定向到默认日志文件,除非另行配置。如果您想将输出定向到控制台窗口,而不是错误日志,请在控制台窗口的命令提示符下使用 --console 选项启动服务器。有关更多信息,请参见 Windows 上的默认错误日志目标。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
Default Error Log Destination on Windows.
在 Unix 及类 Unix 系统中,stderr 通常会被定向到终端,除非另行配置。更多信息,请参见 Unix 和类 Unix 系统的默认错误日志目的地。On Unix and Unix-like systems, stderr is
typically directed to the terminal unless configured otherwise.
For more information, see
Default Error Log Destination on Unix and Unix-Like Systems.
只有在你确实想查看监控信息时才应启用 InnoDB 监控器,因为生成输出会导致一些性能下降。此外,如果监控器输出被定向到错误日志,如果之后忘记禁用监控器,日志可能会变得非常大。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 在某些情况下会临时启用标准的 InnoDB 监控输出。有关更多信息,请参阅 第 17.20 节,“InnoDB 故障排除”。To assist with troubleshooting, InnoDB
temporarily enables standard InnoDB Monitor
output under certain conditions. For more information, see
Section 17.20, “InnoDB Troubleshooting”.
InnoDB 监控输出以包含时间戳和监控名称的标题开始。例如: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 =====================================
标准 InnoDB 监控器(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.
innodb_status_output 和 innodb_status_output_locks 系统变量用于启用标准的 InnoDB 监控器和 InnoDB 锁监控器。The innodb_status_output and
innodb_status_output_locks system
variables are used to enable the standard
InnoDB Monitor and InnoDB
Lock Monitor.
启用或禁用 InnoDB 监控器需要 PROCESS 权限。The PROCESS privilege is required
to enable or disable InnoDB Monitors.
启用标准 InnoDB 监控器Enabling the Standard InnoDB Monitor
通过将 innodb_status_output 系统变量设置为 ON 来启用标准 InnoDB 监控器。Enable the standard InnoDB Monitor by setting
the innodb_status_output system
variable to ON.
SET GLOBAL innodb_status_output=ON;
要禁用标准的 InnoDB 监控器,请将 innodb_status_output 设置为 OFF。To disable the standard InnoDB Monitor, set
innodb_status_output to
OFF.
当您关闭服务器时,innodb_status_output 变量会被设置为默认的 OFF 值。When you shut down the server, the
innodb_status_output variable is
set to the default OFF value.
启用 InnoDB 锁监控器Enabling the InnoDB Lock Monitor
InnoDB 锁监控器的数据随 InnoDB 标准监控器的输出一起打印。必须同时启用 InnoDB 标准监控器和 InnoDB 锁监控器,才能定期打印 InnoDB 锁监控器的数据。InnoDB Lock Monitor data is printed with the
InnoDB Standard Monitor output. Both the
InnoDB Standard Monitor and
InnoDB Lock Monitor must be enabled to have
InnoDB Lock Monitor data printed periodically.
要启用 InnoDB 锁监视器,请将 innodb_status_output_locks 系统变量设置为 ON。必须同时启用 InnoDB 标准监视器和 InnoDB 锁监视器,才能定期打印 InnoDB 锁监视器数据:To enable the InnoDB Lock Monitor, set the
innodb_status_output_locks system
variable to ON. Both the
InnoDB standard Monitor and
InnoDB Lock Monitor must be enabled to have
InnoDB Lock Monitor data printed periodically:
SET GLOBAL innodb_status_output=ON; SET GLOBAL innodb_status_output_locks=ON;
要禁用 InnoDB 锁监控器,请将 innodb_status_output_locks 设置为 OFF。若要同时禁用 InnoDB 标准监控器,请将 innodb_status_output 设置为 OFF。To disable the InnoDB Lock Monitor, set
innodb_status_output_locks to
OFF. Set
innodb_status_output to
OFF to also disable the
InnoDB Standard Monitor.
当您关闭服务器时,innodb_status_output 和 innodb_status_output_locks 变量将被设置为默认的 OFF 值。When you shut down the server, the
innodb_status_output and
innodb_status_output_locks
variables are set to the default OFF value.
要为 InnoDB 输出启用 SHOW ENGINE INNODB
STATUS 锁监视器,您只需启用 innodb_status_output_locks。To enable the InnoDB Lock Monitor for
SHOW ENGINE INNODB
STATUS output, you are only required to enable
innodb_status_output_locks.
按需获取标准 InnoDB 监视器输出Obtaining Standard InnoDB Monitor Output On Demand
作为启用标准 InnoDB 监视器以定期输出的替代方法,您可以使用 InnoDB SQL 语句按需获取标准 SHOW ENGINE
INNODB STATUS 监视器输出,该语句会将输出提取到您的客户端程序。如果您使用 mysql 交互式客户端,当您将通常的分号语句结束符替换为 \G 时,输出会更易读: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:
mysql> SHOW ENGINE INNODB STATUS\G
SHOW ENGINE INNODB
STATUS 的输出还包括 InnoDB 锁监视器数据,如果 InnoDB 锁监视器已启用。SHOW ENGINE INNODB
STATUS output also includes InnoDB
Lock Monitor data if the InnoDB Lock Monitor is
enabled.
将标准 InnoDB 监视器输出重定向到状态文件Directing Standard InnoDB Monitor Output to a Status File
通过在启动时指定 --innodb-status-file 选项,可以启用标准 InnoDB 监视器输出并将其重定向到状态文件。当使用此选项时,InnoDB 会在数据目录中创建一个名为 innodb_status. 的文件,并大约每 15 秒将输出写入该文件。Standard pidInnoDB 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 named
innodb_status.
in the data directory and writes output to it every 15 seconds,
approximately.pid
InnoDB 在服务器正常关闭时会移除状态文件。如果发生异常关闭,可能需要手动移除状态文件。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.
--innodb-status-file 选项用于临时使用,因为生成输出可能影响性能,而且 innodb_status. 文件随着时间可能会变得相当大。The pid--innodb-status-file option is intended for
temporary use, as output generation can affect performance, and
the
innodb_status.
file can become quite large over time.pid