简体   繁体   中英

How to specify a config file for Mongod process

When running mongod I receive the non-critical error

[HostnameCanonicalizationWorker] Failed to obtain address information for hostname flimflamjims-MacBook-Pro.local: nodename nor servname provided, or not known

This problem is well documented on stack overflow and solutions typically suggest editing /etc/hosts to specify an address of 127.0.0.1 . This does indeed resolve the issue however as an alternative I would like to specify a config file.

As per Homebrew's instructions I have tried running mongod --config /usr/local/etc/mongod.conf . After running the command the process hangs with no logs being printed to the terminal.

mongod.conf was created automatically by Homebrew and its contents are:

systemLog:
  destination: file
  path: /usr/local/var/log/mongodb/mongo.log
  logAppend: true
storage:
  dbPath: /usr/local/var/mongodb
net:
  bindIp: 127.0.0.1

When I remove mongod.conf from /usr/local/var/log/mongodb/ and again run mongod --config /usr/local/etc/mongod.conf I receive the error:

Error reading config file: No such file or directory
try 'mongod --help' for more information`

So it seems that mongod.conf is at least being accessed.

Any help would be much appreciated.

With your configuration the logs will go to the log file mentioned in the systemLog.path . If you remove only the systemLog.path from the config file, it will thrown error as it won't be able to find the path for log file. Because systemLog.destination says log to file , you must specify systemLog.path as well. In case, you want logs be sent to stdout then you need to remove systemLog.destination and systemLog.path both.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM