I have database which is set up in data folder of mongodb. For accessing this database I usually run the below command

    mongod --dbpath "C:\program files\mongodb\data" --port 27017

Now I am trying to replicate database. For creating Primary database I run command

    mongod --port 27017 --dbpath "C:\Program Files\MongoDB\data" --replSet replicaSetMGL --smallfiles --oplogSize 128

I have created two empty folders in mongodb folder as replicaSet1 and replicaSet2. Now for creating replica set for port no. 27018, I executed below command in another terminal.

    mongod --port 27018 --dbpath "C:\Program Files\MongoDB\replicaSet1" --replSet replicaSetMGL --smallfiles --oplogSize 128

This is not working (throwing error):

C:\Users\well come>mongod --port 27018 --dbpath "C:\Program Files\MongoDB\replic
aSet1" --replSet replicaSetMGL --smallfiles --oplogSize 128
2017-06-12T17:25:33.164+0530 I CONTROL  [initandlisten] MongoDB starting : pid=6
936 port=27018 dbpath=C:\Program Files\MongoDB\replicaSet1 64-bit host=hp
2017-06-12T17:25:33.164+0530 I CONTROL  [initandlisten] targetMinOS: Windows 7/W
indows Server 2008 R2
2017-06-12T17:25:33.165+0530 I CONTROL  [initandlisten] db version v3.4.4
2017-06-12T17:25:33.165+0530 I CONTROL  [initandlisten] git version: 88839051587
2017-06-12T17:25:33.165+0530 I CONTROL  [initandlisten] OpenSSL version: OpenSSL
 1.0.1u-fips  22 Sep 2016
2017-06-12T17:25:33.165+0530 I CONTROL  [initandlisten] allocator: tcmalloc
2017-06-12T17:25:33.165+0530 I CONTROL  [initandlisten] modules: none
2017-06-12T17:25:33.165+0530 I CONTROL  [initandlisten] build environment:
2017-06-12T17:25:33.165+0530 I CONTROL  [initandlisten]     distmod: 2008plus-ss
2017-06-12T17:25:33.165+0530 I CONTROL  [initandlisten]     distarch: x86_64
2017-06-12T17:25:33.165+0530 I CONTROL  [initandlisten]     target_arch: x86_64
2017-06-12T17:25:33.165+0530 I CONTROL  [initandlisten] options: { net: { port:
27018 }, replication: { oplogSizeMB: 128, replSet: "replicaSetMGL" }, storage: {
 dbPath: "C:\Program Files\MongoDB\replicaSet1", mmapv1: { smallFiles: true } }
2017-06-12T17:25:33.166+0530 I -        [initandlisten] Detected data files in C
:\Program Files\MongoDB\replicaSet1 created by the 'wiredTiger' storage engine,
so setting the active storage engine to 'wiredTiger'.
2017-06-12T17:25:33.167+0530 I STORAGE  [initandlisten] wiredtiger_open config:
2017-06-12T17:25:34.184+0530 W STORAGE  [initandlisten] Detected configuration f
or non-active storage engine mmapv1 when current storage engine is wiredTiger
2017-06-12T17:25:34.185+0530 I CONTROL  [initandlisten]
2017-06-12T17:25:34.185+0530 I CONTROL  [initandlisten] ** WARNING: Access contr
ol is not enabled for the database.
2017-06-12T17:25:34.185+0530 I CONTROL  [initandlisten] **          Read and wri
te access to data and configuration is unrestricted.
2017-06-12T17:25:34.186+0530 I CONTROL  [initandlisten]
2017-06-12T17:25:34.308+0530 I FTDC     [initandlisten] Initializing full-time d
iagnostic data capture with directory 'C:/Program Files/MongoDB/replicaSet1/diag
2017-06-12T17:25:34.447+0530 I REPL     [initandlisten] Did not find local voted
 for document at startup.
2017-06-12T17:25:34.448+0530 I REPL     [initandlisten] Did not find local repli
ca set configuration document at startup;  NoMatchingDocument: Did not find repl
ica set configuration document in local.system.replset
2017-06-12T17:25:34.451+0530 I NETWORK  [thread1] waiting for connections on por
t 27018
  • Can you share us some more information on the error. Perhaps from a logfile.
    – Marco
    Jun 12 '17 at 11:29
  • where is log file. I am very new to mongo db
    – Nida
    Jun 12 '17 at 11:30
  • Actually I don't know where log file is at windows. But if you give parameter --logpath C:\program files\mongodb\mongod.log mongod will write it's log to that file.
    – JJussi
    Jun 12 '17 at 11:55
  • have updated my question
    – Nida
    Jun 12 '17 at 12:02
  • While doing replication process, do I have to create database folders of same database. I mean in the above example replicaSet1 and replicaSet2 should contain same database setup/configuration/content like in data folder "C:\Program Files\MongoDB\data" or those two folders should be empty
    – Nida
    Jun 12 '17 at 12:34

OK.. It's look like that you have managed to mix things. So, you have working mongodb at "C:\program files\mongodb\data" and now you want to convert that mongodb to three node replica set?!? First after you have start that mongod process with --replSet replicaSetMGL parameter. Log in (with mongo -program) and give command rs.initiate().

Then remove all files from directory "C:\Program Files\MongoDB\replicaSet1" (because I can see from log file that there is mixed db files; mmapv1 and wiredTiger). Start that node with those parameters.

Go back to first nodes mongo and give command rs.add("localhost:27018") to add that node to replica set. With command rs.status() you can see your replica sets status.

Repeat those steps to add third node to RS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.