0

Tried to initiate a replica set in MongoDB but failed.

My mongod configuration file is as follows:

dbpath=C:\data\db
logpath=C:\data\log\mongo.log
storageEngine=mmapv1

After starting mongod with the command:

mongod --config "C:\data\mongo.conf" --replSet "rs0"

I went to mongo and typed

rs.initiate()

and got the error of "no configuration file specified" (code 8). Also tried to clearly instruct mongodb using

cfg = {"_id": "rs0", "version":1, "members":[{"_id":0,"host":"127.0.0.1:27017"}]}

rs.initiate(cfg)

However, the result is still the same (code 8).

Dig deeper into the log file, I found this

replSetInitiate failed to store config document or create the oplog; UnknownError: assertion C:\data\mci\7751c6064ad5f370b9aea0db0164a05e\src\src\mongo/util/concurrency/rwlock.h:204
2017-08-26T18:36:41.760+0700 I COMMAND  [conn1] command local.oplog.rs command: replSetInitiate { replSetInitiate: { _id: "rs0", version: 1.0, members: [ { _id: 0.0, host: "127.0.0.1:27017" } ] } } keyUpdates:0 writeConflicts:0 numYields:0 reslen:143 locks:{ Global: { acquireCount: { r: 1, W: 1 } }, MMAPV1Journal: { acquireCount: { w: 2 } }, Metadata: { acquireCount: { W: 6 } } } protocol:op_command 4782ms

Any hint for me please? Thank you a ton.

Hoai
  • 11
  • 2
  • You're using the old 2.4 config file syntax, you may want to use the YAML config file syntax instead that was introduced in 2.6... Does the directory referenced in dbpath exist and does the user running mongod have access to it? – Timo Geusch Aug 26 '17 at 17:18
  • Hi, thanks for your feedback. I see that it's an old-fashion config file for mongod but it still works on this laptop and my another computer. The problem is somehow on the rs thingy. (I do not encounter this rs problem on my PC. That's weird, I don't know why.) FYI, the dbpath exists and I am having dbs in that directory. – Hoai Aug 26 '17 at 17:21
  • Aggrrr, finally figured out that I installed a 32bit version on Windows 64bit so it cannot initiate replication sets. Installed a fresh 64bit, worked like a charm. So weird. – Hoai Sep 12 '17 at 02:56

0 Answers0