2

I have created a MongoDB docker container, with a replica set, using this command:

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

The container starts running.

I then try to initiate the replica set, using this command:

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
}

But it gives the error message "already initialized".

When I check the health of the replica set with the rs.status() command

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
}

It says the replica set config is invalid.

Vince Bowdren
  • 8,326
  • 3
  • 31
  • 56

1 Answers1

0

It looks you didn't specify any replica set configuration.

The 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" }
      ]
   }
)
CloudStax
  • 649
  • 5
  • 6