MongoDB won't start after server crash

前端 未结 8 1198
被撕碎了的回忆
被撕碎了的回忆 2020-11-28 18:29

My Ubuntu computer had crashed, and when I restarted it MongoDB wasn\'t working. I tried the following commands, and got the following output:

$ mongo
Error:         


        
相关标签:
8条回答
  • 2020-11-28 19:04

    This is probably not the best solution, but if you're desperate you can try this. It seemed that only the journal was a problem for me, so I took these steps:

    1. Create a new data directory. Possibly /var/lib/mongodb2
    2. Update your mongod.conf to point to the new data dir.
    3. Start mongoDB.
    4. If it starts successfully, then you can shut down mongo again and proceed, otherwise you can stop reading here.
    5. Locate your previous data dir and copy the files for your database(s) to your new data directory (example, admin.0 admin.1 admin.ns, etc)
    6. Start mongoDB again (still using the new data directory)

    After completing these steps (took less than 5 min), I was up and running and all data appeared to be ok.

    0 讨论(0)
  • 2020-11-28 19:05

    all I had to do was run: sudo mongod --repair

    then:

    sudo mongod

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