Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过终端连接到MongoDB本地安装时出错_Mongodb - Fatal编程技术网

通过终端连接到MongoDB本地安装时出错

通过终端连接到MongoDB本地安装时出错,mongodb,Mongodb,终端显示以下错误: $ mongo MongoDB shell version: 2.4.5 connecting to: test Wed Jul 24 14:26:45.779 JavaScript execution failed: Error: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:L112 exception: connect failed $ mongod --r

终端显示以下错误:

$ mongo
MongoDB shell version: 2.4.5
connecting to: test
Wed Jul 24 14:26:45.779 JavaScript execution failed: Error: couldn't connect to server         127.0.0.1:27017 at src/mongo/shell/mongo.js:L112
exception: connect failed
$ mongod --repair
Wed Jul 24 15:16:51.596 Can't specify both --journal and --repair options.
跑步时 mongod运行——config/usr/local/etc/mongod.conf

我在控制台上遇到以下错误:

about to fork child process, waiting until server is ready for connections.
forked process: 11204
all output going to: /usr/local/var/log/mongodb/mongo.log
ERROR: child process failed, exited with error number 100
mongo.log显示:

***** SERVER RESTARTED *****
Wed Jul 24 14:39:57.360 [initandlisten] MongoDB starting : pid=11204 port=27017      dbpath=/usr/local/var/mongodb 64-bit host=59.161.67.13.del-cdma.dialup.vsnl.net.in
Wed Jul 24 14:39:57.363 [initandlisten] 
Wed Jul 24 14:39:57.363 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
Wed Jul 24 14:39:57.363 [initandlisten] db version v2.4.5 
Wed Jul 24 14:39:57.363 [initandlisten] git version:  a2ddc68ba7c9cee17bfe69ed840383ec3506602b
Wed Jul 24 14:39:57.363 [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
Wed Jul 24 14:39:57.363 [initandlisten] allocator: system
Wed Jul 24 14:39:57.363 [initandlisten] options: { bind_ip: "127.0.0.1", command: [ "run" ], 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" }
Wed Jul 24 14:39:57.367 [initandlisten] journal dir=/usr/local/var/mongodb/journal
Wed Jul 24 14:39:57.368 [initandlisten] recover : no journal files present, no recovery needed
Wed Jul 24 14:39:58.113 [initandlisten] couldn't open /usr/local/var/mongodb/test.0 errno:13 Permission denied
Wed Jul 24 14:39:58.136 [initandlisten] couldn't open /usr/local/var/mongodb/test.0 errno:13 Permission denied
Wed Jul 24 14:39:58.152 [initandlisten] exception in initAndListen: 10085 can't map file memory, terminating
Wed Jul 24 14:39:58.152 dbexit: 
Wed Jul 24 14:39:58.152 [initandlisten] shutdown: going to close listening sockets...
Wed Jul 24 14:39:58.153 [initandlisten] shutdown: going to flush diaglog...
Wed Jul 24 14:39:58.153 [initandlisten] shutdown: going to close sockets...
Wed Jul 24 14:39:58.153 [initandlisten] shutdown: waiting for fs preallocator...
Wed Jul 24 14:39:58.153 [initandlisten] shutdown: lock for final commit...
Wed Jul 24 14:39:58.153 [initandlisten] shutdown: final commit...
Wed Jul 24 14:39:58.153 [initandlisten] shutdown: closing all files...
Wed Jul 24 14:39:58.154 [initandlisten] closeAllFiles() finished
Wed Jul 24 14:39:58.154 [initandlisten] journalCleanup...
Wed Jul 24 14:39:58.154 [initandlisten] removeJournalFiles
Wed Jul 24 14:39:58.154 [initandlisten] shutdown: removing fs lock...
Wed Jul 24 14:39:58.154 dbexit: really exiting now
编辑!(从答案中尝试建议) 运行$mongod--repair会出现以下错误:

$ mongo
MongoDB shell version: 2.4.5
connecting to: test
Wed Jul 24 14:26:45.779 JavaScript execution failed: Error: couldn't connect to server         127.0.0.1:27017 at src/mongo/shell/mongo.js:L112
exception: connect failed
$ mongod --repair
Wed Jul 24 15:16:51.596 Can't specify both --journal and --repair options.

您需要确保实际启动了服务器。它似乎没有在这里运行。

首先运行以下命令以启动mongo服务器

mongod run --config /usr/local/etc/mongod.conf
假设您使用安装了mongo

有关mongod进程的更多信息

编辑

尝试使用以下方法修复mongo:

mongod --repair

似乎权限也有问题,请尝试使用
sudo
启动mongod

我刚刚通过运行$brew update mongodb命令更新了mongo。我正在关注它说的下一步运行$mongo。启动服务器的命令是什么?很好,但这不会启动服务器!那么如何启动服务器呢?我已经回答了上面的问题;)我使用Brew安装了它。我遇到以下错误:即将分叉子进程,等待服务器准备好连接。分叉进程:11204所有输出转到:/usr/local/var/log/mongodb/mongo.log错误:子进程失败,退出,错误号为100请执行
mongod--version
查看您使用的是哪个mongod版本。我使用的是:db version v2.4.5 Wed Jul 24 14:44:37.222 git版本:A2DDC68Ba7C9CEE17BFE69ED84038EC3506602是最新版本。我刚刚更新了一个小时。(使用brew)您使用的是哪种操作系统?您可能希望使用
brew doctor
检查brew安装。仅供参考,要更新brew公式,您应首先使用
brew update
更新brew,然后使用
brew upgrade mongo