Menu Close

MariaDB 移动数据文件后无法启动

1. 故障现象(SYMPTOMS)

MariaDB启动时报如下错误:

2022-01-14 15:45:57 0 [Warning] The parameter innodb_buffer_pool_instances is deprecated and has no effect.
2022-01-14 15:45:57 0 [Warning] The parameter innodb_log_files_in_group is deprecated and has no effect.
2022-01-14 15:45:57 0 [Note] InnoDB: Using Linux native AIO
2022-01-14 15:45:57 0 [Note] InnoDB: Uses event mutexes
2022-01-14 15:45:57 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2022-01-14 15:45:57 0 [Note] InnoDB: Number of pools: 1
2022-01-14 15:45:57 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
2022-01-14 15:45:57 0 [Note] mariadbd: O_TMPFILE is not supported on /dbdata/data/tmp (disabling future attempts)
2022-01-14 15:45:57 0 [Note] InnoDB: Initializing buffer pool, total size = 536870912, chunk size = 134217728
2022-01-14 15:45:57 0 [Note] InnoDB: Completed initialization of buffer pool
2022-01-14 15:45:57 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2022-01-14 15:45:57 0 [Note] InnoDB: 128 rollback segments are active.
2022-01-14 15:45:57 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2022-01-14 15:45:57 0 [Note] InnoDB: Setting file '/dbdata/data/mysql/data/ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2022-01-14 15:45:57 0 [Note] InnoDB: File '/dbdata/data/mysql/data/ibtmp1' size is now 12 MB.
2022-01-14 15:45:57 0 [Note] InnoDB: 10.5.8 started; log sequence number 366838; transaction id 1081
2022-01-14 15:45:57 0 [Note] InnoDB: Loading buffer pool(s) from /dbdata/data/mysql/data/ib_buffer_pool
2022-01-14 15:45:57 0 [Note] Plugin 'FEEDBACK' is disabled.
2022-01-14 15:45:57 0 [ERROR] mariadbd: File '/data/log/mysql-bin.000005' not found (Errcode: 2 "No such file or directory")
2022-01-14 15:45:57 0 [ERROR] Failed to open log (file '/data/log/mysql-bin.000005', errno 2)
2022-01-14 15:45:57 0 [ERROR] Could not open log file
2022-01-14 15:45:57 0 [ERROR] Can't init tc log
2022-01-14 15:45:57 0 [ERROR] Aborting

2. 变化(CHANGES)

3. 故障原因(CAUSE)

将原来的数据文件位置从 /data/ 移动到 /dbdata/data/目录后,并修改了 /etc/my.cnf 文件中相应的目录位置,启动 mariadb 时报了上面的错误。
虽然已经把 /etc/my.cnf 中的所有路径都修改正确了,但是mysql服务在启动时,是通过读取log-bin-index来查找log-bin日志文件的,查找的文件还是在服务器指定的位置,所以mysql服务启动失败。

4. 解决方案(SOLUTION)

手动修改 mysql-bin.index 文件中二进制日志索引文件的绝对路径,指定到当前datadir下的二进制日志,然后尝试启动mysql服务,启动成功,问题解决。

5. 总结(SUMMARY)

附录

附录A:相关联的文档

MariaDB 修改存储路径后启动失败问题解决