How to specify the mongodb.config file in OSX?

2,502 views
Skip to first unread message

Anil Kemisetti

unread,
May 29, 2016, 2:01:47 AM5/29/16
to mongodb-user
How to specify the mongodb.config file in OSX?

pooja...@10gen.com

unread,
Jun 3, 2016, 6:37:23 AM6/3/16
to mongodb-user

Hi Anil,

MongoDB Configuration Files use YAML format and it is independent of the platform you are using.

Please note that YAML format works on MongoDB 2.6 and above.

Below is the sample configuration file that I tried on my system which runs mongod instance on port 27017 on wiredTiger storage engine:

mongod --config /etc/mongod.conf

# SystemLog sets the destination to which all log output has to be sent
# Set the path of the log file
# Appends new entries to the end of the existing log file
systemLog:
   destination: file
   path: "/var/log/mongodb/mongod.log"
   logAppend: true

# Storage sets the directory where mongod instance stores its data
# Enables journaling
# and runs on Wired Tiger storage engine 
storage:
    dbPath: "/data/db/"
   journal:
      enabled: true
   engine:
      wiredTiger 

# Net sets the IP address and TCP port for mongod instance 
net:
   bindIp: 127.0.0.1
   port: 27017

# fork and run in background
# location of pid file 
processManagement:
   fork: true
   pidFilePath: "/var/run/mongodb/mongod.pid"

You can create it accordingly for your system.

Above config file will be same as working with command line options:

mongod —port 27017 —bind_ip 127.0.0.1 —dbpath /data/db —journal —storageEngine wiredTiger —logpath /var/log/mongodb/mongod.log —logappend —fork

Please note that :

1) The above configuration file sample will fork the mongod process into the background, and the mongod logs will be accessible from /var/log/mongodb/mongod.log as specified in systemLog.path setting.

2) These settings require writing data or files to /var/log, /var/run, /data/db . Make sure you are authorised to have write permissions to do so.

Regards,

Pooja

Reply all
Reply to author
Forward
0 new messages