2016-09-06 66 views
2

我創建了一個MongoDB的泊塢窗容器中,加一個replica set,使用這個命令:錯誤初始化MongoDB的複製品泊塢容器

docker run -d --name mongo -v /data/db:/data/db mongo --replSet name 

容器開始運行。

我再嘗試initiate副本集,使用這個命令:

rs.initiate() 
{ 
    "info2" : "no configuration specified. Using a default configuration for the set", 
    "me" : "fa07bcdd8591:27017", 
    "info" : "try querying local.system.replset to see current configuration", 
    "ok" : 0, 
    "errmsg" : "already initialized", 
    "code" : 23 
} 

但它給「已初始化」的錯誤消息。

當我檢查與rs.status()命令

rs.status() 
{ 
    "state" : 10, 
    "stateStr" : "REMOVED", 
    "uptime" : 102, 
    "optime" : { 
     "ts" : Timestamp(1472680081, 1), 
     "t" : NumberLong(77) 
    }, 
    "optimeDate" : ISODate("2016-08-31T21:48:01Z"), 
    "ok" : 0, 
    "errmsg" : "Our replica set config is invalid or we are not a member of it", 
    "code" : 93 
} 

設置副本的健康報告說,副本集的配置是無效的。

+0

你有沒有指定的任何副本集的配置呢? –

+0

你有沒有想過這個sudhakar?我一直有同樣的問題.. –

回答

0

看起來你沒有指定任何副本集配置。

replica set initiate example

rs.initiate(
 
    { 
 
     _id: "myReplSet", 
 
     version: 1, 
 
     members: [ 
 
     { _id: 0, host : "mongodb0.example.net:27017" }, 
 
     { _id: 1, host : "mongodb1.example.net:27017" }, 
 
     { _id: 2, host : "mongodb2.example.net:27017" } 
 
     ] 
 
    } 
 
)