這一定是一個簡單的問題,但我非常認真地遵循https://docs.c9.io/setting_up_mongodb.html提供的優秀和簡單的文檔並閱讀每個cloud9-ide標記的問題,其中包括'MongoDb' - 徒勞無功。我會很感激任何幫助。Mongo外殼無法連接到服務器
按照上面提到的說明,我似乎能夠讓mongo正常運行。 (見下文)。
然而,當我嘗試了殼 - 按照指示 - 我得到以下錯誤:
[email protected]:~/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運行。按照前面提到的指令後,我可以執行以下(雖然我得到一個警告):
[email protected]:~/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*
那麼你真的有一個mongod運行時,你正在嘗試連接?或者你是在同一個終端窗口中分別運行它們嗎? – 2014-09-10 22:05:03
好問題!絕對。我正在使用第二個終端窗口來執行mongo shell。我在一個窗口中啓動mongod,然後翻轉到另一個窗口(在一個Cloud9工作區內)。雖然,我剛剛瞭解到「./mongo&」命令可能允許我使用相同的終端窗口。 (我的語法可能不正確,當我回到我的開發機器時,我會再次查看它)。我今晚晚些時候會嘗試這種方法,看它是否能解決我的問題 - 但似乎不太可能。 – 2014-09-10 22:40:20
我已經更新了c9上的文檔,並在下面發佈了一個答案:https://docs.c9.io/setting_up_mongodb.html – 2014-09-11 13:12:40