简体   繁体   English

从损坏的 MongoDB 安装中恢复 WiredTiger 集合时出错

[英]Error while Recovering a WiredTiger collection from a corrupt MongoDB installation

We have implemented MongoDB master-slave replication and database got deleted.我们实现了 MongoDB 主从复制,数据库被删除了。

We restored deleted files from Mongo data directory using extundelete command.我们使用extundelete命令从 Mongo 数据目录中恢复了已删除的文件。

Undelete Blog https://github.com/RIKSOF/development/wiki/Restoring-deleted-files-on-Linux 取消删除博客https://github.com/RIKSOF/development/wiki/Restoring-deleted-files-on-Linux

We wanted to restore at least one collection for which we got the WT (wired timer) file.我们想要恢复至少一个我们获得了 WT(有线计时器)文件的收藏。 We are trying to restore that file using the following commands and we are getting the following errors我们正在尝试使用以下命令恢复该文件,但出现以下错误

Recovering a WiredTiger collection from a corrupt MongoDB installation 从损坏的 MongoDB 安装中恢复 WiredTiger 集合

wget http://source.wiredtiger.com/releases/wiredtiger-2.7.0.tar.bz2 tar xvf wiredtiger-2.7.0.tar.bz2 cd wiredtiger-2.7.0 sudo apt-get install libsnappy-dev build-essential./configure --enable-snappy make

./wt -v -h../mongo-bak -C "extensions=[./ext/compressors/snappy/.libs/libwiredtiger_snappy.so]" -R salvage collection-2657--1723320556100349955.wt

Error -错误 -

./wt -v -h../mongo-bak -C "extensions=[./ext/compressors/snappy/.libs/libwiredtiger_snappy.so]" -R salvage collection-246--7553069514495955510.wt [1488888117:36780][13536:0x7f7b633cd740], file:WiredTiger.wt, connection: read checksum error for 4096B block at offset 12288: block header checksum of 1955562709 doesn't match expected checksum of 3146787951 [1488888117:36809][13536:0x7f7b633cd740], file:WiredTiger.wt, connection: WiredTiger.wt: encountered an illegal file format or internal value [1488888117:36817][13536:0x7f7b633cd740], file:WiredTiger.wt, connection: the process must exit and restart: WT_PANIC: WiredTiger library panic lt-wt: WT_PANIC: WiredTiger library panic

This could be related to corrupted .wt files (eg WiredTiger.wt / WiredTiger.turtle ) as per SERVER-31076 bug report.根据SERVER-31076错误报告,这可能与损坏的.wt文件(例如WiredTiger.wt / WiredTiger.turtle )有关。

Try to run repair on all databases by the following command:尝试通过以下命令在所有数据库上运行修复:

mongod --repair --dbpath /path/to/data/db

Also make sure all data/db files have the right read and write permission.还要确保所有data/db文件都具有正确的读写权限。

In my case, I had recovered mac from Time Machine.就我而言,我已经从 Time Machine 恢复了 mac。 I had mongodb installed via brew install.我通过 brew install 安装了 mongodb。 When I started mongo, the service did not start cleanly.当我启动 mongo 时,该服务没有正常启动。

vi /usr/local/var/log/mongodb/mongo.log
enter code here
2020-01-30T17:06:10.655-0500 E  STORAGE  [initandlisten] WiredTiger error (0) [1580421970:655376][62181:0x112233dc0], file:WiredTiger.wt, connection: __wt_block_read_off, 283: WiredTiger.wt: read checksum error for 4096B block at offset 12288: block header checksum of 0x325e318 doesn't match expected checksum of 0x65ef0e12 Raw: [1580421970:655376][62181:0x112233dc0], file:WiredTiger.wt, connection: __wt_block_read_off, 283: WiredTiger.wt: read checksum error for 4096B block at offset 12288: block header checksum of 0x325e318 doesn't match expected checksum of 0x65ef0e12

What I saw was that because of a corrupt mongodb collection.我看到的是因为一个损坏的 mongodb 集合。 So, I ran the cleanup command for the brew install, which has the db in a different location.因此,我为 brew install 运行了清理命令,它的数据库位于不同的位置。

mongod --repair --dbpath /usr/local/var/mongodb

    2020-01-30T17:06:11.741-0500 I  STORAGE  [initandlisten] Verify failed on uri table:collection-12--8361386101775862971. Running a salvage operation.
2020-01-30T17:06:11.745-0500 I  STORAGE  [initandlisten] Repairing collection wlchat.jobs
2020-01-30T17:06:11.765-0500 I  STORAGE  [initandlisten] WiredTiger progress WT_SESSION.verify 100
2020-01-30T17:06:11.769-0500 I  STORAGE  [initandlisten] WiredTiger progress WT_SESSION.verify 200
2020-01-30T17:06:11.774-0500 I  STORAGE  [initandlisten] WiredTiger progress WT_SESSION.verify 300
2020-01-30T17:06:11.783-0500 I  STORAGE  [initandlisten] WiredTiger progress WT_SESSION.verify 400
2020-01-30T17:06:11.789-0500 I  STORAGE  [initandlisten] WiredTiger progress WT_SESSION.verify 500
2020-01-30T17:06:11.793-0500 I  STORAGE  [initandlisten] WiredTiger progress WT_SESSION.verify 600
2020-01-30T17:06:11.795-0500 I  STORAGE  [initandlisten] Verify succeeded on uri table:collection-10--8361386101775862971. Not salvaging.
2020-01-30T17:06:11.795-0500 I  STORAGE  [initandlisten] Repairing collection wlchat.SovrenJobs
2020-01-30T17:06:11.801-0500 I  STORAGE  [initandlisten] Verify succeeded on uri table:collection-0-8794251073515214768. Not salvaging.
2020-01-30T17:06:11.814-0500 I  INDEX    [initandlisten] index build: starting on wlchat.users properties: { v: 2, key: { _id: 1 }, name: "_id_", ns: "wlchat.users" } using method: Foreground

and restart mongodb-community并重启mongodb-community

brew services restart mongodb-community.
==> Successfully started `mongodb-community` (label: homebrew.mxcl.mongodb-community)

Things are back to normal.事情恢复正常。

I got this error and trying a lot of way to resolve but not reached to successfully.我收到此错误并尝试了很多方法来解决但没有成功。

I am currently using 5.0.1 mongodb standalone version,我目前使用的是5.0.1 mongodb独立版,

  • removed currently installed mongodb ( 5.0.1 )删除了当前安装的 mongodb ( 5.0.1 )
  • installed latest version ( 6.0 )安装最新版本( 6.0 )

and reapaired all corrupted *.wt file and verified.并修复所有损坏的 *.wt 文件并进行验证。

mongod --repair --dbpath /path/to/data/db

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM