mongodb replica set with multiple primaries and pingMS=0
mongodb, replication
Solution
You mentioned that you run `rs.initiate()` on both servers. This should only be done on one.
I suggest you start from scratch, by deleting the dbpath directory for each node (backup data before if the db was not empty). Then, start all mongod processes, log into one of them, then call
- `rs.initiate()`
- `rs.add(<other node 1>)`
The other node gets the replica set configuration through the first one automatically. Repeat `rs.add() for each additional node you want to add.
Problem
I am trying to set a replica set with two nodes: Node0 and Node1. From the Node0 I initialized a replica set named "rs0" and added Node1 to it. The problem is that it is added as a primary node instead of a secondary node and the final result is a replica set with two primary nodes. This is the result of executing the `rs.status()` command from Node0 ``` "set" : "rs0", "date" : ISODate("2012-10-23T21:03:37Z"), "myState" : 1, "members" : [ { "_id" : 0, "name" : "Node0:27017", "health" : 1, "state" : 1, "stateStr" : "PRIMARY", "uptime" : 61185, "optime" : Timestamp(1350967947000, 1), "optimeDate" : ISODate("2012-10-23T04:52:27Z"), "self" : true }, { "_id" : 1, "name" : "Node1:27017", "health" : 1, "state" : 1, "stateStr" : "PRIMARY", "uptime" : 58270, "optime" : Timestamp(1350956423000, 1), "optimeDate" : ISODate("2012-10-23T01:40:23Z"), "lastHeartbeat" : ISODate("2012-10-23T21:03:37Z"), "pingMs" : 0 } ], ``` If I execute the same command from Node1 the only node listed is itself. Note that the pingMs is 0. Trying to add a third node or an arbiter give similar results: each one is added as primary and the pingMS is always 0.