Kostas
Kostas

Reputation: 8595

Sane defaults for MongoDB on OSX?

I installed MongoDB and have set it up like so:

DB path: /data/db

System-wide config file: /usr/local/mongodb/mongod.conf

launchctl plist: /Library/LaunchDaemons/org.mongodb.mongod.plist

Log: /var/log/mongodb/output.log

Binary: /usr/local/bin/mongod

Are there any defaults on all these paths?

I am looking for defaults that are in line with MongoDB and with OS X. References for the answers would be lovely. :-)

Upvotes: 12

Views: 7845

Answers (3)

rohit kotian
rohit kotian

Reputation: 130

If you have already installed mongodb, like I did but have an older version simply run

brew upgrade mongodb

This should update your mongodb to the latest available package.

Upvotes: 0

Fabian
Fabian

Reputation: 2458

On Mac I'd recommend you install mongo with homebrew which installs all programs into /usr/local. You will have the default paths:

  • config: /usr/local/etc/mongod.conf
  • data dir: /usr/local/var/mongodb
  • log: /usr/local/var/log/mongodb/mongo.log
  • plist file: /usr/local/opt/mongodb/homebrew.mxcl.mongodb.plist

To install: brew install mongodb

to restart mongo you do:

launchctl stop homebrew.mxcl.mongodb
launchctl start homebrew.mxcl.mongodb

Upvotes: 13

dcrosta
dcrosta

Reputation: 26258

The only one of these values for which MongoDB has a default is the data path, which is /data/db. MongoDB by itself does not ship with a config file, nor does it log to a file by default, and the choice of where to install the binaries is entirely up to you.

For my own installation, I use the following:

  • config: /usr/local/mongo/mongod.conf
  • dbpath: /usr/local/mongo/data
  • logging: /private/var/etc/mongodb.log (this then shows up automatically in the Console app)
  • launchctl: /Library/LaunchDaemons/org.mongodb.mongod.plist

The only other note I'd make is that it is probably worth raising the hard and soft limits for NumberOfFiles, as MongoDB uses this limit to determine the maximum number of connections that it will accept. On some versions, OS X defaults this number to 256, which means you can have a maximum of around 205 connections, which may be too low even for a development environment. I have the following in my launchctl plist:

<key>HardResourceLimits</key>
<dict>
  <key>NumberOfFiles</key>
  <integer>1024</integer>
</dict>
<key>SoftResourceLimits</key>
<dict>
  <key>NumberOfFiles</key>
  <integer>1024</integer>
</dict>

Upvotes: 17

Related Questions