Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"dirname: missing operand" error while starting mongod service

Tags:

mongodb

I recently installed mongo 2.6.5 version on our Red Hat enterprise Linux server. Everything was working fine, until I decided to make a change in /etc/mongod.conf file. I noticed that from version 2.6 above mongo supports conf file in YAML fomat. (the reason I wanted to make a change was, I wanted to enable the authentication on mongo instance)

http://docs.mongodb.org/manual/reference/configuration-options/

I changed my config file which used to look like below (I am adding only a portion of the config):

# mongod.conf

#where to log
logpath=/var/log/mongodb/mongod.log

logappend=true

# fork and run in background
fork=true

#port=27017

dbpath=/var/lib/mongo

# location of pidfile
pidfilepath=/var/run/mongodb/mongod.pid

My changed file mongod.conf file looks like below now:

systemLog:
    destination: file
    path: "/var/log/mongodb/mongodb.log"
    logAppend: true

storage:
    dbPath: "/var/lib/mongo"
    journal:
        enabled: true

processManagement:
    pidFilePath: "/var/run/mongodb/mongod.pid"
    fork: true

security:
    authorization: true![enter image description here][1]

Now when I try to run the mongod service it is giving me error (see attached picture): dirname: missing operand Try 'dirname --help' for more information Starting mongod: [FAILED]

When I revert my mongod.conf file to previous version, then the service runs fine. Do I need to change something in my mongo installation to make it use YAML format of config?

like image 645
Deepak Avatar asked Dec 20 '22 10:12

Deepak


2 Answers

A few things:

  1. make sure that you define a PID file location in /etc/mongod.conf

    pidfilepath=/var/run/mongodb/mongod.pid
    
  2. change the "daemon" line in /etc/init.d/mongod to explicitly use the PID file

    daemon --user "$MONGO_USER" --check "$mongod" --pidfile "$PIDFILE" "$NUMACTL $mongod $OPTIONS >/dev/null 2>&1"
    

In addition, ensure that the following are all owned by mongod

  • /var/log/mongodb
  • /var/run/mongodb
  • your dbpath
like image 65
Phil Windley Avatar answered May 06 '23 09:05

Phil Windley


It would seem that although mongod supports YAML config files, the initscripts haven't been revised to handle them.

like image 23
StRangeRover Avatar answered May 06 '23 08:05

StRangeRover