【发布时间】:2021-09-01 21:08:14
【问题描述】:
我对 mongodb 和 atlas 很陌生。我正在尝试在学习 Web 开发时将我的 atlas 服务器连接到 mongo shell。我正在尝试运行命令:
mongo "mongodb+srv://cluster0.6ss5b.mongodb.net/myFirstDatabase" --username Bruno
如果我在没有 vpn 的情况下在互联网上运行,我会收到错误消息:
DNSHostNotFound: Failed to look up service "":This operation returned because the timeout period expired.
try 'C:\Program Files\MongoDB\Server\4.4\bin\mongo.exe --help' for more information
表明我的 ISP 已为我阻止了此功能。 当我连接一个 vpn 时,我被要求输入我的用户名密码,然后得到错误:
connecting to: mongodb://cluster0-shard-00-00.6ss5b.mongodb.net:27017,cluster0-shard-00-01.6ss5b.mongodb.net:27017,cluster0-shard-00-02.6ss5b.mongodb.net:27017/myFirstDatabase?authSource=admin&compressors=disabled&gssapiServiceName=mongodb&replicaSet=atlas-kcfk5f-shard-0&ssl=true
{"t":{"$date":"2021-06-17T04:19:26.714Z"},"s":"I", "c":"NETWORK", "id":4333208, "ctx":"ReplicaSetMonitor-TaskExecutor","msg":"RSM host selection timeout","attr":{"replicaSet":"atlas-kcfk5f-shard-0","error":"FailedToSatisfyReadPreference: Could not find host matching read preference { mode: \"nearest\" } for set atlas-kcfk5f-shard-0"}}
*** You have failed to connect to a MongoDB Atlas cluster. Please ensure that your IP whitelist allows connections from your network.
Error: connect failed to replica set atlas-kcfk5f-shard-0/cluster0-shard-00-00.6ss5b.mongodb.net:27017,cluster0-shard-00-01.6ss5b.mongodb.net:27017,cluster0-shard-00-02.6ss5b.mongodb.net:27017 :
connect@src/mongo/shell/mongo.js:374:17
@(connect):2:6
exception: connect failed
exiting with code 1
我已将集群的所有 IP 列入白名单,将 ip 设置为 0.0.0.0/0 我的用户具有管理员权限。 在 vpn 上时,我无法打开我在某处读到的 url http://portquiz.net:27017/,这意味着端口 27017 对我来说被阻止了。如何将 atlas 服务器连接到 mongo shell?
【问题讨论】:
-
您可以使用 Mongo Compass GUI 工具。很容易访问和学习 mongo:mongodb.com/products/compass
标签: node.js mongodb mongodb-atlas