2017-06-02 181 views
0

我创建了一个mongodb集群并尝试通过mongo shell进行连接,但出现错误。我在做什么不对?Mongodb连接失败

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 : 
[email protected]/mongo/shell/mongo.js:223:14 
@(connect):1:6 

exception: connect failed 

在此先感谢。

+0

那么原因是错误'没有主的一套cluster0-碎片-0'检测。所以复制品可能处于选举状态。你需要看看,看看是什么造成了**这个特殊问题。 –

+0

顺便说一句。关于为什么副本集没有主节点的新问题是StackOverflow的“脱离主题”,因为它是关于配置数据库的。 [dba.stackexchange.com](https://dba.stackexchange.com)是你可以问的地方。 –

+0

@ Neil Lunn:感谢您的建议 – rahulb

回答

-1

,如果你有这样的错误exception: connect failed 键入以下命令在Linux的终结者:

sudo -s 

sudo service mongod start 
+0

感谢Michel,但我正在使用cloud.mongodb群集 – rahulb

+0

像这样:[link](https://stackoverflow.com/questions/38237663/mongo-atlas-connection-authentication-failed -with定制的数据库?answertab =活性#制表顶部) – Michael1