2017-08-17 59 views
1

我試圖連接到從盒式磁帶創建到OpenShift上的數據庫,並且我通過shell使用Mongo客戶端通過它進行連接。使用Mongo-Cli連接到OpenShift數據庫

我使用Mac OS Sierra作爲客戶端,我的Mongo項目託管在MiniShift上。我可以在本地連接使用OpenShift殼:

mongo sampledb --host localhost -u user -p password

但是,當我嘗試從MacOS的直接連接:

mongo sampledb --host devmongo-mongo01.192.168.99.100.nip.io -u user -p password

我用詳細模式這個錯誤堆棧激活:

2017-08-17T18:10:41.938+0200 D NETWORK [thread1] creating new connection to:devmongo-mongo01.192.168.99.100.nip.io:27017 
2017-08-17T18:10:41.941+0200 W NETWORK [thread1] Failed to connect to 192.168.99.100:27017, in(checking socket for error after poll), reason: Connection refused 
2017-08-17T18:10:41.941+0200 D -  [thread1] User Assertion: 1:couldn't connect to server devmongo-mongo01.192.168.99.100.nip.io:27017, connection attempt failed src/mongo/scripting/mozjs/mongo.cpp 716 
2017-08-17T18:10:41.941+0200 E QUERY [thread1] Error: couldn't connect to server devmongo-mongo01.192.168.99.100.nip.io:27017, connection attempt failed : 
[email protected]/mongo/shell/mongo.js:237:13 
@(connect):1:6 
2017-08-17T18:10:41.941+0200 D -  [thread1] User Assertion: 12513:connect failed src/mongo/shell/shell_utils.cpp 256 
2017-08-17T18:10:41.941+0200 I QUERY [thread1] MozJS GC prologue heap stats - total: 3498847 limit: 0 
2017-08-17T18:10:41.943+0200 I QUERY [thread1] MozJS GC epilogue heap stats - total: 350087 limit: 0 
2017-08-17T18:10:41.943+0200 I QUERY [thread1] MozJS GC prologue heap stats - total: 241791 limit: 0 
2017-08-17T18:10:41.944+0200 I QUERY [thread1] MozJS GC epilogue heap stats - total: 50423 limit: 0 
2017-08-17T18:10:41.944+0200 D -  [main] User Assertion: 12513:connect failed src/mongo/scripting/mozjs/proxyscope.cpp 295 
exception: connect failed 
+1

什麼是Mongo配置文件中的bindip?默認情況下,它將是本地主機,更改爲正確的IP說192.168.99.100並重新啓動mongod。嘗試再次連接。 – dilsingi

+1

關於bindip,你可能是對的,我過去曾經遇到過這個問題,但是在OpenShift上,這有點不同,因爲你使用預先配置的盒式磁帶,一旦部署,容器就不可變,這會讓遊戲變得有點更復雜... – awzx

回答

1

我意識到在OpenShif上部署MongoDB之後,無法編輯「bind_ip」 t(因此無法通過Robomongo等工具訪問MongoDB)。因此,我在OpenShift項目中使用Mongo數據庫的解決方案是將使用數據庫的項目嵌入到同一項目中,並使用連接字符串和服務來標識數據庫容器而不是IP,因爲如果容器重新啓動,則可以更改IP但服務將保持不變。