2017-06-02 184 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