Having trouble initializing a replica set

6,344 views
Skip to first unread message

Alen Teplitsky

unread,
Sep 3, 2015, 6:15:18 PM9/3/15
to mongodb-user
I'm new to Mongo, been doing MS SQL for years.

set up two instances on vmware on Windows 2012 to run as a service with a configuration file and the same replica set name. both start up as primaries. when i try to add the other one as a replica have a primary and secondary I get the following error: I can ping both nodes from each other. i'm trying to follow the tutorials in the admin guide and the replication guide but it's not working. am i missing something?


          
}
chat_dr:PRIMARY> rs.add('mymongoinstance')
{
        "ok" : 0,
        "errmsg" : "Quorum check failed because not enough voting nodes responde
d; required 2 but only the following 1 voting nodes responded: mymongoinstance:27017;
 the following nodes did not respond affirmatively: mymongoinstance2:27017 failed with
 Received heartbeat from member with the same member ID as ourself: 0",
        "code" : 74
}
chat_dr:PRIMARY>

Wan.Bachtiar

unread,
Sep 13, 2015, 9:00:11 PM9/13/15
to mongodb-user
Hi Alen,

You received the error message because both nodes (the node you are connected to and the one being added) have different replica set configs.

It is likely that rs.initiate() was executed on both of the nodes. 
The rs.initiate() command generates a new replica set configuration and should only be run once per replica set on the initial primary node. 
Once the initial replica configuration has been created, additional nodes can be added using rs.add() or rs.reconfig(). See deploy replica set for more info.

In order to fix your replica setup, choose one of the nodex that is intended to be the secondary:

1. Shut down the mongod process.
2. Remove the dbpath files associated with the process.
3. Restart mongod with the same parameters as before, i.e. --replSet, etc.
4. Run rs.add() command on the primary node.


Note: In order to allow for automatic failover, your replica set configuration should have at least 3 nodes. 
See Replica Set Architecture for more info.


Kind Regards,
Wan.

ohad...@healthy.io

unread,
Apr 27, 2016, 7:40:21 AM4/27/16
to mongodb-user
"Remove the dbpath files associated with the process." 
what files are those exactly ?

ls -ltra /var/lib/mongodb
-rw-r--r--  1 mongodb mongodb    21 Apr 26 14:36 WiredTiger.lock
-rw-r--r--  1 mongodb mongodb    49 Apr 26 14:36 WiredTiger
-rw-r--r--  1 mongodb mongodb    95 Apr 26 14:36 storage.bson
drwxr-xr-x 23 root    root     4096 Apr 26 14:36 ..
-rw-r--r--  1 mongodb mongodb 16384 Apr 26 15:25 index-6--6639998270022824679.wt
-rw-r--r--  1 mongodb mongodb 16384 Apr 26 15:25 index-4--6639998270022824679.wt
-rw-r--r--  1 mongodb mongodb 16384 Apr 26 15:25 index-1--6639998270022824679.wt
drwxr-xr-x  2 mongodb mongodb  4096 Apr 27 10:44 journal
drwxr-xr-x  2 mongodb mongodb  4096 Apr 27 10:46 diagnostic.data
-rw-r--r--  1 mongodb mongodb   924 Apr 27 10:46 WiredTiger.turtle
drwxr-xr-x  4 mongodb mongodb  4096 Apr 27 10:46 .
-rw-r--r--  1 mongodb mongodb 61440 Apr 27 10:46 WiredTiger.wt
-rw-r--r--  1 mongodb mongodb  4096 Apr 27 10:46 WiredTigerLAS.wt
-rw-r--r--  1 mongodb mongodb 36864 Apr 27 10:46 sizeStorer.wt
-rw-r--r--  1 mongodb mongodb 36864 Apr 27 10:46 _mdb_catalog.wt
-rw-r--r--  1 mongodb mongodb 36864 Apr 27 10:46 index-1--677236015540488615.wt
-rw-r--r--  1 mongodb mongodb 32768 Apr 27 10:46 collection-5--6639998270022824679.wt
-rw-r--r--  1 mongodb mongodb 16384 Apr 27 10:46 collection-3--6639998270022824679.wt
-rw-r--r--  1 mongodb mongodb 32768 Apr 27 10:46 collection-2--6639998270022824679.wt
-rw-r--r--  1 mongodb mongodb 36864 Apr 27 10:46 collection-0--677236015540488615.wt
-rw-r--r--  1 mongodb mongodb 16384 Apr 27 10:46 collection-0--6639998270022824679.wt
-rw-r--r--  1 mongodb mongodb     0 Apr 27 10:46 mongod.lock

Jeff Sherard

unread,
Apr 27, 2016, 6:43:28 PM4/27/16
to mongodb-user
You can remove all of those files.  It would be helpful to see your command line options or your mongod.conf file just to confirm.  From your command below I assume your data directory is set to:

--dbpath /var/lib/mongodb

or your mongod.conf file has this in it:

storage:

   dbPath:  /var/lib/mongodb

(Configuration File Options)


I do see a mongod.lock in your directory indicating that mongod is/was probably still running at the time your ls command.  You should probably stop the process cleanly before you delete data files.


Understand deleting file in the --dbpath will delete *all* data in your database.  Which will then be synced back again from the primary when you add it to the replica set.


Cheers,


Jeff Sherard

MongoDB Master

Reply all
Reply to author
Forward
0 new messages