polardb / polardbx-engine

polardbx-engine is a MySQL branch originated from Alibaba Group, especially supports large-scale distributed database system.
Other
482 stars 125 forks source link

binlog日志文件过期导致服务启动失败 #37

Open zsk27 opened 5 months ago

zsk27 commented 5 months ago

1、启用binlog 2、配置日志过期时间为3天:binlog_expire_logs_seconds=259200 3、启动服务,建库建表产生一些日志 4、关闭服务,等日志过期(3天)后重新启动服务 5、服务启动失败: 2024-06-14T17:29:29.562028+08:00 0 [Warning] [MY-000000] [Server] log file /opt/log/polardb/polardb-bin.000001 cannot found last log term index, term is 5. 2024-06-14T17:29:29.562632+08:00 0 [Warning] [MY-000000] [Server] last log term is 5, last log term index is 0. 2024-06-14T17:29:29.563188+08:00 0 [ERROR] [MY-000000] [Server] init_last_index_of_term for recovery failed 2024-06-14T17:29:29.564252+08:00 0 [ERROR] [MY-010119] [Server] Aborting 2024-06-14T17:29:29.577102+08:00 0 [Warning] [MY-000000] [Server] Plugin polarx_rpc reported: 'polarx_rpc exit' 2024-06-14T17:29:30.342619+08:00 0 [System] [MY-010910] [Server] /usr/local/polardb/bin/mysqld: Shutdown complete (mysqld 8.0.30) Source distribution. 2024-06-14T17:29:31.309844+08:00 0 [System] [MY-013169] [Server] /usr/local/polardb/bin/mysqld (mysqld 8.0.30) initializing of server in progress as process 7 2024-06-14T17:29:31.312159+08:00 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting. 2024-06-14T17:29:31.312205+08:00 0 [ERROR] [MY-013236] [Server] The designated data directory /opt/data/polardb/ is unusable. You can remove all files that the server added to it. 2024-06-14T17:29:31.312326+08:00 0 [ERROR] [MY-010119] [Server] Aborting 2024-06-14T17:29:31.317786+08:00 0 [System] [MY-010910] [Server] /usr/local/polardb/bin/mysqld: Shutdown complete (mysqld 8.0.30) Source distribution

请问这个问题如何修复?

sWildGold commented 5 months ago

数据目录下还有binlog吗,比如/opt/log/polardb/polardb-bin.000001?如果还有的话,请贴一下binlog内容

zsk27 commented 5 months ago

binlog日志目录下过期的日志文件已经没有了,又重新生成了两个文件: polardb-bin.000001 文件和 polardb-bin.index 文件

polardb-bin.000001 文件的内容: 无标题

polardb-bin.index 文件中只有一行: /opt/log/polardb/polardb-bin.000001

zsk27 commented 5 months ago

一次完整启动的日志: 2024-06-24T16:47:02.472370+08:00 0 [System] [MY-010116] [Server] /usr/local/polardb/bin/mysqld (mysqld 8.0.30) starting as process 1 2024-06-24T16:47:02.966306+08:00 1 [Warning] [MY-011825] [InnoDB] [GTID INFO] Reading from undo log : 2024-06-24T16:47:04.364379+08:00 0 [Warning] [MY-000000] [Server] Plugin polarx_rpc reported: 'polarx_rpc start up' 2024-06-24T16:47:04.364570+08:00 0 [ERROR] [MY-000000] [Server] Plugin polarx_rpc reported: 'PolarX RPC disabled.' 2024-06-24T16:47:04.443824+08:00 0 [Warning] [MY-000000] [Server] gtid_mode is GTID_MODE_OFF, turn off recovery_apply_binlog 2024-06-24T16:47:04.445836+08:00 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed. 2024-06-24T16:47:04.456544+08:00 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/opt/data/polardb' in the path is accessible to all OS users. Consider choosing a different directory. 2024-06-24T16:47:04.537887+08:00 0 [Warning] [MY-000000] [Server] log file /opt/log/polardb/polardb-bin.000001 cannot found last log term index, term is 4. 2024-06-24T16:47:04.538160+08:00 0 [Warning] [MY-000000] [Server] last log term is 4, last log term index is 0. 2024-06-24T16:47:04.538386+08:00 0 [ERROR] [MY-000000] [Server] init_last_index_of_term for recovery failed 2024-06-24T16:47:04.538818+08:00 0 [ERROR] [MY-010119] [Server] Aborting 2024-06-24T16:47:04.548524+08:00 0 [Warning] [MY-000000] [Server] Plugin polarx_rpc reported: 'polarx_rpc exit' 2024-06-24T16:47:05.731918+08:00 0 [System] [MY-010910] [Server] /usr/local/polardb/bin/mysqld: Shutdown complete (mysqld 8.0.30) Source distribution. 2024-06-24T16:47:07.060159+08:00 0 [System] [MY-013169] [Server] /usr/local/polardb/bin/mysqld (mysqld 8.0.30) initializing of server in progress as process 7 2024-06-24T16:47:07.062202+08:00 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting. 2024-06-24T16:47:07.062245+08:00 0 [ERROR] [MY-013236] [Server] The designated data directory /opt/data/polardb/ is unusable. You can remove all files that the server added to it. 2024-06-24T16:47:07.062347+08:00 0 [ERROR] [MY-010119] [Server] Aborting 2024-06-24T16:47:07.067723+08:00 0 [System] [MY-010910] [Server] /usr/local/polardb/bin/mysqld: Shutdown complete (mysqld 8.0.30) Source distribution.

BoyTNT commented 4 months ago

我也遇到了同样问题,一但长时间未启动服务或者服务器出现时间波动,binlog就被自动删除了,导致服务无法启动,急需解决方案

sWildGold commented 4 months ago

x-paxos强依赖binlog,设置binlog过期会导致binlog被自动删除启动不了,恢复起来比较麻烦,不是一步两步可以解决的,如果实例上有大量生产数据,可以加开源交流钉钉群32432897具体沟通 @BoyTNT @zsk27