MongoDB Service Will Not Start After Initial Setup

前端 未结 11 1745
夕颜
夕颜 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:13

    I've spent a while looking into this, and it appears as if the pid folder and file permissions don't work with the default daemon.

    The simplest solution I've come across is disable the pid file by just putting a # in front of the line in the config file.

    vi /etc/mongod.conf
    

    find the line that says pidfilepath=/var/run/mongodb/mongod.pid and change it accordingly.

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

    For information on what commenting it out does check here. http://docs.mongodb.org/manual/reference/configuration-options/#processManagement.pidFilePath

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

    i met the same issue,when i modify my mongod.conf as follow and problem resolved~

    port=27017
    dbpath=/usr/local/mongodb/data/db/
    logpath=/usr/local/mongodb/logs
    fork = true
    

    tips: logpath is the logfile not a folder.

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

    If you’re starting mongod as a service using:

    sudo service mongod start

    Make sure the directories defined for logpath, dbpath, and pidfilepath in your mongod.conf exist and are owned by mongod:mongod.

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

    I just experience a similar problem on ubuntu. Encountered nearly every ERROR tips, like

    child process failed, exited with error number 1
    

    orchild process failed, exited with error number 100

    or [signalProcessingThread] got signal 2 (Interrupt: 2), will terminate after current cmd ends

    For many times I remove the Mongodb and try to install again, but the problem remains....

    Finally I came to this way: Backup your data first, then remove Mongodb with

    #sudo apk-get autoremove mongodb-org
    

    Find out all the files related with mongodb:

    /#find -name mongo*
    

    Delete them all with "rm" or "rmdir", including the packages in the /var/cache/... and everthing.

    Then repeat the installation as the first time you did :

    #echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
    #sudo apt-get update
    #sudo apt-get install -y mongodb-org
    

    It will run again.

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

    I have the same problem, I solved it temporarily, disabling SELinux, rebooted the machine, eliminated mongod.lock:

    #rm /var/lib/mongo/mongod.lock
    

    By creating the file /var/run/mongodb/mongo.pid (as mentioned in the configuration file /etc/mongod.conf):

    #mkdir /var/run/mongodb
    #touch /var/run/mongodb/mongod.pid
    

    and giving 777 permissions:

    #chmod 777 /var/run/mongodb/mongod.pid 
    

    and starting mongo:

    #service mongod start
    

    But the problem persists after restarting the machine. The folder and file disappear.

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

    This worked for me in Ubuntu:

    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/
    sudo touch /var/run/mongodb/mongod.pid
    sudo chown -R  mongodb:mongodb /var/run/mongodb/
    sudo chown mongodb:mongodb /var/run/mongodb/mongod.pid
    sudo service mongod start
    
    0 讨论(0)
提交回复
热议问题