why can't I start the mongodb

前端 未结 7 555
被撕碎了的回忆
被撕碎了的回忆 2020-12-04 10:10

this is the error:

(mysite)zjm1126@zjm1126-G41MT-S2:~$ /usr/local/mongodb/bin/mongod 
/usr/local/mongodb/bin/mongod --help for help and startup options
Wed A         


        
相关标签:
7条回答
  • 2020-12-04 10:47

    On Mac OSX Yosemite after standard install with brew:

    sudo chown -R `id -u` /data/db
    

    if it not starts (check if there are no hanging and blocking connections):

    lsof -i:27017
    

    outputs something like:

    COMMAND   PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
    mongod  16948 andi    8u  IPv4 0x883a71bc9412939d      0t0  TCP *:27017 (LISTEN)
    

    take value of PID and run:

    kill -9 <PID>
    

    now you should be able to start mongo server: mongod and then e.g in separate console window connect to it with mongo

    0 讨论(0)
  • 2020-12-04 10:49

    I resolved this by doing a chown on mongodb ie.

    sudo chown -R mongodb:mongodb /data
    

    This is because, when you do

    ls -lrth /data
    drwxr-xr-x 2 mongodb mongodb  6 Jan  5 02:31 journal
    -rwxr-xr-x 1 mongodb mongodb  0 Jan  5 02:31 mongod.lock
    drwxr-xr-x 2 ubuntu  root    24 May  8 20:02 configdb
    

    Hope this helps.

    0 讨论(0)
  • 2020-12-04 10:56

    Either sudo the call to mongod or change the permissions of /data/db/mongod.lock so that it is writable by you.

    0 讨论(0)
  • 2020-12-04 10:56

    Make sure you do not have a mongod instance running.

    This is what worked for me. I checked to see if there was an instance running in the background at first by looking in the terminal like this: ps aux | grep mongo

    and I saw that there was: 48358 bla bla mongod

    so I killed it: kill 48358

    and then I was able to run it fine.

    0 讨论(0)
  • 2020-12-04 11:03

    If you want to rescue a member of a replica set don't use this methods described above. Instead use the procedures described in the ReSync-documentation of MongoDB.

    0 讨论(0)
  • 2020-12-04 11:04

    Here, how i solved it

    1. After removing lock file I repaired it using sudo mongod --repair --config=/etc/mongodb.conf, After this I Checked mongod.lock permission using ls -l /var/lib/mongodb/mongod.lock
    2. it was showing root is owner of lock file, so i changed it back to mongodb using sudo chown mongodb:mongodb /var/lib/mongodb/*
    3. then restart mongodb service using sudo service mongodb restart
    0 讨论(0)
提交回复
热议问题