Our replica set config is invalid or we are not a member of it - MongoDB I have started the mongodb server with replica set name 'rs01' enabled on port 27001.

Then started another command window to start the mongo db on the same port.

The status says the 'rs0' is not a member of the replica set.

rs0:OTHER&gt; rs.status()
{
        "operationTime" : Timestamp(1552575009, 1),
        "ok" : 0,
        "errmsg" : "Our replica set config is invalid or we are not a member of it",
        "code" : 93,
        "codeName" : "InvalidReplicaSetConfig",
        "$clusterTime" : {
                "clusterTime" : Timestamp(1552575009, 1),
                "signature" : {
                        "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
                        "keyId" : NumberLong(0)
                }
        }
}


But, if I try to register the member, below error message happens. Any help would be appreciated.

rs0:OTHER&gt; rs.initiate({_id:"rs0",members[{_id:0,host:"localhost:27001"}]})
2019-03-14T22:14:39.840+0530 E QUERY    [js] SyntaxError: missing : after property id @(shell):1:30
rs0:OTHER&gt; rsconf={ _id:"rs0", members: [ { _id: 0,host:"localhost:27001"}]}
{
        "_id" : "rs0",
        "members" : [
                {
                        "_id" : 0,
                        "host" : "localhost:27001"
                }
        ]
}
rs0:OTHER&gt; rs.initiate(rsconf)
{
        "operationTime" : Timestamp(1552575009, 1),
        "ok" : 0,
        "errmsg" : "already initialized",
        "code" : 23,
        "codeName" : "AlreadyInitialized",
        "$clusterTime" : {
                "clusterTime" : Timestamp(1552575009, 1),
                "signature" : {
                        "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
                        "keyId" : NumberLong(0)
                }
        }
}


mongodb
As per error it seems like you have not configured properly the replica set. How to setup MongoDB Replica Set , you find here.

For example I am writing the steps here to setup MongoDB Replica Set

1) Start a mongod instance.

2) Start another mongod instance.

3) Start Replication.

After launcing the all mongod node instances, connect to any one node and start the mongo shell then type in command prompt


  rs.initiate()


For example

Now the mongo shell prompt would be changed to yournodeinstancename:PRIMARY>

You may also check the status using rs.status() method.


  rs.status()


for more info about rs.status() see the MongoDB documentation here and here

4) Add a MongoDB instance to the Replica Set.


  rs.add();


5) Check the Status.

You may check the status of the Replica Set by running the following command


  rs.status();


6) Getting an overview of the replica set and if current node is master


  rs.isMaster()


For further your ref here , here , here