mongodb 转储失败,无法解组 DNS 消息

kle*_*lee 20 mongodb mongodump

我正在使用安装在 EC2 实例上的 mongo db 服务器版本 MongoDB shell 版本 v4.0.16。

我可以使用 mongo 命令进入实例

mongo mongodb+srv://dxxxxxxx:xxxxxx[][]@cluster0-vxcen.gcp.mongodb.net 
MongoDB shell version v4.0.16
connecting to: mongodb://cluster0-shard-00-02-vxcen.gcp.mongodb.net.:27017,cluster0-shard-00-01-vxcen.gcp.mongodb.net.:27017,cluster0-shard-00-00-vxcen.gcp.mongodb.net.:27017/?authSource=admin&gssapiServiceName=mongodb&replicaSet=Cluster0-shard-0&ssl=true
2020-03-05T09:02:45.265+0000 I NETWORK  [js] Starting new replica set monitor for Cluster0-shard-0/cluster0-shard-00-02-vxcen.gcp.mongodb.net.:27017,cluster0-shard-00-01-vxcen.gcp.mongodb.net.:27017,cluster0-shard-00-00-vxcen.gcp.mongodb.net.:27017
2020-03-05T09:02:45.604+0000 I NETWORK  [ReplicaSetMonitor-TaskExecutor] Successfully connected to cluster0-shard-00-00-vxcen.gcp.mongodb.net.:27017 (1 connections now open to cluster0-shard-00-00-vxcen.gcp.mongodb.net.:27017 with a 5 second timeout)
2020-03-05T09:02:45.607+0000 I NETWORK  [js] Successfully connected to cluster0-shard-00-01-vxcen.gcp.mongodb.net.:27017 (1 connections now open to cluster0-shard-00-01-vxcen.gcp.mongodb.net.:27017 with a 5 second timeout)
2020-03-05T09:02:45.707+0000 I NETWORK  [js] changing hosts to Cluster0-shard-0/cluster0-shard-00-00-vxcen.gcp.mongodb.net:27017,cluster0-shard-00-01-vxcen.gcp.mongodb.net:27017,cluster0-shard-00-02-vxcen.gcp.mongodb.net:27017 from Cluster0-shard-0/cluster0-shard-00-00-vxcen.gcp.mongodb.net.:27017,cluster0-shard-00-01-vxcen.gcp.mongodb.net.:27017,cluster0-shard-00-02-vxcen.gcp.mongodb.net.:27017
2020-03-05T09:02:46.010+0000 I NETWORK  [js] Successfully connected to cluster0-shard-00-00-vxcen.gcp.mongodb.net:27017 (1 connections now open to cluster0-shard-00-00-vxcen.gcp.mongodb.net:27017 with a 5 second timeout)
2020-03-05T09:02:46.028+0000 I NETWORK  [ReplicaSetMonitor-TaskExecutor] Successfully connected to cluster0-shard-00-01-vxcen.gcp.mongodb.net:27017 (1 connections now open to cluster0-shard-00-01-vxcen.gcp.mongodb.net:27017 with a 5 second timeout)
2020-03-05T09:02:46.439+0000 I NETWORK  [js] Successfully connected to cluster0-shard-00-02-vxcen.gcp.mongodb.net:27017 (1 connections now open to cluster0-shard-00-02-vxcen.gcp.mongodb.net:27017 with a 5 second timeout)
Implicit session: session { "id" : UUID("1c7432d5-e09c-45f8-8d84-d47e4f572cbf") }
MongoDB server version: 4.2.3
WARNING: shell and server versions do not match
Error while trying to show server startup warnings: user is not allowed to do action [getLog] on [admin.]
MongoDB Enterprise Cluster0-shard-0:PRIMARY> 
Run Code Online (Sandbox Code Playgroud)

我正在尝试连接到 mongo db Atlas 以使用 mongodump 获取数据库

mongodump --uri="mongodb+srv://dxxxxxxx:xxxxxx[][]@cluster0-vxcen.gcp.mongodb.net/xxxxxxxxxx"
Run Code Online (Sandbox Code Playgroud)

我面临着问题

error parsing command line options: error parsing uri (mongodb+srv://dxxxxxxx:xxxxxx[]@cluster0-vxcen.gcp.mongodb.net/xxxxxxxxxx): lookup cluster0-vxcen.gcp.mongodb.net on 127.0.0.53:53: cannot unmarshal DNS message
Run Code Online (Sandbox Code Playgroud)

Aki*_*nde 35

这只是 DNS 服务器不兼容的情况。

找到/etc/resolv.conf文件并将名称服务器替换为8.8.8.8,一切都应该正常工作。如果这不起作用,请尝试1.1.1.1

  • 这对我很有帮助 - 谢谢。在 MacOS 上,您可以通过转至系统偏好设置 --> 网络 --> 高级,然后单击 DNS 按钮来进行设置。添加 8.8.8.8 和 1.1.1.1 就可以了。 (13认同)
  • 在 Ubuntu 18.04 上,这是“/etc/resolv.conf” (2认同)

eli*_*eli 5

此问题与此处报告的问题类似。如上所述更改 resolv.conf 的修复程序似乎不会持续重新启动。上面链接中提出的解决方法是使用非 srv url,或者,一种更简单的方法,据我所知,重新启动后仍然存在,是删除符号链接/etc/resolve.conf并将其替换为包含所需 DNS 服务器的静态文件.

此处找到的另一个选项 建议安装 resolvconf(对于 Ubuntu apt install resolvconf),将行添加nameserver 8.8.8.8/etc/resolvconf/resolv.conf.d/base,然后运行sudo resolvconf -u并确保service resolvconf restart. 要验证运行systemd-resolve --status.

您应该在第一行看到您的 DNS 服务器,如下所示:

         DNS Servers: 8.8.8.8
          DNS Domain: sa-east-1.compute.internal
          DNSSEC NTA: 10.in-addr.arpa
                      16.172.in-addr.arpa
Run Code Online (Sandbox Code Playgroud)