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

时间:2020-03-05 09:06:44

标签: 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> 

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

mongodump --uri="mongodb+srv://dxxxxxxx:xxxxxx[][]@cluster0-vxcen.gcp.mongodb.net/xxxxxxxxxx"

我遇到

问题
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

4 个答案:

答案 0 :(得分:14)

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

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

答案 1 :(得分:2)

此问题与报道的here类似。 上面更改resolv.conf的修复似乎无法持久重启。 在上面的链接中建议的解决方法是使用非srv url,或者,据我所知,重启后仍然可以幸存的更简单的方法是删除符号链接/etc/resolve.conf并将其替换为静态文件,其中包含所需的DNS服务器。

找到另一种选择here 建议安装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

答案 2 :(得分:0)

在某些情况下,例如在无法更改解析器的环境中,可以使用旧样式的URL:

client = pymongo.MongoClient("mongodb://<username>:<password>@<cluster>...

更改后由cloud.mongodb.com Atlas生成的URL 在“群集”->“连接”->“选择连接方法”->“ Python”-3.4或更高版本中

它终于开始工作了。

我的设置:

  • Ubuntu 18.04
  • Python 2.7.17 / 2.7.12
  • Pymongo 3.11.1
  • Google Cloud SDK 319.0.0

答案 3 :(得分:-1)

连接到不同的互联网连接(wifi 网络),然后连接回您自己的。这应该可以解决问题。