Mongo shell无法连接到服务器

时间:2014-09-10 18:13:23

标签: mongodb cloud9-ide

这一定是一个简单的问题,但我已经非常谨慎地遵循了https://docs.c9.io/setting_up_mongodb.html提供的优秀而简单的文档,并阅读了包含&#的每个 cloud9-ide 标记的问题39; MongoDB的' - 无济于事。我很感激任何可能的帮助。

按照上面提到的说明,我似乎能够让mongo正常运行。 (见下文。)

然而,当我按照指示尝试shell时,我收到以下错误:

cliffchaney@sacs:~/workspace $ mongo --host $IP
MongoDB shell version: 2.6.4
connecting to: 0.0.0.0:27017/test
2014-09-10T17:53:55.570+0000 Error: couldn't connect to server 0.0.0.0:27017 (0.0.0.0), address resolved to 0.0.0.0 at src/mongo/shell/mongo.js:148
exception: connect failed

有什么建议吗?

如上所述,似乎我可以让mongod运行。按照前面提到的说明后,我可以执行以下操作(虽然我收到警告):

cliffchaney@sacs:~/workspace $ ./mongod
2014-09-10T17:52:29.370+0000 ** WARNING: --rest is specified without --httpinterface,
2014-09-10T17:52:29.370+0000 **          enabling http interface
warning: bind_ip of 0.0.0.0 is unnecessary; listens on all ips by default
2014-09-10T17:52:29.376+0000 [initandlisten] MongoDB starting : pid=1345 port=27017 dbpath=data 64-bit host=cliffchaney-sacs-983224
2014-09-10T17:52:29.376+0000 [initandlisten] db version v2.6.4
2014-09-10T17:52:29.376+0000 [initandlisten] git version: 3a830be0eb92d772aa855ebb711ac91d658ee910
2014-09-10T17:52:29.376+0000 [initandlisten] build info: Linux build7.nj1.10gen.cc 2.6.32-431.3.1.el6.x86_64 #1 SMP Fri Jan 3 21:39:27 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49
2014-09-10T17:52:29.376+0000 [initandlisten] allocator: tcmalloc
2014-09-10T17:52:29.376+0000 [initandlisten] options: { net: { bindIp: "0.0.0.0", http: { RESTInterfaceEnabled: true, enabled: true } }, storage: { dbPath: "data", journal: { enabled: false } } }
2014-09-10T17:52:29.389+0000 [initandlisten] waiting for connections on port 27017
2014-09-10T17:52:29.389+0000 [websvr] admin web console waiting for connections on port 28017
2014-09-10T17:53:29.389+0000 [clientcursormon] mem (MB) res:51 virt:238
2014-09-10T17:53:29.389+0000 [clientcursormon]  mapped:80
2014-09-10T17:53:29.389+0000 [clientcursormon]  connections:0
2014-09-10T17:58:29.399+0000 [clientcursormon] mem (MB) res:52 virt:239
2014-09-10T17:58:29.399+0000 [clientcursormon]  mapped:80
2014-09-10T17:58:29.399+0000 [clientcursormon]  connections:0
2014-09-10T18:03:29.410+0000 [clientcursormon] mem (MB) res:52 virt:239
2014-09-10T18:03:29.410+0000 [clientcursormon]  mapped:80
2014-09-10T18:03:29.410+0000 [clientcursormon]  connections:0*

1 个答案:

答案 0 :(得分:1)

只需运行

即可访问shell提示符
$ mongo

没有--host参数。