MongoDB: ERROR: child process failed, exited with error number 14

后端 未结 11 1890
攒了一身酷
攒了一身酷 2020-12-17 21:48

I run MongoDB on Mac:

Shave:mongodb_simple Logan$ ./bin/mongod -f conf/mongod.conf
about to fork child process, waiting until server is ready for connections         


        
相关标签:
11条回答
  • 2020-12-17 22:01

    I encountered this issue on a GCP managed Compute Engine instance.
    As this is the top answer on a Google search for the issue, I'll include what worked for me, and is a documented bug as per MongoDB (jira-link)

    On linux systems, if the user running mongod does not have a locale set or the locale is misconfigured, mongod fails to start printing a stack trace.

    The issue can be resolved by combining a few steps:

    1. Install the required language packs (ref):
    sudo apt-get install language-pack-XX
    
    1. Run update locale (ref):
    sudo update-locale
    
    1. Restart your session, and check the same mongo command again

    2. IFF the above doesn't work (it didn't for me), just manually add the following to the file at /etc/default/locale (ref):

    LC_ALL=en_US.UTF-8
    LANG=en_US.UTF-8
    
    1. Just to admire the absence of those persistent warnings about LC_ALL not being set, run the following:
    sudo dpkg-reconfigure locales
    

    That's all, your MongoDB instance should be good to go now!

    0 讨论(0)
  • 2020-12-17 22:04

    This worked for me:

    run in terminal

    sudo rm -rf mongod.lock
    export LC_ALL=C
    

    then

    sudo mongod --fork --config /xxxx/xx/mongod.conf --logpath /xxx/log/mongodb/mongodb.log
    
    0 讨论(0)
  • 2020-12-17 22:12

    You started and probably shutdown mongo in the wrong way.

    1. TO START MONGODB

    To start mongo in the background type: mongod --dbpath /data/db --fork --logpath /dev/null.

    • /data/db is the location of the db. If you haven't created one yet => type: mkdir /data/db
    • --fork means you want to start mongo in the background - deamon.
    • --logpath /dev/null means you don't want to log - you can change that by replacing /dev/null to a path like /var/log/mongo.log

    2. TO SHUTDOWN MONGODB

    Connect to your mongo by typing: mongo and then use admin and db.shutdownServer(). Like explain in mongoDB

    If this technique doesn't work for some reason you can always kill the process.

    1. Find the mongodb process PID by typing: lsof -i:27017 assuming your mongodb is running on port 27017
    2. Type kill <PID>, replace <PID> by the value you found the previous command.
    0 讨论(0)
  • 2020-12-17 22:13

    By changing owner to mongodb for all files under /var/lib/mongodb/ it started working for me:

    chown mongodb:mongodb -R /var/lib/mongodb/
    
    0 讨论(0)
  • 2020-12-17 22:17

    Check the ownership of the file /tmp/mongodb-27017.sock

    It should be mongod. I got same error since it was root:root

    0 讨论(0)
提交回复
热议问题