MySQL 报错及解决方案
在使用 MySQL 过程中,遇到了以下报错:
2024-09-02T14:54:39.825067Z 0 [ERROR] InnoDB: Write to file ./ibtmp1 failed at offset 0, 1048576 bytes should have been
written, only 0 were written. Operating system error number 28. Check that your OS and file system support files of this
size. Check also that the disk is not full or a disk quota exceeded.
2024-09-02T14:54:39.825085Z 0 [ERROR] InnoDB: Error number 28 means 'No space left on device'
2024-09-02T14:54:39.825089Z 0 [Note] InnoDB: Some operating system error numbers are described at http://dev.mysql.com
/doc/refman/5.7/en/operating-system-error-codes.html
2024-09-02T14:54:39.825093Z 0 [ERROR] InnoDB: Could not set the file size of './ibtmp1'. Probably out of disk space
2024-09-02T14:54:39.825096Z 0 [ERROR] InnoDB: Unable to create the shared innodb_temporary
2024-09-02T14:54:39.825103Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2024-09-02T14:54:40.227301Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2024-09-02T14:54:40.227319Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2024-09-02T14:54:40.227325Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2024-09-02T14:54:40.227331Z 0 [ERROR] Failed to initialize builtin plugins.
2024-09-02T14:54:40.227334Z 0 [ERROR] Aborting
问题原因
报错信息显示 No space left on device,即磁盘空间不足。
解决步骤
1. 检查磁盘占用情况
使用 du -sh * 命令查看磁盘占用情况:
du -sh *
2. 定位占用大量空间的文件
发现 /var/lib/docker/overlay2/b10a9fb4ba3d950874b4bdecaa278fb8fb3524b14b532c78cd75f6c 文件占用了 49GB
3. 检查 Docker 容器
查看 Docker 容器,发现该容器是用于 TTS(文本转语音)任务,其中的日志文件占用了大量空间
4. 删除日志文件
使用rm -f ,删除容器中的日志文件
5. 重启服务器和 MySQL 服务
重启服务器
shutdown -r
总结
通过上述步骤,成功解决了磁盘空间不足的问题,并恢复了 MySQL 的正常运行。