简体   繁体   English

为什么我不能使用mongo shell连接到副本集?

[英]Why cant I connect to replica set using mongo shell?

I can connect to replica set using following command from mongo shell version 3.2.11. 我可以使用mongo shell版本3.2.11中的以下命令连接到副本集。 But the same does not works with mongo shell v3.4.1. 但同样适用于mongo shell v3.4.1。

mongo --host \
      "replicaSet1/10.10.10.15:27001,10.10.10.16:27002,10.10.10.17:27000" mydbname \
      -u root -p root \
      --authenticationDatabase admin

 [main] Error: Failed to parse mongodb:// URL: mongodb://replicaSet1/10.10.10.15:27001,10.10.10.16:27002,10.10.10.17:27000/mydbname :

I have read here that replica set address format has not changed since v 3.4.1 release. 我在这里读到,自v 3.4.1发布以来,副本集地址格式没有改变。

Why cant I connect to db ? 为什么我无法连接到db? What is the parse error, as per new format(if its there). 什么是解析错误,根据新格式(如果它在那里)。

This is a known regression in MongoDB 3.4.0/3.4.1: SERVER-27289: mongo --host replSet/Host:Port no longer works . 这是MongoDB 3.4.0 / 3.4.1中已知的回归: SERVER-27289: mongo --host replSet/Host:Port不再有效 A fix has been committed for the upcoming MongoDB 3.4.2 release. 已经为即将发布的MongoDB 3.4.2版本提供了修复程序。

You can work around this in an affected 3.4.x mongo shell by using the standard MongoDB Connection String URI format instead: 您可以使用标准的MongoDB连接字符串URI格式在受影响的3.4.x mongo shell中解决此问题:

mongo --host mongodb://10.10.10.15:27001,10.10.10.16:27002,10.10.10.17:27000/mydbname?replicaSet=replicaSet1

You can also use a standard MongoDB Connection String as a plain argument (ie without the --host parameter): 您还可以使用标准MongoDB连接字符串作为普通参数(即不使用--host参数):

mongo mongodb://10.10.10.15:27001,10.10.10.16:27002,10.10.10.17:27000/mydbname?replicaSet=replicaSet1

I have read here that replica set address format has not changed since v 3.4.1 release. 我在这里读到,自v 3.4.1发布以来,副本集地址格式没有改变。

Support for using the standard MongoDB Connecting String format in the --host parameter was added in MongoDB 3.4 in order to align the mongo shell connection string syntax with the format used by all official drivers. 在MongoDB 3.4中添加了对在--host参数中使用标准MongoDB连接字符串格式的支持,以便将mongo shell连接字符串语法与所有官方驱动程序使用的格式对齐。

This change is currently not noted in the MongoDB 3.4 manual, so I've raised DOCS-9808 to clarify. MongoDB 3.4手册中目前没有注意到这一变化,因此我提出了DOCS-9808进行澄清。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM