MongoDB Replicaset cookbook/Recipe.

164 views
Skip to first unread message

Amit Agarwal

unread,
Oct 3, 2016, 11:40:13 PM10/3/16
to mongodb-user
Hi,

I am planning to create 3 node mongodb Replicaset using cookbook/recipe.
I tried couple of option but i am not able to do so.

1) I created first node with installation of mongodb with ReplicatSetName in /etc/mongod.comf and did the rs.initiate(), so it became primary.
2) I used the same recipe to create 2 secondary but once those have rs.initiate() executed they can not be the secondary on replicaset and i get following error.

api_umbrella:PRIMARY> rs.add("pocmysql002iad.io.askjeeves.info:14001");

{

"ok" : 0,

"errmsg" : "Quorum check failed because not enough voting nodes responded; required 2 but only the following 1 voting nodes responded: pocmysql001iad.io.askjeeves.info:14001; the following nodes did not respond affirmatively: pocmysql002iad.io.askjeeves.info:14001 failed with Received heartbeat from member with the same member ID as ourself: 0",

"code" : 74

}


When i tried to debug this issue got to know secondary became kind of primary after firing rs.initiate() and both of them have _id=0 so they can not be the part of same replicates and solution was to stop mongo clean the data directory and restart the mongod so it will behave as new instance and then do the rs.add on primary for this node.


I am looking for some kind of cookbook/recipe where it can create the primary and 2 secondary without any manual work, is it possible or do we have such kind of cookbook/recipe?


Thanks,

Amit


Amit Agarwal

unread,
Oct 4, 2016, 12:07:28 AM10/4/16
to mongodb-user
Probably i will try the below to check, this link looks good to me


Thanks,
Amit

Lungang Fang

unread,
Oct 4, 2016, 11:51:26 PM10/4/16
to mongodb-user

Hi Amit,

1) I created first node with installation of mongodb with ReplicatSetName in /etc/mongod.comf and did the rs.initiate(), so it became primary.

2) I used the same recipe to create 2 secondary but once those have rs.initiate() executed they can not be the secondary on replicaset and i get following error.

You ran rs.initiate() three times (on for each host). You should have run the command only once per replica set. Please refer to Deploy a Replica Set for more details.

Regards,
Lungang

Amit Agarwal

unread,
Oct 5, 2016, 3:00:48 PM10/5/16
to mongodb-user
Thanks Lungang,

I go to know the same and able to resolve the issue and able to automate the replicates installation using one primary and 2 secondaryand some automation of user/database/collection creation.

Thanks,
Amit
Reply all
Reply to author
Forward
0 new messages