ERROR: Cannot write pid file to /var/run/mongodb/mongod.pid: No such file or directory inf fedora 20

后端 未结 5 1345
故里飘歌
故里飘歌 2020-12-31 18:04

MongoDB is not starting. I have installed mongo and mongo was running but after reboot it is not running.

ERROR: Cannot write pid file to /var/run/mon

相关标签:
5条回答
  • 2020-12-31 18:28

    step by step, centos 6.8

    sudo kill $(sudo lsof -t -i:27017) 
    rm -rf /tmp/mongodb-27017.sock
    rm -f /var/lib/mongo/mongod.lock 
    rm -f /var/run/mongodb/mongod.pid 
    sudo service mongod start
    

    open port 27017 and save changes

    iptables -A INPUT -p tcp --dport 27017 -j ACCEPT
    sudo service iptables sav
    
    0 讨论(0)
  • 2020-12-31 18:35

    i finally found a solution that worked for me (I'm using Ubuntu on my Vagrant VM), i started with this :

    sudo mkdir -p /var/run/mongodb/
    sudo chown -R mongodb:mongodb /var/run/mongodb
    

    But when i checked my logs with :

    tail -f /var/log/mongodb/mongodb.log 
    

    I still had this :

    [HOUR] I CONTROL [main] ***** SERVER RESTARTED *****

    [HOUR] I CONTROL [main] ERROR: Cannot write pid file to /var/run/mongod.pid: Permission denied

    So i've edited a file named mongod.pid with nothing in it :

    sudo vim /var/run/mongod.pid
    

    And i've changed the rights :

    sudo chown mongodb:mongodb mongod.pid
    

    Final folders, users & rights :

    drwxr-xr-x 2 mongodb mongodb 40 Jul 27 09:28 mongodb/

    -rw-r--r-- 1 mongodb mongodb 1 Jul 27 09:35 mongod.pid

    Then :

    sudo systemctl restart mongod
    

    And that finally worked :)

    0 讨论(0)
  • 2020-12-31 18:36

    This helped me to go ahead

    mkdir -p  /var/run/mongodb/ ;chown -R  mongod:mongod /var/run/mongodb/
    
    0 讨论(0)
  • 2020-12-31 18:44

    What worked for me in Ubuntu is a combination of the answers from @Tuan Nguyen and @Tom Carchrae

    sudo kill $(sudo lsof -t -i:27017) 
    sudo rm -rf /tmp/mongodb-27017.sock
    sudo rm -f /var/lib/mongo/mongod.lock
    sudo rm -f /var/run/mongodb/mongod.pid
    sudo mkdir -p  /var/run/mongodb/
    touch /var/run/mongodb/mongod.pid
    sudo chown -R  mongodb:mongodb /var/run/mongodb/
    sudo chown mongodb:mongodb /var/run/mongodb/mongod.pid
    

    You can then run

    sudo service mongod start
    
    0 讨论(0)
  • 2020-12-31 18:49

    The MongoDB packages contain a "bug" which prevents them from starting properly on the newer RedHat based systems. Please see SERVER-14679 for details.

    As a workaround until 2.6.5 is released, please edit the init script according to https://github.com/mongodb/mongo/commit/50ca596ace0b1390482408f1b19ffb1f9170cab6

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