问题现象
启动 OAT 容器失败,进一步检查容器日志后发现,问题根源在于 MariaDB 进程启动失败。
通过查看 MariaDB 的运行日志,定位是 MariaDB 日志损坏,启动进程时 InnoDB 遇到日志扫描和文件级别的损坏方面报错。
2024-03-19 11:44:14 0 [Note] InnoDB: Dump from the start of the mini-transaction (LSN=32645050650) to 100 bytes after the record:
len 103; hex 87750000208709263500808f31bf3900a007889007a4c9c1004700863328043097b40d012fddb4ae5c2fddb6804707a4c9bab409013097c3000c00b3002efac3000c00a022031c0080e100
0000000000e080000000000000127363616e5f646f636b65725f696d; asc u &5 1 9 G 3( 0 / \/ G 0 . " scan_docker_i
m;
2024-03-19 11:44:14 0 [Warning] InnoDB: Log scan aborted at LSN 32645065728
2024-03-19 11:44:14 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2024-03-19 11:44:14 0 [Note] InnoDB: Starting shutdown...
2024-03-19 11:44:15 0 [ERROR] Plugin 'InnoDB' init function returned error.
2024-03-19 11:44:15 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2024-03-19 11:44:15 0 [Note] Plugin 'FEEDBACK' is disabled.
2024-03-19 11:44:15 0 [ERROR] Unknown/unsupported storage engine: InnoDB
2024-03-19 11:44:15 0 [ERROR] Aborting
240319 11:44:15 mysqld_safe mysqld from pid file /data/db/mariadb.pid ended
240319 11:45:16 mysqld_safe Starting mariadbd daemon with databases from /data/db
2024-03-19 11:45:16 0 [Note] Starting MariaDB 10.6.14-MariaDB source revision c93754d45e5d9379e3e23d7ada1d5f21d2711f66 as process 144
2024-03-19 11:45:16 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2024-03-19 11:45:16 0 [Note] InnoDB: Number of pools: 1
2024-03-19 11:45:16 0 [Note] InnoDB: Using ARMv8 crc32 + pmull instructions
2024-03-19 11:45:16 0 [Note] mariadbd: O_TMPFILE is not supported on /tmp (disabling future attempts)
2024-03-19 11:45:16 0 [Warning] mariadbd: io_uring_queue_init() failed with errno 1
2024-03-19 11:45:16 0 [Warning] InnoDB: liburing disabled: falling back to innodb_use_native_aio=OFF
2024-03-19 11:45:16 0 [Note] InnoDB: Initializing buffer pool, total size = 2147483648, chunk size = 134217728
2024-03-19 11:45:16 0 [Note] InnoDB: Completed initialization of buffer pool
2024-03-19 11:45:16 0 [Note] InnoDB: Starting crash recovery from checkpoint LSN=32645050650,32645050650
2024-03-19 11:45:16 0 [ERROR] InnoDB: Corrupted file-level record; set innodb_force_recovery=1 to ignore.
2024-03-19 11:45:16 0 [Note] InnoDB: Dump from the start of the mini-transaction (LSN=32645050650) to 100 bytes after the record:
问题原因
可能因为服务器突然断电等原因导致 MariaDB 日志损坏,无法启动 MariaDB 进程。
影响租户
影响 OceanBase 数据库中的 SYS 租户和 Oracle 租户以及 MySQL 租户。
适用版本
OAT V4.x 版本。
解决方法
启动一个空的 OAT 容器。
##-- 注意要挂载当前 OAT 正在使用的数据目录。 docker run -itd --net host --name oat_blank -v xxx:/data --entrypoint bash --restart on-failure:5 ${repo}:${tag}进入空的 OAT 容器。
docker exec -it oat_blank bash编辑
/etc/my.cnf.d/server.cnf文件。增加
innodb_force_recovery=6(4 以上会以只读模式启动,应该先从1开始尝试,如果能启动,通过 mysqldump 进行逻辑备份)。[mysqld] default-time-zone='+8:00' innodb_buffer_pool_size=2G max_connections = 1024 innodb_file_per_table=on port=3306 innodb_default_row_format=dynamic datadir=/data/db # log-error=/data/db/mariadb.log socket=/data/db/mysql.sock pid-file=mariadb.pid innodb_force_recovery=6在容器中启动 MariaDB 进程。
/usr/bin/mysqld_safe --user=root &进行逻辑备份。
在容器中使用 mysqldump 导出 OAT 和 AIRFLOW 这两个数据库。
mysqldump -u [username] -p[password] --databases [database1_name] [database2_name] > [filename].sql删除数据目录。
备份
/data/db目录,并删除容器中/data/db/oat、/data/db/airflow这两个目录。进行逻辑恢复。
mysql -u username -p[password] < [filename].sql并检查 database 里面的数据是否恢复。
删除
oat_blank容器,重启之前的 OAT 容器,验证服务与数据是否正常。