【发布时间】:2018-08-08 15:25:27
【问题描述】:
环境
我们在运行 MariaDB(版本 10.3.8)的 CentOS 服务器上有一个登台/测试 WordPress 站点。我们一直在试验一个名为 GeoDirectory (https://wpgeodirectory.com/) 的插件,该插件在数据库中创建各种表。数据库还使用设置为 ON 的innodb_file_per_table,因此数据库已为数据库中的每个表空间生成 IBD 文件。
问题
登台服务器有 80 GB 的存储空间。在对插件的设置进行了特定更改(更新 Place Settings)后,我们注意到大约十分钟后,当我们尝试通过浏览器访问临时站点时,它会超时。
通过 SSH 登录,我们注意到机器完全没有空间。在 /var 中寻找最大的文件时,我注意到 一个 文件现在占用了 70 GB 的空间 (wp_g1a4rar7xx_geodir_gd_place_detail.ibd)。这是与更新设置的表对应的 IBD 文件。
登录 SQL 并对该表中的记录数运行 count(*),结果只有 6,000 条记录。
由于表已炸毁以占用整个磁盘,因此由于空间不足,即使尝试OPTIMIZE TABLE 也无法正常工作。
问题
会发生什么让文件气球如此迅速地变大?以后如何避免这种情况发生?
鲁莽的猜测
根据搜索,我们认为这可能与 InnoDB 执行的回滚/日志记录有关,我们可以通过在 my.cnf 中进行一些更改以限制日志记录来避免这种情况。同样,它可能是完全不同的东西。
这是来自/etc/my.cnf 的当前my.cnf:
[mysqld]
bind-address = 0.0.0.0
# bind-address = ::ffff:127.0.0.1
local-infile=0
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security
risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
提前感谢您的帮助!
【问题讨论】:
-
如果每行存储 12MB 数据,则 6000 行可能需要 70GB。运行
SHOW TABLE STATUS LIKE 'wp_g1a4rar7xx_geodir_gd_place_detail'\G并检查 Data_length、Index_length 和 Avg_row_length。此外,Data_free 可能表示表空间中存在碎片。 -
SHOW TABLE STATUS 语句是您在 mysql 客户端中运行的内容(您有
mysql>提示符)。我不应该假设你对那句话很熟悉。 -
OPTIMIZE TABLE应该可以工作如果在可用磁盘空间中有足够的空间用于表的新副本。 (是的,这似乎不太可能。)SHOW应该说明这是否可能。
标签: mysql wordpress mariadb innodb