-1

I am a newbie so please bear with me.
I have used this command $ sudo mongod --config /etc/mongod2.confin terminal to start a mongodb service instance. In another terminal I ran $ mongo --port XXXX where XXXX is the port number I configure in mongod.conf file. rs.initiate() in mongo shell is giving the error "errmsg" : "assertion src/mongo/db/repl/replset_commands.cpp:275", "code" : 8 why ?

edit: **mongodb version v3.2.12**
mongod2.conf file consist of:

# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# Where and how to store data.
storage: dbPath: /var/lib/mongodb2 journal: enabled: true
# engine:
# mmapv1:
# wiredTiger:
# where to write logging data.
systemLog: destination: file logAppend: true path: /var/log/mongodb2/mongod.log # network interfaces
net: port: 27019 bindIp: 127.0.0.1
processManagement: fork: true #security:
#operationProfiling:
replication: replSetName: myDevReplSet

  • Hi Prakhar Gajbhiye, and welcome to the site. It's hard to tell what might be going wrong, so could you provide some more info? What version of MongoDB are you running, and can you show us what's in that mongod2.conf file? – Vince Bowdren Apr 18 '17 at 14:02
  • @VinceBowdren I am able to use replica set now. I created multiple copy of `mongod.conf` naming `mongod1.conf` , `mongod2.conf` and so on in which I specified `dbpath` as `/var/lib/mongodb1`, `/var/lib/mongodb2` and so on _(as you can see in the edit section of mongod2.conf)_ and it works fine. Apology if there is something naive. – Prakhar Gajbhiye Apr 19 '17 at 14:59
  • Glad to hear that you solved your problem. The best thing to do here is to [post your own answer](http://stackoverflow.com/help/self-answer), and then [accept](http://blog.stackoverflow.com/2009/01/accept-your-own-answers/) it - that will take your question off the unanswered list. – Vince Bowdren Apr 19 '17 at 15:16

1 Answers1

0

I created multiple copy of mongod.conf naming mongod1.conf , mongod2.conf and so on in which I specified dbpath as /var/lib/mongodb1, /var/lib/mongodb2 and so on (as you can see in the edit section of mongod2.conf) and it works fine.If there doesn't exist folder /var/lib/mongodb1 then it automatically creates it or you should just create the folder. Now you can use replica set.