在Mac上的localhost上连接到MongoDB时出错

时间:2013-07-29 14:02:37

标签: mongodb localhost

$ 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

2 个答案:

答案 0 :(得分:1)

正确的答案应该是这样的

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

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. 尾随日志文件
  3. 使用mongod --dbpath
  4. 开始mongod --dbpath home/test/data/mymogodb/
  5. 打开一个新的终端窗口并使用 mongos 进行连接,如下所示 mongospress Enter
  6. 干杯!您 mongodb 现在已连接并且可以运行您的所有命令!

答案 1 :(得分:0)

您必须先启动mongod实例才能连接它。

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