MongoDB not using /etc/mongodb.conf after I changed dbpath

前端 未结 4 1054
眼角桃花
眼角桃花 2020-12-30 04:25

Ever since I changed the dbpath in /etc/mongodb.conf, MongoDB has not been starting automatically, nor using the new dbpath. Prior to

相关标签:
4条回答
  • 2020-12-30 05:09

    MongoDB 1.6 is very old and the latest production version is 2.2, which contains a large amount of bug fixes and enhancements since 1.6.

    Am I correct that you haven't installed 1.6 via a package manager such as yum or aptitude? I don't believe there are packages for 1.6 at present afaik. Therefore, mongod is behaving correctly as you have not started MongoDB with a control script.

    Please see this link on configuration file options.

    0 讨论(0)
  • 2020-12-30 05:23

    After checking all permission in the data, journal and log folders as suggested, my problem was solved by giving permission to a lock file in the /tmp folder

    sudo chown mongod:mongod mongodb-27017.sock 
    

    I was running it as a AWS Amazon Linux instance. I figured that out by executing as the mongod user as below, and then, researching the error code. It might be useful for other troubleshooting.

    sudo -S -u mongod mongod -f /etc/mongod.conf
    
    0 讨论(0)
  • 2020-12-30 05:25

    A late follow up on the above question...

    I had a similar issue after moving the db to an ebs on ec2.

    It turns out that just running mongod still directs the dbpath to /data/db/ (which exists).

    The /etc/mongodb.conf is completely ignored unless specifically directed to.

    I manage to work around this by using the directive --config or just the --dbpath(both work) But was left wondering where does mongod takes it defaults from...?!

    I was unable to locate and override these defaults anywhere. Anyone ?

    Note: I am really annoyed by this behaviour of mongod...This is just bad design,and bad documentation.

    0 讨论(0)
  • 2020-12-30 05:25

    It turns out that I needed to set the owner and group to mongodb. When I transferred the files to the new directory, I had set the owner and group to my user account nick and also tried root, neither of which worked.

    To do so, here are the following commands:

    sudo chown mongodb /home/nick/appdev/mongodb -R
    sudo chgrp mongodb /home/nick/appdev/mongodb -R
    

    To confirm that it worked, you can check the file permissions with:

    ls -l /home/nick/appdev/mongodb
    
    0 讨论(0)
提交回复
热议问题