mongodb service is not starting up

前端 未结 21 683
野的像风
野的像风 2020-12-02 05:16

I\'ve installed the mongodb 2.0.3, using the mongodb-10gen debian package. Everything went well, except the service which is installed by default is not starting up when com

相关标签:
21条回答
  • 2020-12-02 05:36

    Remember that when you restart the database by removing .lock files by force, the data might get corrupted. Your server shouldn't be considered "healthy" if you restarted the server that way.

    To amend the situation, either run

    mongod --repair
    

    or

    > db.repairDatabase();    
    

    in the mongo shell to bring your database back to "healthy" state.

    0 讨论(0)
  • 2020-12-02 05:36

    Recall that according to official MongoDB documentation, the right command to start the service is (@Ubuntu): sudo service mongod start (06/2018) (no mongodb or mongo).

    Reference: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/

    0 讨论(0)
  • 2020-12-02 05:36

    What helped me diagnose the issue was to run mongod and specify the /etc/mondgob.conf config file:

    mongod --config /etc/mongodb.conf
    

    That revealed that some options in /etc/mongdb.conf were "Unrecognized". I had commented out both options under security: and left alone only security: on one line, which caused the service to not start. This looks like a bug.

    security:
    #  authorization: enabled
    #  keyFile: /etc/ssl/mongo-keyfile
    

    ^^ error

    #security:
    #  authorization: enabled
    #  keyFile: /etc/ssl/mongo-keyfile
    

    ^^ correctly commented.

    0 讨论(0)
  • 2020-12-02 05:37

    Fixed!

    The reason was the dbpath variable in /etc/mongodb.conf. Previously, I was using mongodb 1.8, where the default value for dbpath was /data/db. The upstart job mongodb(which comes with mongodb-10gen package) invokes the mongod with --config /etc/mongodb.conf option.

    As a solution, I only had to change the owner of the /data/db directory recursively.

    0 讨论(0)
  • 2020-12-02 05:39

    Here's a weird one, make sure you have consistent spacing in the config file.

    For example:

    processManagement:
      timeZoneInfo: /usr/share/zoneinfo
    
    security:
        authorization: 'enabled'
    

    If the authorization key has 4 spaces before it, like above and the rest are 2 spaces then it won't work.

    0 讨论(0)
  • 2020-12-02 05:41

    This can also happen if the disk is full at your logpath path (e.g. if you have a dedicated /log/ directory/drive and it is full).

    This had me panicking for a good 15 minutes because it also prevents you from reading the mongod.log when starting the process, so difficult to troubleshoot.

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