我使用 mongo 2.6.4 / Windows Server 2012 R2。
Mongodump 生成了两个转储文件:
mongodump -d mydb
- 事务.bson
- transaction.metadata.json
我试图通过 mongorestore (2.6.4) 恢复这些信息:
mongorestore --host 127.0.0.1 --port 27018 --collection transaction --db mydb
但是工具返回错误(进度〜23%):
2015-08-17T19:45:51.844+0400 Failed: restore error: mydb.transaction: error restoring from F:\restore\transaction.bson: insertion error: Client Error: bad object in message: invalid bson type in object with _id: ObjectId('528dc7c03599b01214d17469')
所以我决定用标志来扩展它:
mongorestore --host 127.0.0.1 --port 27018 --collection transaction --db mydb --drop --noIndexRestore --noOptionsRestore --noobjcheck --filter "{'_id' : { $ne: '528dc7c03599b01214d17469' }}" F:/restore/transaction.bson
并再次得到同样的错误。
所以我尝试使用 3.0 版本的 mongorestore:
mongorestore /host 127.0.0.1 /port 27018 /collection transaction /db mydb /drop /noIndexRestore /noOptionsRestore /keepIndexVersion F:/restore/transaction.bson
并再次得到同样的错误。
我希望它有所帮助,因为我没有使用 /stopOnError 标志。但事实并非如此。它一直以约 23% 的速度失败。
这是 MongoDB 日志的一部分:
2015-08-17T19:14:32.447+0400 [conn8] Assertion: 10307:Client Error: bad object in message: invalid bson type in object with _id: ObjectId('528dc7c03599b01214d17469')
2015-08-17T19:14:32.532+0400 [conn6] insert mydb.transaction ninserted:10000 keyUpdates:0 numYields:0 locks(micros) w:181893 181ms
2015-08-17T19:14:32.743+0400 [conn9] insert mydb.transaction ninserted:10000 keyUpdates:0 numYields:0 locks(micros) w:211264 211ms
2015-08-17T19:14:32.921+0400 [conn7] insert mydb.transaction ninserted:10000 keyUpdates:0 numYields:0 locks(micros) w:176525 177ms
2015-08-17T19:14:36.250+0400 [conn8] mongod.exe ...\src\mongo\util\stacktrace.cpp(169) mongo::printStackTrace+0x43
2015-08-17T19:14:36.250+0400 [conn8] mongod.exe ...\src\mongo\util\log.cpp(127) mongo::logContext+0x9c
2015-08-17T19:14:36.250+0400 [conn8] mongod.exe ...\src\mongo\util\assert_util.cpp(183) mongo::msgasserted+0xfb
2015-08-17T19:14:36.250+0400 [conn8] mongod.exe ...\src\mongo\util\assert_util.cpp(174) mongo::msgasserted+0x13
2015-08-17T19:14:36.250+0400 [conn8] mongod.exe ...\src\mongo\db\dbmessage.cpp(116) mongo::DbMessage::nextJsObj+0x11f
2015-08-17T19:14:36.250+0400 [conn8] mongod.exe ...\src\mongo\db\instance.cpp(898) mongo::receivedInsert+0x18f
2015-08-17T19:14:36.250+0400 [conn8] mongod.exe ...\src\mongo\db\instance.cpp(484) mongo::assembleResponse+0x7c9
2015-08-17T19:14:36.250+0400 [conn8] mongod.exe ...\src\mongo\db\db.cpp(202) mongo::MyMessageHandler::process+0x111
2015-08-17T19:14:36.250+0400 [conn8] mongod.exe ...\src\mongo\util\net\message_server_port.cpp(210) mongo::PortMessageServer::handleIncomingMsg+0x671
2015-08-17T19:14:36.250+0400 [conn8] mongod.exe ...\src\third_party\boost\libs\thread\src\win32\thread.cpp(185) boost::'anonymous namespace'::thread_start_function+0x21
2015-08-17T19:14:36.250+0400 [conn8] mongod.exe f:\dd\vctools\crt_bld\self_64_amd64\crt\src\threadex.c(314) _callthreadstartex+0x17
2015-08-17T19:14:36.250+0400 [conn8] mongod.exe f:\dd\vctools\crt_bld\self_64_amd64\crt\src\threadex.c(292) _threadstartex+0x7f
2015-08-17T19:14:36.250+0400 [conn8] KERNEL32.DLL BaseThreadInitThunk+0xd
2015-08-17T19:14:36.250+0400 [conn8]
2015-08-17T19:14:36.255+0400 [conn8] insert mydb.transaction keyUpdates:0 exception: Client Error: bad object in message: invalid bson type in object with _id: ObjectId('528dc7c03599b01214d17469') code:10307 numYields:0 0ms
我想从这个文件中读取数据,但它很大(18 Gb)。跳过一些记录也没关系。
有谁知道如何解决这个问题?