Mongodb service won't start

后端 未结 12 1054
臣服心动
臣服心动 2020-12-15 03:32

I am not sure why, and the service was working fine just yesterday, all of a sudden I can not get MongoDB to start up.

[root@purr ~]# service mongod start
St         


        
相关标签:
12条回答
  • 2020-12-15 03:44

    In my case, it was also showing some lock problems whenever my local system shuts down without stopping the MongoDB server.

    But it just worked only by using sudo command:-

    $ sudo mongod --port 27017

    0 讨论(0)
  • 2020-12-15 03:46

    After running the repair I was able to start the mongod proccessor but as root, which meant that service mongod start would not work. To repair this issue, I needed to make sure that all the files inside the database folder were owned and grouped to mongod. I did this by the following:

    1. Check the file permissions inside your database folder
      1. note you need to be in your dbpath folder mine was /var/lib/mongo I went to cd /var/lib
      2. I ran ls -l mongo
    2. This showed me that databases were owned by root, which is wrong. I ran the following to fix this: chown -R mongod:mongod mongo. This changed the owner and group of every file in the folder to mongod. (If using the mongodb package, chown -R mongodb:mongodb mongodb)

    I hope this helps someone else in the future.

    0 讨论(0)
  • 2020-12-15 03:46

    I solved this by deleting d:\test\mongodb\data\mongod.lock file. When you will reconnect mongo db than this file will auto generate in same folder. it works for me.

    0 讨论(0)
  • 2020-12-15 03:50

    I tried deleting the lock file, but the real reason that this happened to me was because I was using ~/data/db as the data directory. Mongo needs an absolute path to the database. Once I changed it to /home//data/db, I was in business.

    0 讨论(0)
  • 2020-12-15 03:53

    Delete the .lock file from the C:\mongodb\data\ path and then restart the mongodb service.

    0 讨论(0)
  • 2020-12-15 03:56

    I can't upvote/comment yet, but +1 for manually removing the lock file haha.

    My C9 workspace crashed on me and triggered an unexpected shutdown. The API advises: https://docs.mongodb.com/manual/tutorial/recover-data-following-unexpected-shutdown/

    .. but removing data/mongo.lock worked for me :).

    Also, just in case you're getting a connection refusal (which happened to me), running the repair command before removing the lock file could solve your problem (it did mine).

    sudo -u mongodb mongod --repair --dbpath /var/lib/mongodb/

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