3
$ mongo
MongoDB shell version: 2.4.5
connecting to: test
Mon Jul 29 19:44:07.569 JavaScript execution failed: Error: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:L112
exception: connect failed

以上确实应该连接到mongo。我已经尝试过“brew update”和“brew upgrade mongodb”。

Brew upgrade mongodb 

Error: mongodb-2.4.5 already installed

编辑:- 运行 mongod & 给出以下错误。

$ mongod &
[1] 858
$ about to fork child process, waiting until server is ready for connections.
forked process: 860
all output going to: /usr/local/var/log/mongodb/mongo.log
ERROR: child process failed, exited with error number 100

编辑- 2:- 以下是 mongo.log 报告。

***** SERVER RESTARTED *****


Mon Jul 29 19:57:12.582 [initandlisten] MongoDB starting : pid=874 port=27017 dbpath=/usr/local/var/mongodb 64-bit host=121.245.123.3.cdma-delhi.vsnl.net.in
Mon Jul 29 19:57:12.582 [initandlisten] 
Mon Jul 29 19:57:12.582 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
Mon Jul 29 19:57:12.582 [initandlisten] db version v2.4.5
Mon Jul 29 19:57:12.582 [initandlisten] git version: a2ddc68ba7c9cee17bfe69ed840383ec3506602b
Mon Jul 29 19:57:12.582 [initandlisten] build info: Darwin bs-osx-106-x86-64-2.10gen.cc 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun  7 16:32:41 PDT 2011; root:xnu-1504.15.3~1/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49
Mon Jul 29 19:57:12.582 [initandlisten] allocator: system
Mon Jul 29 19:57:12.582 [initandlisten] options: { bind_ip: "127.0.0.1", config: "/usr/local/etc/mongod.conf", dbpath: "/usr/local/var/mongodb", fork: "true", journal: "true", logappend: "true", logpath: "/usr/local/var/log/mongodb/mongo.log", port: 27017, quiet: "true" }
Mon Jul 29 19:57:12.584 [initandlisten] journal dir=/usr/local/var/mongodb/journal
Mon Jul 29 19:57:12.584 [initandlisten] recover begin
Mon Jul 29 19:57:12.586 [initandlisten] In File::open(), ::open for '/usr/local/var/mongodb/journal/lsn' failed with errno:13 Permission denied
Mon Jul 29 19:57:12.586 [initandlisten]   Assertion failure f.is_open() src/mongo/db/dur_journal.cpp 567
0x100447d8b 0x100421aec 0x10017506a 0x10017892a 0x100179961 0x100179aae 0x10016d148    0x100003657 0x100004c90 0x10000b6e1 0x1000010b4 
0   mongod                              0x0000000100447d8b _ZN5mongo15printStackTraceERSo + 43
1   mongod                              0x0000000100421aec _ZN5mongo12verifyFailedEPKcS1_j + 284
2   mongod                              0x000000010017506a _ZN5mongo3dur14journalReadLSNEv + 218
3   mongod                              0x000000010017892a _ZN5mongo3dur11RecoveryJob2goERSt6vectorIN5boost11filesystem34pathESaIS5_EE + 98
4   mongod                              0x0000000100179961 _ZN5mongo3dur8_recoverEv + 3089
5   mongod                              0x0000000100179aae _ZN5mongo3dur7recoverEv + 30
6   mongod                              0x000000010016d148 _ZN5mongo3dur7startupEv + 72
7   mongod                              0x0000000100003657 _ZN5mongo14_initAndListenEi + 1351
8   mongod                              0x0000000100004c90 _ZN5mongo13initAndListenEi + 16
9   mongod                              0x000000010000b6e1 main + 801
10  mongod                              0x00000001000010b4 start + 52
Mon Jul 29 19:57:12.592 [initandlisten] dbexception during recovery: 13611 can't read lsn file in journal directory : assertion src/mongo/db/dur_journal.cpp:567
Mon Jul 29 19:57:12.592 [initandlisten] exception in initAndListen: 13611 can't read lsn file in journal directory : assertion src/mongo/db/dur_journal.cpp:567, terminating
Mon Jul 29 19:57:12.592 dbexit: 
Mon Jul 29 19:57:12.592 [initandlisten] shutdown: going to close listening sockets...
Mon Jul 29 19:57:12.592 [initandlisten] shutdown: going to flush diaglog...
Mon Jul 29 19:57:12.592 [initandlisten] shutdown: going to close sockets...
Mon Jul 29 19:57:12.593 [initandlisten] shutdown: waiting for fs preallocator...
Mon Jul 29 19:57:12.593 [initandlisten] shutdown: lock for final commit...
Mon Jul 29 19:57:12.593 [initandlisten] shutdown: final commit...
Mon Jul 29 19:57:12.593 [initandlisten] shutdown: closing all files...
Mon Jul 29 19:57:12.593 [initandlisten] closeAllFiles() finished
Mon Jul 29 19:57:12.593 [initandlisten] shutdown: removing fs lock...
Mon Jul 29 19:57:12.593 dbexit: really exiting now
4

2 回答 2

1

正确答案应该是这样的

这是我尝试mongodb从 Ubunut 上的命令行启动时的情况。它显示以下错误,如上和

error couldn't remove journal file during shutdown assertion 
src/mongo/db/dur_journal.cpp:235

然后我该如何解决它是

  1. 我使用 ` tail -f /var/log/mongodb/mongodb.log 跟踪日志文件
  2. mongod以like--dbpath开头 mongod --dbpath home/test/data/mymogodb/
  3. 打开一个新的终端窗口并使用mongos连接如下类型 mongospress Enter

干杯! 您的mongodb现在已连接并且可以运行您的所有命令!

于 2014-04-11T12:46:43.603 回答
0

您必须先启动 mongod 实例,然后才能连接到它。

在你的终端输入“mongod &”来启动数据库。然后您可以使用 mongo shell 连接到它。

于 2013-07-29T14:05:23.530 回答