【发布时间】:2020-05-20 23:39:57
【问题描述】:
我正在尝试使用公共 IP 而不是主机名连接到我的 mongodb atlas 实例。
所有 IP 都在安全设置中列入白名单。
我查找了集群中每个节点的公共 IP,并尝试连接到每个节点,但每次都失败。
Hosts ---> Public Address
(Secondary node) cluster0-shard-00-00-ubkbl.mongodb.net ---> 54.221.247.60
(Primary node) cluster0-shard-00-01-ubkbl.mongodb.net ---> 54.145.147.81
(secondary node) cluster0-shard-00-02-ubkbl.mongodb.net ---> 184.73.253.26
如何找到合适的公共 IP 来使用?
错误示例:
mongo admin --host 54.145.147.81 -u <USERNAME> --port 27017 -p --verbose
MongoDB shell version v4.2.0
Enter password:
connecting to: mongodb://54.145.147.81:27017/admin?compressors=disabled&gssapiServiceName=mongodb
2020-05-20T20:09:18.015-0400 D1 NETWORK [js] creating new connection to:54.145.147.81:27017
2020-05-20T20:09:18.032-0400 D1 NETWORK [js] connected to server 54.145.147.81:27017
2020-05-20T20:09:18.050-0400 I NETWORK [js] DBClientConnection failed to receive message from 54.145.147.81:27017 - HostUnreachable: Connection closed by peer
2020-05-20T20:09:18.050-0400 D1 - [js] User Assertion: HostUnreachable: network error while attempting to run command 'isMaster' on host '54.145.147.81:27017' src/mongo/client/dbclient_base.cpp 226
2020-05-20T20:09:18.050-0400 D1 - [js] User Assertion: InternalError: network error while attempting to run command 'isMaster' on host '54.145.147.81:27017' src/mongo/scripting/mozjs/mongo.cpp 832
2020-05-20T20:09:18.050-0400 E QUERY [js] Error: network error while attempting to run command 'isMaster' on host '54.145.147.81:27017' :
connect@src/mongo/shell/mongo.js:341:17
@(connect):2:6
2020-05-20T20:09:18.050-0400 D1 - [js] User Assertion: Location12513: connect failed src/mongo/shell/shell_utils.cpp 416
2020-05-20T20:09:18.050-0400 I QUERY [js] MozJS GC prologue heap stats - total: 3762898 limit: 0
2020-05-20T20:09:18.053-0400 I QUERY [js] MozJS GC epilogue heap stats - total: 2 limit: 0
2020-05-20T20:09:18.053-0400 D1 - [main] User Assertion: Location12513: connect failed src/mongo/scripting/mozjs/proxyscope.cpp 320
2020-05-20T20:09:18.053-0400 F - [main] exception: connect failed
2020-05-20T20:09:18.053-0400 E - [main] exiting with code 1
【问题讨论】:
-
你是如何尝试连接的,你看到了什么错误?
-
Mongoshell 也是一个外部应用程序。
-
我们可以看到 mongo shell 命令行和使用
--verbose选项的响应吗? -
@Joe 更新上面的描述 ^
-
Atlas 需要 TLS/SSL。 Atlas 集群也是一个副本集,因此您可能需要指定该集的名称。
标签: mongodb connection mongodb-atlas