如何修复 docker-compose MariaDB 实例 (aria_chk -r)
问题:
你正在尝试使用 docker-compose 运行 MariaDB 容器。但是,数据库容器没有启动,你在日志中看到类似这样的错误消息:
mariadb-aria-errors.txt
[ERROR] mysqld: Aria recovery failed. Please run aria_chk -r on all Aria tables and delete all aria_log.######## files
[ERROR] Plugin 'Aria' init function returned error.
[ERROR] Plugin 'Aria' registration as a STORAGE ENGINE failed.
....
[ERROR] Could not open mysql.plugin table. Some plugins may be not loaded
[ERROR] Failed to initialize plugins.
[ERROR] Aborting解决方案
日志消息已经告诉你该做什么 - 但它们没有告诉你如何做:
aria-recovery-instructions.txt
Aria recovery failed. Please run aria_chk -r on all Aria tables and delete all aria_log.######## files首先,**备份整个 MariaDB 数据目录:**检查容器的数据目录(/var/lib/mysql)映射到哪个主机目录,并将整个目录复制到备份空间。这在修复过程失败时很重要。
现在让我们运行 aria_chk -r 来检查和修复 MySQL 表文件。
docker-aria-repair.sh
docker-compose run my-db bash -c 'aria_chk -r /var/lib/mysql/**/*'将 my-db 替换为你的数据库容器名称。这将尝试修复许多非表文件,但 aria_chk 会愉快地忽略这些。
现在我们可以删除日志文件:
docker-remove-aria-logs.sh
docker-compose run my-db bash -c 'rm /var/lib/mysql/aria_log.*'同样,将 my-db 替换为你的数据库容器名称。
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow