MongoDB Service Will Not Start After Initial Setup

前端 未结 11 1746
夕颜
夕颜 2021-01-31 12:11

I am running Fedora 20 and installed MongoDB per the Red Hat installation guide on the official documentation. I was able to run the mongod daemon as a service with

相关标签:
11条回答
  • 2021-01-31 12:29

    Comment below the line from your "mongo.conf" file.

    pidfilepath=/var/run/mongodb/mongod.pid

    0 讨论(0)
  • 2021-01-31 12:31

    Following commands solved for cent os

    ERROR:

     service mongod status
     Error starting mongod. /var/run/mongodb/mongod.pid exists
    

    FIXED BY:

       rm /var/lib/mongo/mongod.lock
       chown -R mongod:mongod /var/log/mongodb/
       chown -R mongod:mongod /var/run/mongodb/
       chown -R mongod:mongod /var/lib/mongo/
       chmod 777 /var/run/mongodb/mongod.pid
    
       mongod --dbpath /var/lib/mongo
    
    0 讨论(0)
  • 2021-01-31 12:33

    We need to create the temp dir location of pidfile /var/run/mongodb that's handled by systemd-tmpfiles. So, create a file /lib/tmpfiles.d/mongodb.conf as root:

    lnx#> sudo su
    lnx#> cd /lib/tmpfiles.d
    lnx#> echo “d /var/run/mongodb 0755 mongod mongod” > mongodb.conf

    Then reboot or run this command to activate that temp directory:

    lnx#>sudo systemd-tmpfiles --create mongodb.conf

    Start mongod service:

    lnx#> sudo systemctl start mongod.service

    Bibliography: Fedora And Mongodb · l33tsource

    0 讨论(0)
  • 2021-01-31 12:37

    I was having the same problem running mongodb 3.0.4 on OpenSuse 13.2, and I found that the mongod directory under /var/run was missing. If I created the directory manually it would disappear after a reboot.

    I solved it by adding the following lines to my /etc/init.d/mongod startup script:

    mkdir -p /var/run/mongod  
    chown $MONGO_USER:$MONGO_GROUP /var/run/mongod
    
    0 讨论(0)
  • 2021-01-31 12:38

    What worked for me on Fedora 20: we need to create the temp dir on every boot, and that's handled by systemd-tmpfiles. So, create a file /lib/tmpfiles.d/mongodb.conf and put one line in it:

    d /var/run/mongodb 0755 mongod mongod
    

    That seems to handle it on restarts; if you don't want to restart right away, you can execute that with:

    sudo systemd-tmpfiles --create mongodb.conf
    

    (See the man pages for systemd-tmpfiles)

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