Mongod运行,但Mongo返回错误

时间:2012-11-16 15:58:43

标签: mongodb

此问题之前已被提出,但从未得到回答。此外,我的错误日志略有不同:

当我运行'mongo'时,我收到此错误:

MongoDB shell version: 2.2.0
connecting to: test
Fri Nov 16 10:52:05 Error: couldn't connect to server 127.0.0.1:27017 src/mongo/shell/mongo.js:91
exception: connect failed

以下是我的错误日志:

Fri Nov 16 10:47:44 [initandlisten] MongoDB starting : pid=46508 port=27017     dbpath=/usr/local/var/mongodb 64-bit host=Brians-MacBook-Pro-2.local
Fri Nov 16 10:47:44 [initandlisten] 
Fri Nov 16 10:47:44 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
Fri Nov 16 10:47:44 [initandlisten] db version v2.2.0, pdfile version 4.5
Fri Nov 16 10:47:44 [initandlisten] git version: f5e83eae9cfbec7fb7a071321928f00d1b0c5207
Fri Nov 16 10:47:44 [initandlisten] build info: Darwin bs-osx-106-x86-64-1.local 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun  7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386 BOOST_LIB_VERSION=1_49
Fri Nov 16 10:47:44 [initandlisten] options: { bind_ip: "127.0.0.1", config: "/usr/local/etc/mongod.conf", dbpath: "/usr/local/var/mongodb", logappend: "true", logpath: "/usr/local/var/log/mongodb/mongo.log" }
Fri Nov 16 10:47:44 [initandlisten] journal dir=/usr/local/var/mongodb/journal
Fri Nov 16 10:47:44 [initandlisten] recover begin
Fri Nov 16 10:47:44 [initandlisten] couldn't open /usr/local/var/mongodb/journal/lsn errno:13 Permission denied
Fri Nov 16 10:47:44 [initandlisten]   Assertion failure f.is_open() src/mongo/db/dur_journal.cpp 552
0x10037637b 0x1000b0196 0x100105ec2 0x10049de46 0x10049e445 0x10049e628 0x1002401ac     0x1000057ec 0x10000608d 0x10000d534 0x10000f309 0x100000ea4 0x3 
 0   mongod                              0x000000010037637b _ZN5mongo15printStackTraceERSo + 43
 1   mongod                              0x00000001000b0196 _ZN5mongo12verifyFailedEPKcS1_j + 310
 2   mongod                              0x0000000100105ec2 _ZN5mongo3dur14journalReadLSNEv + 898
 3   mongod                              0x000000010049de46 _ZN5mongo3dur11RecoveryJob2goERSt6vectorIN5boost11filesystem210basic_pathISsNS4_11path_traitsEEESaIS7_EE + 86
 4   mongod                              0x000000010049e445 _ZN5mongo3dur8_recoverEv + 405
 5   mongod                              0x000000010049e628 _ZN5mongo3dur7recoverEv + 40
 6   mongod                              0x00000001002401ac _ZN5mongo3dur7startupEv + 124
 7   mongod                              0x00000001000057ec _ZN5mongo14_initAndListenEi + 1052
 8   mongod                              0x000000010000608d _ZN5mongo13initAndListenEi + 29
 9   mongod                              0x000000010000d534 _ZL11mongoDbMainiPPc + 29348
 10  mongod                              0x000000010000f309 main + 9
 11  mongod                              0x0000000100000ea4 start + 52
 12  ???                                 0x0000000000000003 0x0 + 3
Fri Nov 16 10:47:44 [initandlisten] dbexception during recovery: 13611 can't read lsn file in journal directory : assertion src/mongo/db/dur_journal.cpp:552
Fri Nov 16 10:47:44 [initandlisten] exception in initAndListen: 13611 can't read lsn file in journal directory : assertion src/mongo/db/dur_journal.cpp:552, terminating
Fri Nov 16 10:47:44 dbexit: 
Fri Nov 16 10:47:44 [initandlisten] shutdown: going to close listening sockets...
Fri Nov 16 10:47:44 [initandlisten] shutdown: going to flush diaglog...
Fri Nov 16 10:47:44 [initandlisten] shutdown: going to close sockets...
Fri Nov 16 10:47:44 [initandlisten] shutdown: waiting for fs preallocator...
Fri Nov 16 10:47:44 [initandlisten] shutdown: lock for final commit...
Fri Nov 16 10:47:44 [initandlisten] shutdown: final commit...
Fri Nov 16 10:47:44 [initandlisten] shutdown: closing all files...
Fri Nov 16 10:47:44 [initandlisten] closeAllFiles() finished
Fri Nov 16 10:47:44 [initandlisten] shutdown: removing fs lock...
Fri Nov 16 10:47:44 dbexit: really exiting now

我跑步时没有输出:

netstat -f inet -a -n | grep 27101

感谢您的帮助!

4 个答案:

答案 0 :(得分:3)

正如@Nilam所说,你的一个问题是期刊,但是,你实际上在这里遇到两个问题,我所说的那个问题更多的是警告:

Fri Nov 16 10:47:44 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000

具体涉及:https://jira.mongodb.org/browse/SERVER-4407

你应该考虑在Linux中增加你的openfile数量,否则你可以得到这个:http://www.mongodb.org/display/DOCS/Too+Many+Open+Files当然这个页面也会告诉你如何解决这个问题。

注意:作为日志点的旁注,看起来你的MongoDB节点可能正试图从某些东西中恢复。我会检查原因。

答案 1 :(得分:2)

与@ Hartator的答案类似,这解决了我的问题:

chmod -R 777 /data/db

答案 2 :(得分:0)

你有

journal dir=/usr/local/var/mongodb/journal

错误显示为

[initandlisten] couldn't open /usr/local/var/mongodb/journal/lsn errno:13 Permission denied

因此,请检查日志目录是否存在,并为此文件夹指定了正确的写入权限。

答案 3 :(得分:-2)

尝试运行:

chmod 777 -R /usr/local/var/mongodb