无法使用 mongodb+srv 将 Mongo shell 连接到 Mongo Atlas M0 [英] Can't connect Mongo shell to Mongo Atlas M0 using mongodb+srv

查看:332
本文介绍了无法使用 mongodb+srv 将 Mongo shell 连接到 Mongo Atlas M0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过 mongo+srv 连接连接到我的 MongoDB Atlas Cloud 集群,如下所示:

I am trying to connect to my MongoDB Atlas Cloud cluster via the mongo+srv connection like so:

mongo "mongodb+srv://cluster0-mhzdc.mongodb.net/test" --username myuser

我收到了这个回复:

DNSHostNotFound: Failed to look up service "_mongodb._tcp.cluster0-mhzdc.mongodb.net": Undefined error: 0
try 'mongo --help' for more information

我正在使用以下版本的 Mongo 客户端:

I am using the following version of Mongo client:

mongo --version
MongoDB shell version v4.0.5
git version: 3739429dd92b92d1b0ab120911a23d50bf03c412
allocator: system
modules: none
build environment:
    distarch: x86_64
    target_arch: x86_64

我在网上找不到任何解决方案.任何想法有什么问题?这是给定版本的 Mongo shell 客户端中的错误吗?

I can't find any resolution online. Any ideas what's wrong? Is this a bug in the given version of the Mongo shell client?

推荐答案

看起来像是 bug 34117,仍未解决:

It looks like bug 34117, still unresolved:

https://jira.mongodb.org/browse/SERVER-34117

如果您的笔记本电脑上有活动的 DNS 解析器,则要解决错误检查.在 Windows 上:

To work around the bug check if you have a DNS resolver active on your notebook. On windows:

ipconfig /displayDNS

查看当前的 DNS 解析器缓存.您甚至可以尝试使用以下命令擦除缓存:

to see the current DNS resolver cache. You might even try to erase the cache with the command:

ipconfig /flushdns

然后重试.如果您在 linux ubuntu 上工作,请尝试以下命令:

and retry. If you are working on linux ubuntu try the command:

named -v

检查是否已安装 DNS 解析器软件.如果不是:

to check if the DNS resolver software is already installed. If not:

sudo apt update
sudo apt install bind9 bind9utils bind9-doc bind9-host

安装需要的包,然后启动服务:

to install the needed packages, then start the service:

sudo systemctl start bind9

然后重试.

在 Mac OSX 上,命令是:

On Mac OSX, the command is:

sudo killall -HUP mDNSResponder;sudo killall mDNSResponderHelper;sudo dscacheutil -flushcache

这篇关于无法使用 mongodb+srv 将 Mongo shell 连接到 Mongo Atlas M0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆