强制重启 docker 后 MariaDB 因锁定文件而阻塞

强制重启 docker 后 MariaDB 因锁定文件而阻塞

我有一个用于运行 Nextcloud 的 docker compose 设置,以及 MariaDB 容器和反向代理等。最近,我不得不强制手动重启 docker 守护进程,因为某些容器在更新后卡住了,无法干净地终止。现在我的 MariaDB 无法再启动了。

[ERROR] InnoDB: Unable to lock ./ibdata1 error: 11
[Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.

这是一个明显的问题,服务在无条件终止时没有机会删除其锁定文件。当我将 ibdata 文件移动到备份位置时,我看到了一系列其他错误:

[Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.5.8+maria~focal started.
[Note] [Entrypoint]: Switching to dedicated user 'mysql'
[Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.5.8+maria~focal started.
[Note] mysqld (mysqld 10.5.8-MariaDB-1:10.5.8+maria~focal) starting as process 1 ...
[Warning] You need to use --log-bin to make --binlog-format work.
[Note] InnoDB: Using Linux native AIO
[Note] InnoDB: The first innodb_system data file 'ibdata1' did not exist. A new tablespace will be created!
[Note] InnoDB: Uses event mutexes
[Note] InnoDB: Compressed tables use zlib 1.2.11
[Note] InnoDB: Number of pools: 1
[Note] InnoDB: Using crc32 + pclmulqdq instructions
[Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
[Note] InnoDB: Initializing buffer pool, total size = 134217728, chunk size = 134217728
[Note] InnoDB: Completed initialization of buffer pool
[ERROR] InnoDB: redo log file './ib_logfile0' exists. Creating system tablespace with existing redo log file is not recommended. Please delete redo log file before creating new system tablespace.
[ERROR] InnoDB: Database creation was aborted with error Generic error. You may need to delete the ibdata1 file before trying to start up again.
[Note] InnoDB: Starting shutdown...
[Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
[ERROR] Plugin 'InnoDB' init function returned error.
[ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
[Note] Plugin 'FEEDBACK' is disabled.
[ERROR] Unknown/unsupported storage engine: InnoDB
[ERROR] Aborting

我现在完全不知所措了。我该怎么做才能启动我的容器?我遇到了一个类似的问题,MongoDB 容器在转储锁定文件后启动正常。

答案1

ibdata1不是一个锁文件,而是系统表空间,它正在获取其上的文件系统锁,以便独占使用。

由于您已删除此内容,因此您需要从备份中恢复。

无法获取此文件的锁定是一个非常可靠的指标,表明另一个 mariadb 进程已在该数据目录和系统表空间上运行。

正确的操作是识别其他实例并将其停止。即使不干净地停止 mariadb 进程/容器也会放弃锁定,因为该锁定保存在 Linux 内核中,进程终止时该锁定将被删除。

相关内容