Environment:
- 3.4.9-gentoo
- mongodb (OpenRC) 0.9.8.4 (Gentoo Linux)
if I use mongod daemon to start mongodb,the default db path is /data/db
But if I use /etc/init.d/mongodb script to start mongodb, the /etc/conf.d/mongdb write the default db path is /var/lib/mongodb,
I am puzzled that why the db path is not the same?
The default dbpath if you start MongoDB without a configuration file is
/data/db.Your init script (
/etc/init.d/mongodb) is starting mongodb with the--config(aka-f) option and a path to a config file to use (/etc/conf.d/mongodb).If you look at the contents of your
/etc/config.mongodbconfiguration file, you should see thedbpathsetting with the/var/lib/mongodbdirectory path that overrides the default. In this case the maintainer of your MongoDB install package has decided that/var/libis the most appropriate default directory for data files. Generally this is done to be more consistent with the default locations used by other packages in your distribution; the MongoDB data files can live anywhere on your filesystem.You can also check for any settings that have been overridden by your configuration file in the
mongoshell using:The output will be similar to: