0

以前有人问过这个问题,但从未回答过。此外,我的错误日志略有不同:

当我运行“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

4 回答 4

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 节点可能正在尝试从某些东西中恢复。我会检查为什么。

于 2012-11-16T16:16:14.447 回答
2

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

chmod -R 777 /data/db
于 2013-03-13T15:34:50.447 回答
0

你有

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

错误显示是

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

因此,请检查日志目录是否存在以及是否为该文件夹提供了适当的写入权限。

于 2012-11-16T16:03:05.117 回答
-2

尝试运行:

chmod 777 -R /usr/local/var/mongodb
于 2012-11-16T16:32:41.737 回答