我正在尝试连接到从盒式磁带创建到OpenShift上的数据库,我遇到了使用shell中的Mongo客户端连接它的问题。
我使用Mac OS Sierra作为客户端,我的Mongo项目托管在MiniShift上。我可以使用OpenShift shell在本地连接:
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 :
connect@src/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
答案 0 :(得分:1)
我意识到无法编辑" bind_ip"在OpenShift上部署MongoDB之后(因此无法通过Robomongo等工具访问MongoDB)。因此,我在OpenShift项目中使用Mongo数据库的解决方案是在同一项目中嵌入使用DB的项目,并使用连接String和服务来识别数据库容器而不是IP,因为如果重新启动容器,则可以更改IP但服务将保持不变。