Where does gentoo store mongodb.conf? Want to change dbpath location

gentoomongodb

This may seem like an innocent enough question, but I can't for the life of me figure out where gentoo puts mongodb.conf after installation from portage. The documentation says to look under /etc/, but it's not there. All I need to do is modify the dbpath parameter have it store under /data/db, but it's currently using /var/lib/mongodb (which is odd since it should default to /data/db)

The closest thing I've seen is /etc/init.d/mongodb, which has the following configuration:

start-stop-daemon --background --start --make-pidfile \
            --pidfile ${MONGODB_RUN:-/var/run/mongodb}/${SVCNAME}.pid \
            ${USEROPT} ${MONGODB_USER:-mongodb} \
            --exec ${MONGODB_EXEC:-/usr/bin/mongod} \
            -- \
            --port ${MONGODB_PORT:-27017} \
            --dbpath ${MONGODB_DATA:-/data/db} \
             #--dbpath ${MONGODB_DATA:-/var/lib/mongodb} \
            --unixSocketPrefix ${MONGODB_RUN:-/var/run/mongodb} \
            --logappend --logpath /var/log/mongodb/${SVCNAME}.log \
            ${MONGODB_OPTIONS}
    eend $?
}

As you can see, I change where dbpath should point to. However, running a ps aux | grep mongod results in the following:

mongodb  21044  0.2  2.1 189300 22032 ?        Ssl  May01   0:01 /usr/bin/mongod --port 27017 --dbpath /var/lib/mongodb --unixSocketPrefix /var/run/mongodb --logappend --logpath /var/log/mongodb/mongodb.log --bind_ip 127.0.0.1 --journal

The other file I have is /etc/conf.d/mongodb, which contains the following:

# Mongodb essentials
MONGODB_EXEC="/usr/bin/mongod"
MONGODB_RUN="/var/run/mongodb"
MONGODB_DATA="/var/lib/mongodb"
MONGODB_USER="mongodb"

# Listen to specified IP, comment this to listen to all
MONGODB_IP="127.0.0.1"

# Listen to specified port
MONGODB_PORT="27017"

# Set extra options here, such as disabling the admin web server
MONGODB_OPTIONS="--journal"

It someone knows where to properly set the dbpath parameter, I'd really appreciate it.

Best Answer

Gentoo's portage downloads the source code and then compiles the binaries locally, you may want to look to where portage caches the downloads, presumably in /usr/portage/distfiles/mongodb* for any files that are included in the source code tarball.

It looks like instead of changing the init script, you should be making the change to the config file.

You mentioned that you have a /etc/conf.d/mongodb file - and I can see from there that a variable is being set, named MONGODB_DATA - if you set that value to /data/db, then the variable in the init script should fill correctly upon startup.

For reference, this line:

--dbpath ${MONGODB_DATA:-/data/db} \

means that the init script will try to set the --dbpath command line option to whatever the contents of MONGODB_DATA are, and if it is nothing, then use the path specified, as denoted. Something like this:

${A_CONFIG_FILE_OPTION:-/a/default/when/config/does/not/set/the/option}

Please note - this is not something that is mongodb related, or really even gentoo packaging, rather gentoo init script and configuration file.

A more comprehensive guide on mongodb configuration files (not gentoo's config file!) can be found here: http://www.mongodb.org/display/DOCS/File+Based+Configuration