Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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

share|improve this answer
    
Excellent- all I had to do was modify /etc/conf.d/mongodb. I don't know how I completely missed the MONGODB_DATA variable. Thanks for your explanation as well! –  thomascirca May 3 '12 at 19:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.