mongodb - 未检测到设置的主节点 [Mongo shell]

标签 mongodb shell mongo-shell

我当前的 MongoDb 版本是 3.2.7 我正在尝试用这个连接到我的数据库

"mongo mongodb://meanbeta-shard-00-00-sshqm.mongodb.net:27017,meanbeta-shard-00-01-sshqm.mongodb.net:27017,meanbeta-shard-00-02-sshqm.mongodb.net:27017/test?replicaSet=MEANbeta-shard-0" --authenticationDatabase admin --ssl --username xxxx --password xxxxx

昨天我能够通过 mongo shell 进行连接,但今天它给了我错误,但我仍然能够使用 Compass 应用程序进行连接:

 
  2017-10-20T20:34:04.682+0530 I NETWORK  [thread1] Starting new replica set monitor for MEANbeta-shard-0/meanbeta-shard-00-00-sshqm.mongodb.net:27017,meanbeta-shard-00-01-sshqm.mongodb.net:27017,meanbeta-shard-00-02-sshqm.mongodb.net:27017
2017-10-20T20:34:04.682+0530 I NETWORK  [ReplicaSetMonitorWatcher] starting
2017-10-20T20:34:07.708+0530 W NETWORK  [thread1] No primary detected for set MEANbeta-shard-0
2017-10-20T20:34:11.095+0530 W NETWORK  [thread1] No primary detected for set MEANbeta-shard-0
2017-10-20T20:34:14.516+0530 W NETWORK  [thread1] No primary detected for set MEANbeta-shard-0
2017-10-20T20:34:16.637+0530 W NETWORK  [ReplicaSetMonitorWatcher] No primary detected for set MEANbeta-shard-0
2017-10-20T20:34:20.056+0530 W NETWORK  [thread1] No primary detected for set MEANbeta-shard-0
2017-10-20T20:34:20.056+0530 E QUERY    [thread1] Error: connect failed to replica set MEANbeta-shard-0/meanbeta-shard-00-00-sshqm.mongodb.net:27017,meanbeta-shard-00-01-sshqm.mongodb.net:27017,meanbeta-shard-00-02-sshqm.mongodb.net:27017 :
 

我是 MongoDB 及其副本集概念的新手,请帮助我。

谢谢

最佳答案

不要从 apt-get 安装 mongo shell,因为它会安装旧版本。您需要MongoDB shell版本v3.4.10或更高版本才能工作。

在通过 mongo 网站上从 shell 对话框连接到集群中显示的链接安装较新版本之前,我也遇到了同样的问题。

enter image description here

关于mongodb - 未检测到设置的主节点 [Mongo shell],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46852169/

相关文章:

mongodb - 使用 native 驱动程序附加到mongo查询

c# - 检查 BsonValue 是否不为空

php - 如何检查MongoDB错误?

linux - 检查是否在 Bash 中设置了陷阱

linux - 在输出文件中打印列

linux - 在 bash 脚本的 until 循环中验证多个表达式

mongodb - 在 mongo shell 中将 Mongo 查询输出打印到文件

node.js - MongoDB/Mongoose $pull(删除)子文档不起作用

node.js - mongoose 查询在 Node.js 中不起作用,但在 mongo shell 中起作用

mongodb - 如何从 atlas 备份文件中恢复 mongo?