报错日志:

2024-04-06T20:24:58.527+0800 I CONTROL  [initandlisten]     target_arch: x86_64
2024-04-06T20:24:58.527+0800 I CONTROL  [initandlisten] options: { config: "/home/yituadmin/face_platform/config/mongodb//mongodb.yaml", net: { port: 27017, unixDomainSocket: { enabled: false, pathPrefix: "/home/yituadmin/face_platform/data/mongodb" } }, processManagement: { fork: false }, storage: { dbPath: "/home/yituadmin/face_platform/data/mongodb", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, logRotate: "rename", path: "/home/yituadmin/face_platform/log/mongodb/mongodb.log", quiet: true } }
2024-04-06T20:24:58.569+0800 I -        [initandlisten] Detected data files in /home/yituadmin/face_platform/data/mongodb created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2024-04-06T20:24:58.601+0800 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=451G,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2024-04-06T20:29:18.489+0800 E STORAGE  [initandlisten] WiredTiger (0) [1712406558:489031][58524:0x7f03ce61ecc0], file:index-29--4566408493949288742.wt, WT_CURSOR.insert: read checksum error for 12288B block at offset 1800122368: block header checksum of 3963073239 doesn't match expected checksum of 490489187
2024-04-06T20:29:18.489+0800 E STORAGE  [initandlisten] WiredTiger (0) [1712406558:489169][58524:0x7f03ce61ecc0], file:index-29--4566408493949288742.wt, WT_CURSOR.insert: index-29--4566408493949288742.wt: encountered an illegal file format or internal value
2024-04-06T20:29:18.489+0800 E STORAGE  [initandlisten] WiredTiger (-31804) [1712406558:489185][58524:0x7f03ce61ecc0], file:index-29--4566408493949288742.wt, WT_CURSOR.insert: the process must exit and restart: WT_PANIC: WiredTiger library panic
2024-04-06T20:29:18.489+0800 I -        [initandlisten] Fatal Assertion 28558
2024-04-06T20:29:18.489+0800 I -        [initandlisten] 

***aborting after fassert() failure


2024-04-06T20:29:18.511+0800 F -        [initandlisten] Got signal: 6 (Aborted)

2024-04-06T20:29:18.489+0800 E STORAGE  [initandlisten] WiredTiger (0) [1712406558:489031][58524:0x7f03ce61ecc0], file:index-29--4566408493949288742.wt, WT_CURSOR.insert: read checksum error for 12288B block at offset 1800122368: block header checksum of 3963073239 doesn't match expected checksum of 490489187

这个错误表示在索引文件index-29--4566408493949288742.wt中,WiredTiger检测到了数据块的校验和错误。校验和是对数据块内容计算的一种数字指纹,用于确保数据的完整性和一致性。当实际读取到的校验和与预期不符时,表明数据可能已经损坏。

此问题通常是由硬件故障(如磁盘错误)或者在数据写入过程中发生意外中断导致的。MongoDB因此无法正常启动并触发了崩溃恢复流程。

建议采取以下措施来解决问题:

  1. 检查硬件:确认服务器的硬盘是否有故障或存在其他硬件问题。运行磁盘自检工具(如fsck),查看是否存在坏道或其他错误。
  2. 备份数据:在尝试任何修复操作前,首先备份现有的数据文件以防进一步损坏。
  3. 启用日志压缩:如果未启用,考虑开启WiredTiger的日志压缩功能,这可以在一定程度上防止由于断电等原因导致的数据不一致。
  4. 尝试修复:MongoDB本身不具备自动修复损坏数据的功能,但可以尝试删除出问题的索引文件(在本例中是index-29--4566408493949288742.wt),然后重启MongoDB服务,让WiredTiger重新构建该索引。
  5. 联系支持:如果上述步骤不能解决问题,请联系MongoDB技术支持或寻求专业的数据库管理员帮助,他们可能会基于具体情况提供更详尽的恢复策略,比如从备份恢复数据,或者采用更为高级的数据恢复工具和方法。

鉴于日志最后显示MongoDB自动重启并尝试再次打开数据库,但仍有相同的错误提示,表明问题仍未解决,需要按照上述建议继续排查和处理。