When running InnoDB you are able to dig into the engine internals, look at various gauges and counters, see past deadlocks and the list of all open transactions. This is in your reach with one simple command -

SHOW ENGINE INNODB STATUS

. On most occasions it works beautifully. The problems appear when you have a large spike in number of connections to MySQL, which often happens when several transactions kill the database performance resulting in very long execution times for even simplest queries, or a huge deadlock.

In such rare cases

SHOW ENGINE INNODB STATUS

often fails to provide the necessary information. The reason is that its output is limited to 64000 bytes, so a long list of transactions or a large deadlock dump may easily exhaust the limit. MySQL in such situation truncates the output so it fits the required size and obviously this is not good since you may lose some valuable information from your sight.

With large deadlocks you can actually deal by intentionally creating a new tiny deadlock which will replace the previous one in the output thus reducing the space occupied by that section of InnoDB status. Baron once wrote an article on how to do this.

There is not such easy way for the long transaction list, but fortunately there are some alternatives to the limited MySQL command output.

First one is that you can have innodb-status-file option set in your my.cnf. This will make InnoDB to write the full status output into

innodb_status.<PID>

file located in MySQL data directory. Unfortunately this is a startup time parameter, so unless you set it early, it will not be available in an emergency situation.

Other possibility is to create a special InnoDB table called innodb_monitor

CREATE TABLE innodb_monitor(a INT) ENGINE=innodb;

Creating it causes the full status to be periodically printed into MySQL error log. You can later disable logging by simply dropping the table. The problem I faced many times is that people do not configure their error log at all, so the messages disappear into nothingness. So what then?

I discovered that InnoDB will still create the status file on disk even if you do not specify innodb-status-file option. The file is actually used for every

SHOW ENGINE INNODB STATUS

call, so whenever someone runs the command, InnoDB writes the output to that file first and then the stored information is read back to user. To make things more difficult, MySQL keeps the file deleted, so it is not possible access it with a simple catfilename or any other command through the file system. However on many systems such as Linux or Solaris, but possibly also others, there is a relatively simple way to access deleted but not-yet-closed files (file is physically removed only after it is no longer open by any process).

First be sure to run

SHOW ENGINE INNODB STATUS

at least once. Then see what MySQL process ID is:

garfield ~ # ps ax | grep [m]ysqld
? Ssl : /usr/sbin/mysqld --defaults-file=/etc/mysql/my.cnf

In my case the process ID is 11886, so I will be using it in the examples, but you should of course use whatever PS returned to you.

Now you can use /proc to see all the file descriptors that are being kept open by the process. So go to /proc/<PID> and list all the files that were deleted.

garfield ~ # cd /proc//fd
garfield fd # ls -l | grep deleted
lrwx------ root root Oct : -> /tmp/iblnLBhO (deleted)
lrwx------ root root Oct : -> /tmp/ibuQBSgo (deleted)
lrwx------ root root Oct : -> /tmp/ibLVtBuZ (deleted)
lrwx------ root root Oct : -> /tmp/ibsMzkIA (deleted)
lrwx------ root root Oct : -> /tmp/ibj08Rkc (deleted)

The entries are presented as symbolic links from file descriptor number to a real path as in

 -> /tmp/iblnLBhO

One of these entries is what you are looking for, it’s often (always?) the file with the lowest file descriptor number, so in my case it should be 5. But of course you can try reading a few first bytes from every such file to discover where InnoDB status is. You can also help yourself with lsof

tool available for many platforms:

garfield fd # lsof -c mysqld | grep deleted
mysqld mysql 5u REG , /tmp/ibuQBSgo (deleted)
mysqld mysql 6u REG , /tmp/ibLVtBuZ (deleted)
mysqld mysql 7u REG , /tmp/ibsMzkIA (deleted)
mysqld mysql 8u REG , /tmp/ibj08Rkc (deleted)
mysqld mysql 12u REG , /tmp/iblnLBhO (deleted)

The 4th column contains file descriptor numbers and in the 7th column there are the file sizes. This makes it obvious that InnoDB status has to be under file descriptor 5 since it’s the only non-zero length file.

So while you are still in /proc/<PID> directory, you can try looking into that file:

garfield fd # cat
=====================================
:: INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last seconds
----------
SEMAPHORES
----------
... snip ...

Keep in mind the file will only be refreshed when you run

SHOW ENGINE INNODB STATUS

command.

参考:http://www.mysqlperformanceblog.com/2008/10/31/full-innodb-status/

A quest for the full InnoDB status的更多相关文章

  1. mysql 查看存储引擎的状态 show engine innodb status 详解

    首先,让我们来了解一下 SHOW INNODB STATUS 输出的基础,它打印了很多关于 InnoDB 内部性能相关的计数器.统计.事务处理信息等.在 MySQL 5 中,InnoDB 的性能统计结 ...

  2. mysql之show engine innodb status解读

    注:以下内容为根据<高性能mysql第三版>和<mysql技术内幕innodb存储引擎>的innodb status部分的个人理解,如果有错误,还望指正!!   innodb存 ...

  3. mysql:innodb monitor(show engine innodb status)探秘

    在旧的版本里面是show innodb status命令,新版本后改动了一些:show engine innodb status; 我们最熟悉的,应当就是show innodb status命令,可以 ...

  4. InnoDB Status Output – Buffer Pool and Spin Rounds

    InnoDB has a good source of information about its status which can be requested every time you need ...

  5. Using SHOW PROCESSLIST and mysqladmin debug Output in Conjunction with SHOW INNODB STATUS

    When InnoDB appears hung, I know the natural reaction is to check SHOW ENGINE INNODB STATUS. In fact ...

  6. show engine innodb status 详解

    找个mysql客户端,执行show engine innodb status得到如下结果: 详细信息如下: ************************************** ======= ...

  7. show engine innodb status\G

    mysql> show engine innodb status\G *************************** 1. row *************************** ...

  8. show engine innodb status解读

    xiaoboluo768   注:以下内容为根据<高性能mysql第三版>和<mysql技术内幕innodb存储引擎>的innodb status部分的个人理解,如果有错误,还 ...

  9. (Sqlyog或Navicat不友好处)SHOW ENGINE INNODB STATUS 结果为空或结果为=====================================

    因为最近在学习innodb引擎,所以就在自己的sqlyog上执行上述命令: SHOW ENGINE INNODB STATUS 结果显示如下: 换了个客户端navicat,执行如下: 最后登录到服务器 ...

随机推荐

  1. 转载一篇文章 python程序员经常犯的10个错误

    一位同事推荐的.翻译的不错. http://www.oschina.net/translate/top-10-mistakes-that-python-programmers-make

  2. eclipse中导入一个android工程有The import android cannot be resolved错误怎么办

    解决方法: 右键工程→Bulid Path→Configure Build Path... 选择Android,如图,在Project Build Target里面勾选相应的SDK即可 右键工程,pr ...

  3. 如何调用super

    因此,决定是否调用 super,基于您打算如何重新实施方法: 如果打算补充超类实现的行为,请调用 super. 如果打算替换超类实现的行为,就不要调用 super. 如果您要补充超类行为,另一个需要重 ...

  4. 数位dp-POJ-3252-Round Numbers

    最近一直在看书和博客,即使做出几道题来也是看别人题解写的,感觉没自己的东西,所以很久没更新博客 看了很多数位dp的题和题解,发现数位dp题是有固定的模版的,并且终于自己做出来一道. 我觉得用记忆化搜索 ...

  5. 【转】Polymer API开发指南 (二)(翻译)

    原文转自:http://segmentfault.com/blog/windwhinny/1190000000596258 公开 property 当你公开一个 Polymer 元素的 propert ...

  6. CI 框架隐藏index.php-ubuntu

    和朋友在做一个小网站,用到了CI框架,之前测试都是在windows上,隐藏index.php也相对比较简单.但服务器是ubuntu系统,需要配置一下,根据网上看到的一些教程,结合自己电脑的特点,记录步 ...

  7. iOS学习笔记---C语言第四天

    //⽣生成2个数组,每个数组都有10个元素,元素取值范围20-40之间,数组对应元素相 加,放到另外⼀一个数组中 #import <Foundation/Foundation.h> int ...

  8. 完全搞懂傅里叶变换和小波(1)——总纲<转载>

    无论是学习信号处理,还是做图像.音视频处理方面的研究,你永远避不开的一个内容,就是傅里叶变换和小波.但是这两个东西其实并不容易弄懂,或者说其实是非常抽象和晦涩的! 完全搞懂傅里叶变换和小波,你至少需要 ...

  9. WebRTC录音(1)-实现通话双向录音

    最近公司的iPad项目中一个功能点涉及到了VOIP通讯中的录音,需要在已有的WebRTC引擎中增加录音功能,录制通话双方的声音参考了往上一位兄弟的博文(链接在此 http://blog.csdn.ne ...

  10. C++ Primer : 第二章:变量和基本类型(1)

    变量和基本类型之第一篇:基本内置类型和变量 一. (1) C++定义了一套包括算数类型和空类型,这些类型有:布尔类型bool,字符类型char,宽字符类型wchar_t,Unicode字符char16 ...