英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论