0
votes

while trying to create a replica set of db i get an error that dbpath /data/db does not exist.i am currently running mongo in docker as root. version(mongo) 2.6..10. i start using the service mongodb start command after which the mongo shell appears.log below

root@5936a72e744f:/dbex# mongod --replSet myDevReplSet

2017-07-31T05:13:30.946+0000 [initandlisten] MongoDB starting : pid=679 port=27017 dbpath=/data/db 64-bit host=5936a72e744f 2017-07-31T05:13:30.947+0000 [initandlisten] db version v2.6.10 2017-07-31T05:13:30.947+0000 [initandlisten] git version: nogitversion 2017-07-31T05:13:30.947+0000 [initandlisten] OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016 2017-07-31T05:13:30.947+0000 [initandlisten] build info: Linux lgw01-12 3.19.0-25-generic #26~14.04.1-Ubuntu SMP Fri Jul 24 21:16:20 UTC 2015 x86_64 BOOST_LIB_VERSION=1_58 2017-07-31T05:13:30.948+0000 [initandlisten] allocator: tcmalloc 2017-07-31T05:13:30.949+0000 [initandlisten] options: { replication: { replSet: "myDevReplSet" } } 2017-07-31T05:13:30.950+0000 [initandlisten] exception in initAndListen: 10296


ERROR: dbpath (/data/db) does not exist. Create this directory or give existing directory in --dbpath. See http://dochub.mongodb.org/core/startingandstoppingmongo


, terminating

2
So what is not descriptive about the error? There is actually even a link to documentation that comes with it, so how more descriptive does it need to get?Neil Lunn
True.but in the documentation it says how to change default path of data.i am able to start mongo shell just fine.i do not get a connection error when i type mongo.....but when i create a replication set it throws error that data path does not exist.Nikhil Dhara
Because you are "starting a new instance". And unlike the one that is already running it has no such configuration that tells it where to create it's data files or any other options. Perhaps you actually should have read the manual before you started putting the bike together. Deploy a Replica Set for Testing and DevelopmentNeil Lunn
Of course if all you really wanted to do was "enable a replica set" on your existsing instance so there is an "oplog" that can be followed by a tailable cursor, then you need but add: replSetName: myDevReplSet to your existing config, likely at /etc/mongod.confNeil Lunn

2 Answers

0
votes

If you have a look into your /etc/mongod.conf you will see

storage:
 dbPath: /data/db

So create directory /data/db and ensure proper permission.

0
votes

ok guys..sometimes the data is stored in var/lib/mongod..so to start a replica set use mongod --port 27017 --dbpath "/var/lib/mongodb" --replSet rs0 so check appropriate location and change dbpath location