Creating Replicas Across Servers I'm having some issues creating a replica set of my MongoDB.

I have server A. Currently, it is setup as a local standalone replica.

rs0:PRIMARY&gt; rs.status()
{
        "set" : "rs0",
        "date" : ISODate("2014-06-02T19:01:23Z"),
        "myState" : 1,
        "members" : [
                {
                        "_id" : 0,
                        "name" : "mongo-server-a:27017",
                        "health" : 1,
                        "state" : 1,
                        "stateStr" : "PRIMARY",
                        "uptime" : 14986,
                        "optime" : Timestamp(1401735683, 1),
                        "optimeDate" : ISODate("2014-06-02T19:01:23Z"),
                        "self" : true
                }
        ],
        "ok" : 1
}


On another server, server B, I would like to replicate my data.

To do this, I run the following:

&gt; rs.status()
{
        "set" : "rs0",
        "date" : ISODate("2014-06-02T19:05:40Z"),
        "myState" : 1,
        "members" : [
                {
                        "_id" : 0,
                        "name" : "mongo-replica:27017",
                        "health" : 1,
                        "state" : 1,
                        "stateStr" : "PRIMARY",
                        "uptime" : 35,
                        "optime" : Timestamp(1401735918, 1),
                        "optimeDate" : ISODate("2014-06-02T19:05:18Z"),
                        "electionTime" : Timestamp(1401735918, 2),
                        "electionDate" : ISODate("2014-06-02T19:05:18Z"),
                        "self" : true
                }
        ],
        "ok" : 1
}
rs0:PRIMARY&gt;


Then I add server A

rs0:PRIMARY&gt; rs.add("10.0.3.40:27017")
{ "ok" : 1 }
rs0:PRIMARY&gt;


Then the log file tells the following:

2014-06-02T19:06:50.201+0000 [conn1] replSet replSetReconfig config object parses ok, 2 members specified
2014-06-02T19:06:50.202+0000 [conn1] replSet replSetReconfig [2]
2014-06-02T19:06:50.202+0000 [conn1] replSet info saving a newer config version to local.system.replset: { _id: "rs0", version: 2, members: [ { _id: 0, host: "mongo-replica:27017" }, { _id: 1, host: "10.0.3.40:27017" } ] }
2014-06-02T19:06:50.202+0000 [conn1] replSet saveConfigLocally done
2014-06-02T19:06:50.202+0000 [conn1] replSet info : additive change to configuration
2014-06-02T19:06:50.202+0000 [conn1] replSet replSetReconfig new config saved locally
2014-06-02T19:06:50.202+0000 [rsHealthPoll] replSet member 10.0.3.40:27017 is up
2014-06-02T19:06:50.202+0000 [rsHealthPoll] replSet member 10.0.3.40:27017 is now in state PRIMARY
2014-06-02T19:06:50.202+0000 [rsMgr] replSet total number of votes is even - add arbiter or give one member an extra vote
2014-06-02T19:06:50.202+0000 [rsMgr] another PRIMARY detected but it should step down since it was elected earlier than me


My problem is I have no clue as to how I should continue.
It seems that I missed the obvious part - adding the replica server should be done on Server A, not the other way around.

What I did was:


Start a clean MongoDB installation on server B with replSet option
On Server A I did rs.add('server-b:27017')
On Server A I controlled the addition of the replica with rs.status()


And it works.