Mongodb连接失败

时间:2017-06-02 13:36:16

标签: mongodb

我创建了一个mongodb集群并尝试通过mongo shell进行连接,但是遇到了错误。我有什么不对劲吗?

mongo "mongodb://cluster0-shard-00-00-qvc6m.mongodb.net:27017,cluster0-shard-00-01-qvc6m.mongodb.net:27017,cluster0-shard-00-02-qvc6m.mongodb.net:27017/test?replicaSet=cluster0-shard-0" --authenticationDatabase <DATABASE> --ssl --username <USERNAME> --password <PASSWORD>

MongoDB shell version: 3.2.12
connecting to: mongodb://cluster0-shard-00-00-qvc6m.mongodb.net:27017,cluster0-shard-00-01-qvc6m.mongodb.net:27017,cluster0-shard-00-02-qvc6m.mongodb.net:27017/test?replicaSet=cluster0-shard-0
2017-06-02T18:59:22.341+0530 I NETWORK  [thread1] Starting new replica set monitor for cluster0-shard-0/cluster0-shard-00-00-qvc6m.mongodb.net:27017,cluster0-shard-00-01-qvc6m.mongodb.net:27017,cluster0-shard-00-02-qvc6m.mongodb.net:27017
2017-06-02T18:59:22.342+0530 I NETWORK  [ReplicaSetMonitorWatcher] starting
2017-06-02T18:59:27.220+0530 W NETWORK  [thread1] No primary detected for set cluster0-shard-0
2017-06-02T18:59:28.685+0530 W NETWORK  [thread1] No primary detected for set cluster0-shard-0
2017-06-02T18:59:30.120+0530 W NETWORK  [thread1] No primary detected for set cluster0-shard-0
2017-06-02T18:59:31.553+0530 W NETWORK  [thread1] No primary detected for set cluster0-shard-0
2017-06-02T18:59:32.679+0530 W NETWORK  [ReplicaSetMonitorWatcher] No primary detected for set cluster0-shard-0
2017-06-02T18:59:34.072+0530 W NETWORK  [thread1] No primary detected for set cluster0-shard-0
2017-06-02T18:59:35.546+0530 W NETWORK  [thread1] No primary detected for set cluster0-shard-0
2017-06-02T18:59:36.981+0530 W NETWORK  [thread1] No primary detected for set cluster0-shard-0
2017-06-02T18:59:36.981+0530 E QUERY    [thread1] Error: connect failed to replica set cluster0-shard-0/cluster0-shard-00-00-qvc6m.mongodb.net:27017,cluster0-shard-00-01-qvc6m.mongodb.net:27017,cluster0-shard-00-02-qvc6m.mongodb.net:27017 :
connect@src/mongo/shell/mongo.js:223:14
@(connect):1:6

exception: connect failed

提前致谢。

2 个答案:

答案 0 :(得分:1)

我认为一定是因为主机上的mongo shell版本(3.2.12)与使用的mongo引擎版本不同。您可以尝试使两者的版本相同然后它应该工作。

答案 1 :(得分:-1)

如果您有此错误exception: connect failed 在终结器linux中输入以下命令:

sudo -s

sudo service mongod start