本文主要向大家介绍了MySQL数据库之一个mysql /tmp目录爆满问题的处理 ,通过具体的内容向大家展现,希望对大家学习MySQL数据库有所帮助。
突然收到zabbix告警,说mysql服务器的/目录磁盘空间不足。
登录到服务器,看了下发现100GB的根目录,居然使用了差不多90GB。这台服务器上只跑了一个MySQL,应该不是日志未清理等其它原因造成的。
(说明:下面的几张截图是后期截的,当时已经有部分SQL跑完,释放掉部分磁盘空间了)
lsof |grep deleted 发现如下:
可以看到这个临时文件差不多有40GB。
show processlist; 如下:
上图看的话,没有涉及到写binlog的操作,但是由于单纯的select并不会造成/tmp目录爆满的情况,所以猜测他这个同一个事务里面之前还有涉及到写binlog的操作(update、delete等)。
官方的说明:
https://dev.mysql.com/doc/refman/5.6/en/binary-log.html
When a thread that handles the transaction starts, it allocates a buffer of binlog_cache_size to buffer statements. If a statement is bigger than this, the thread opens a temporary file to store the transaction. The temporary file is deleted when the thread ends.
The Binlog_cache_use status variable shows