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

时间:2017-03-07 12:12:52

标签: linux mongodb wiredtiger

我们已经实现了MongoDB主从复制,数据库被删除了。

我们使用extundelete命令从Mongo数据目录恢复了已删除的文件。

Undelete Blog https://github.com/RIKSOF/development/wiki/Restoring-deleted-files-on-Linux

我们想要恢复至少一个我们获得WT(有线计时器)文件的集合。我们正在尝试使用以下命令恢复该文件,并且我们收到以下错误

Recovering a WiredTiger collection from a corrupt MongoDB installation

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

错误 -

./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

2 个答案:

答案 0 :(得分:0)

根据SERVER-31076错误报告,这可能与损坏的.wt个文件(例如WiredTiger.wt / WiredTiger.turtle)有关。

尝试通过以下命令在所有数据库上运行修复:

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

还要确保所有data/db个文件都具有正确的读写权限。

答案 1 :(得分:0)

就我而言,我已经从Time Machine中恢复了mac。我通过brew install安装了mongodb。当我启动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

我看到的是由于损坏的mongodb集合。 因此,我为brew安装运行了cleanup命令,该命令将数据库放置在其他位置。

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

并重新启动mongodb-community

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

一切恢复正常。