我在MacBook上安装了一个MongoDB。今天,我的MacBook崩溃了,经过硬重启Mac后,mongod
无法启动:
$ mongod
mongod --help for help and startup options
2016-06-16T15:35:27.118+0800 [initandlisten] MongoDB starting : pid=44355 port=27017 dbpath=/data/db 64-bit host=L-MY-MAC.local
2016-06-16T15:35:27.118+0800 [initandlisten] db version v2.6.4
2016-06-16T15:35:27.118+0800 [initandlisten] git version: 3a830be0eb92d772aa855ebb711ac91d658ee910
2016-06-16T15:35:27.118+0800 [initandlisten] build info: Darwin bs-osx108-4 12.5.0 Darwin Kernel Version 12.5.0: Sun Sep 29 13:33:47 PDT 2013; root:xnu-2050.48.12~1/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49
2016-06-16T15:35:27.118+0800 [initandlisten] allocator: system
2016-06-16T15:35:27.118+0800 [initandlisten] options: {}
2016-06-16T15:35:27.120+0800 [initandlisten] journal dir=/data/db/journal
2016-06-16T15:35:27.120+0800 [initandlisten] recover : no journal files present, no recovery needed
2016-06-16T15:35:27.164+0800 [initandlisten] openExisting size 16384 less than minimum file size expectation /data/db/stock.4
2016-06-16T15:35:27.164+0800 [initandlisten] Assertion failure false src/mongo/db/storage/data_file.cpp 112
2016-06-16T15:35:27.169+0800 [initandlisten] 0x1006c014b 0x100677502 0x100668182 0x1004d4695 0x1004db516 0x1000ec387 0x1000ece0e 0x1000efdf0 0x100107d74 0x100107fc5 0x100003f4c 0x100005823 0x100005fb1 0x1000015d4 0x1
0 mongod 0x00000001006c014b _ZN5mongo15printStackTraceERSo + 43
1 mongod 0x0000000100677502 _ZN5mongo10logContextEPKc + 114
2 mongod 0x0000000100668182 _ZN5mongo12verifyFailedEPKcS1_j + 274
3 mongod 0x00000001004d4695 _ZN5mongo8DataFile12openExistingEPKc + 953
4 mongod 0x00000001004db516 _ZN5mongo13ExtentManager4initEv + 200
5 mongod 0x00000001000ec387 _ZN5mongo8Database12openAllFilesEv + 45
6 mongod 0x00000001000ece0e _ZN5mongo8DatabaseC2EPKcRbRKSs + 958
7 mongod 0x00000001000efdf0 _ZN5mongo14DatabaseHolder11getOrCreateERKSsS2_Rb + 834
8 mongod 0x0000000100107d74 _ZN5mongo6Client7Context11_finishInitEv + 78
9 mongod 0x0000000100107fc5 _ZN5mongo6Client7ContextC2ERKSsS3_b + 117
10 mongod 0x0000000100003f4c _ZN5mongo14_initAndListenEi + 2828
11 mongod 0x0000000100005823 _ZN5mongo13initAndListenEi + 19
12 mongod 0x0000000100005fb1 main + 977
13 mongod 0x00000001000015d4 start + 52
14 ??? 0x0000000000000001 0x0 + 1
2016-06-16T15:35:27.169+0800 [initandlisten] warning database /data/db stock could not be opened
2016-06-16T15:35:27.169+0800 [initandlisten] DBException 0: assertion src/mongo/db/storage/data_file.cpp:112
2016-06-16T15:35:27.170+0800 [initandlisten] exception in initAndListen: 0 assertion src/mongo/db/storage/data_file.cpp:112, terminating
2016-06-16T15:35:27.170+0800 [initandlisten] dbexit:
2016-06-16T15:35:27.170+0800 [initandlisten] shutdown: going to close listening sockets...
2016-06-16T15:35:27.170+0800 [initandlisten] shutdown: going to flush diaglog...
2016-06-16T15:35:27.170+0800 [initandlisten] shutdown: going to close sockets...
2016-06-16T15:35:27.170+0800 [initandlisten] shutdown: waiting for fs preallocator...
2016-06-16T15:35:27.170+0800 [initandlisten] shutdown: lock for final commit...
2016-06-16T15:35:27.170+0800 [initandlisten] shutdown: final commit...
2016-06-16T15:35:27.170+0800 [initandlisten] shutdown: closing all files...
2016-06-16T15:35:27.170+0800 [initandlisten] closeAllFiles() finished
2016-06-16T15:35:27.170+0800 [initandlisten] journalCleanup...
2016-06-16T15:35:27.174+0800 [initandlisten] removeJournalFiles
2016-06-16T15:35:27.174+0800 [initandlisten] shutdown: removing fs lock...
2016-06-16T15:35:27.174+0800 [initandlisten] dbexit: really exiting now
我确定的是,当我的Mac崩溃时,mongod
处于空闲状态,对mongo没有任何读/写操作。
如何恢复此数据库?
答案 0 :(得分:1)
如果您在数据库中有重要信息,则需要恢复该信息
尝试运行
在第一航站楼 sudo mongod --auth --dbpath / var / lib / mongodb --smallfiles
在第二个终端中获取备份
sudo mongoexport --db -c --out .json
之后,您需要删除并重新安装mongo db并还原数据库
如果您需要更多帮助,请告诉我 问候 穆罕默德·阿迪尔