在我的应用程序中,我正在对Mongodb集合执行以下查询。它会将collection
的所有记录移至his_collection
`for record in collection.find():
his_collection.insert(record)
collection.remove()`
在collection
表中使用 3k 行,它可以正常工作,即所有行都移动到his_collection。
但是当我在collection
中使用 10k 行执行上述命令时。它被绞死了
现在,当我尝试将Mongodb与命令mongo
连接到shell时,它会抛出错误
MongoDB shell version: 2.4.5
connecting to: test
Fri Aug 23 12:41:28.762 JavaScript execution failed: Error: couldn't connect to
server 127.0.0.1:27017 at src/mongo/shell/mongo.js:L112
exception: connect failed
我尝试在shell中执行以下命令来解决此问题
service mongodb stop
rm /mnt-data/data/mongodb/mongod.lock
mongod –repair --dbpath=/mnt-data/data/mongodb/
service mongodb start
请建议我有什么建议吗?
LOG for mongod -repair
Fri Aug 23 12:56:36.617 [initandlisten] MongoDB starting : pid=16997 port=27017
dbpath=/mnt-data/data/mongodb/ 64-bit host=
Fri Aug 23 12:56:36.618 [initandlisten] db version v2.4.5
Fri Aug 23 12:56:36.618 [initandlisten] git version:
Fri Aug 23 12:56:36.618 [initandlisten] build info: Linux
Fri Aug 23 12:56:36.618 [initandlisten] allocator: tcmalloc
Fri Aug 23 12:56:36.618 [initandlisten] options: { dbpath: "/mnt-data/data/mongo
db/", repair: true }
Fri Aug 23 12:56:36.625 [initandlisten] ****
Fri Aug 23 12:56:36.625 [initandlisten] ****
Fri Aug 23 12:56:36.625 [initandlisten] need to upgrade database jf_db with pdfi
le version 4.5, new version: 4.5
Fri Aug 23 12:56:36.625 [initandlisten] starting upgrade
Fri Aug 23 12:56:36.625 [initandlisten] jf_db repairDatabase jf_db
Fri Aug 23 12:56:36.626 [initandlisten] jf_db Cannot repair database jf_db havi
ng size: 12829327360 (bytes) because free disk space is: 3514216448 (bytes)
Fri Aug 23 12:56:36.626 [initandlisten] jf_db Assertion failure doDBUpgrade( db
Name , errmsg , h ) src/mongo/db/db.cpp 353
0xdd9e31 0xd9b04d 0x6d3116 0x6d6e88 0x6d74cd 0x6ddfb0 0x6dfc09 0x7f8ee2ba976d 0x
6cf979
mongod(_ZN5mongo15printStackTraceERSo+0x21) [0xdd9e31]
mongod(_ZN5mongo12verifyFailedEPKcS1_j+0xfd) [0xd9b04d]
mongod() [0x6d3116]
mongod(_ZN5mongo14_initAndListenEi+0x5d8) [0x6d6e88]
mongod(_ZN5mongo13initAndListenEi+0x1d) [0x6d74cd]
mongod() [0x6ddfb0]
mongod(main+0x9) [0x6dfc09]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed) [0x7f8ee2ba976d]
mongod(__gxx_personality_v0+0x499) [0x6cf979]
Fri Aug 23 12:56:36.629 [initandlisten] exception in initAndListen: 0 assertion
src/mongo/db/db.cpp:353, terminating
Fri Aug 23 12:56:36.629 dbexit:
Fri Aug 23 12:56:36.629 [initandlisten] shutdown: going to close listening socke
ts...
Fri Aug 23 12:56:36.629 [initandlisten] shutdown: going to flush diaglog...
Fri Aug 23 12:56:36.629 [initandlisten] shutdown: going to close sockets...
Fri Aug 23 12:56:36.629 [initandlisten] shutdown: waiting for fs preallocator...
Fri Aug 23 12:56:36.629 [initandlisten] shutdown: closing all files...
Fri Aug 23 12:56:36.631 [initandlisten] closeAllFiles() finished
Fri Aug 23 12:56:36.631 [initandlisten] shutdown: removing fs lock...
Fri Aug 23 12:56:36.631 dbexit: really exiting now
答案 0 :(得分:0)
您需要添加更多磁盘空间。我已经看到修复从2x datasize运行到50x datasize - 取决于数据损坏的严重程度。