如何恢复 Mongodb M0 集群?

huangapple go评论84阅读模式
英文:

how to resume Mongodb M0 Cluster?

问题

MongoDB集群(免费版)在几个小时的不活动后暂停(而不是免费集群的规定7天)。

我尝试使用mongosh和我的Go代码恢复,但仍然无法工作。这是我第二次遇到这个问题,第一次我以为是一个非时代性的错误,终止了集群,但现在看起来不是这样。我希望找到一个更好的处理这个问题的方法。

这是我的错误日志:

来自Go驱动程序

服务器选择错误:服务器选择超时,当前拓扑:{ 类型:ReplicaSetNoPrimary,服务器:[{ 地址:cluster[].mongodb.net:27017,类型:未知,上次错误:connection() error occured during connection handshake: connection(cluster0-shard-00-00.r3cqf.mongodb.net) socket was unexpectedly closed: EOF }

来自终端中的mongosh

MongoServerSelectionError: 连接<monitor>到32.65.3.208:27017已关闭
英文:

MongoDB cluster(free) paused only after a couple hours of inactivity (as opposed to the stated 7 days for the free cluster).

I have tried to resume using mongosh and through my Go code but it still does not work. This is my second time encountering this issue, the first time I assumed it was a non-anachronistic error and terminated the cluster but now it does not look like it. i would love to find out a better way to handle this issue.

here are my error logs:
> from the Go driver

server selection error: server selection timeout, current topology: { Type: ReplicaSetNoPrimary, Servers: [{ Addr: cluster[].mongodb.net:27017, Type: Unknown, Last error: connection() error occured during connection handshake: connection(cluster0-shard-00-00.r3cqf.mongodb.net) socket was unexpectedly closed: EOF }

> from mongosh in terminal

MongoServerSelectionError: connection <monitor> to 32.65.3.208:27017 closed

答案1

得分: 1

在仔细查看错误日志几个小时后,我意识到我的问题与授权有关。

要解决这个问题,导航到你的Mongodb集群的网络/设置部分,并将集群设置为接受来自当前IP的连接请求 - 当我切换互联网源时,我的IP已经改变。你也可以通过在IP地址字段中输入0.0.0.0来设置它接受来自所有IP地址的请求。尽管这绝对不是在生产环境中工作的最佳解决方案,但在本地机器上,它会起作用。

英文:

After a couple hours of combing through the error logs, I realized my issue was authorization related.

To fix this, navigate through the network/settings section of your Mongodb cluster and set the cluster to accept connection requests from your current IP -- mine had changed when I switched internet sources. You could also just set it to accept requests from all IP addresses by inputting 0.0.0.0 in the IP address field. Granted this is definitely not the best solution when working in prod but for now(on local machine), it'll do.

huangapple
  • 本文由 发表于 2022年4月5日 01:03:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/71741067.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定