无法从 mongo shell、mongo 指南针连接到 mongo atlas 并转到 mgo 驱动程序

Couldnt connect to mongo atlas from the mongo shell, mongo compass and go mgo Driver

我正在尝试将 mongo shell 与我的 mongo atlas M0 集群连接并最终收到此错误

Error Message

我试过的解决方案没有用:

我将 monog 版本升级到 4.2 以与 mongo 版本不同步 阿特拉斯,没有解决这个错误的问题mongo

"mongodb://cluster0-shard-00-02.79t7i.azure.mongodb.net:27017,cluster0-shard-00-00.79t7i.azure.mongodb.net:27017,cluster0-shard-00-01.79t7i.azure.mongodb.net:27017/testdatabase?tls=true" MongoDB shell version v4.2.8 connecting to: mongodb://cluster0-shard-00-02.79t7i.azure.mongodb.net:27017,cluster0-shard-00-00.79t7i.azure.mongodb.net:27017,cluster0-shard-00-01.79t7i.azure.mongodb.net:27017/testdatabase?compressors=disabled&gssapiServiceName=mongodb&tls=true

*** It looks like this is a MongoDB Atlas cluster. Please ensure that your IP whitelist allows connections from your network.

2020-08-16T00:14:57.693+0545 E QUERY [js] Error: couldn't connect to server cluster0-shard-00-01.79t7i.azure.mongodb.net:27017, connection attempt failed: HostUnreachable: Connection reset by peer : connect@src/mongo/shell/mongo.js:341:17 @(connect):2:6 2020-08-16T00:14:57.695+0545 F - [main] exception: connect failed 2020-08-16T00:14:57.695+0545 E - [main] exiting with code 1

尝试使用 mgo go 驱动程序时出现错误:

time="2020-08-17T15:32:32+05:45" level=debug msg="mongo host and port : mongodb://cluster0-shard-00-00.akidp.azure.mongodb.net:27017,cluster0-shard-00-01.akidp.azure.mongodb.net:27017,cluster0-shard-00-02.akidp.azure.mongodb.net:27017" time="2020-08-17T15:33:32+05:45" level=error msg="Unable to connect to mongo no reachable servers" panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x8f3a02]

goroutine 1 [running]: gopkg.in/mgo%2ev2.(*Session).Copy(0x0, 0x7fbebca1b008) /home/sgupta/go/pkg/mod/gopkg.in/mgo.v2@v2.0.0-20180705113604-9856a29383ce/session.go:1593 +0x22 github.optum.com/claredi/oti.git/ds.Copy(0xc001ae3a30, 0x0, 0x0) /home/sgupta/go/src/github.optum.com/claredi/oti.git/ds/ds.go:166 +0x3c github.optum.com/claredi/oti.git/ds/announcements.indexes() /home/sgupta/go/src/github.optum.com/claredi/oti.git/ds/announcements/announcements.go:47 +0xff github.optum.com/claredi/oti.git/ds.Init(0xc0000f8000, 0xc0001efe68) /home/sgupta/go/src/github.optum.com/claredi/oti.git/ds/ds.go:98 +0x52e main.startAPIServer(0x0, 0xc000098360) /home/sgupta/go/src/github.optum.com/claredi/oti.git/api/main.go:83 +0xe98 main.main() /home/sgupta/go/src/github.optum.com/claredi/oti.git/api/main.go:26 +0x4d exit status 2

希望得到专家的解决。提前致谢:)

首先,在阿特拉斯:

  1. 确保集群本身在“集群”中看起来健康
  2. 转到“网络访问”并确保您的 IP 被允许
  3. 为了安全起见,转到“数据库访问”并创建一个具有适当权限的新用户

如果您的问题类似,可能是您的IP变了什么的,您需要允许您当前的IP。