如何从本地客户端连接到Openshift Mongodb(端口正在转发)?

时间:2014-11-08 19:17:46

标签: mongodb openshift openshift-client-tools

我创建了一个缩放的nodejs应用程序并添加了mongodb,一切运行正常(使用环境变量从nodejs内连接到mongodb)。现在我想从我的本地机器连接到数据库,我不能让它在我的生活中工作。

rhc port-forward -a [myapp] 

返回:

Forwarding ports ...
Address already in use - bind(2) while forwarding port 8080. Trying local port 8081
Address already in use - bind(2) while forwarding port 8080. Trying local port 8081
Address already in use - bind(2) while forwarding port 8081. Trying local port 8082

To connect to a service running on OpenShift, use the Local address

Service Local                OpenShift
------- --------------- ---- -------------------------------------------------
haproxy 127.0.0.1:8080   =>  127.2.114.130:8080
haproxy 127.0.0.1:8081   =>  127.2.114.131:8080
mongodb 127.0.0.1:65211  =>  [mysubdomain].rhcloud.com:65211
node    127.0.0.1:8082   =>  127.2.114.129:8080

据我所知,这看起来很好,不确定Address already in use部分。

尝试通过

从我的机器连接时
mongo -u admin -p [password] --host [mysubdomain].rhcloud.com --port 65211 [dbname]

我只是得到一个

Error: couldn't connect to server [mysubdomain].rhcloud.com:65211 (54.197.84.134), connection attempt failed at src/mongo/shell/mongo.js:148
exception: connect failed

因此,看起来该端口无法访问(域上的ping有效)。我直接从rhc port-forward复制了。有没有这方面经验的人?

1 个答案:

答案 0 :(得分:7)

看起来你正在连接错误的主机,你应该像这样连接到你的localhost:

mongo -u admin -p [password] --host 127.0.0.1 --port 65211 [dbname]