This evening I tried to connect to my MongoDB instance using the command line mongo tool and got the following error message: Error: couldn't connect to server 127.0.0.1} (anon):1137. It turns out that the server wasn’t running due to an improper shutdown at some point in the past. Here’s what you need to do to fix it. Note: my instructions are specific to Ubuntu 10.04 (& probably other versions of Ubuntu). Why Won’t MongoDB Start? One of the lame things about MongoDB is that it doesn’t handle a crash on it’s own very well. If the database crashes or otherwise doesn’t shut down properly, then the next time you try to start it, you’ll get a nice error saying that there is an old lockfile and that you probably need to remove it and run mongod –repair. However, on my laptop running Ubuntu 10.04, I ran into a few confusing things that I’d like to share, hopefully to save someone else out there some time. Symptoms Try to connect (type mongo on the command line). You should get a connect failed error. Verify that MongoDB is not running. Run sudo status mongodb. It should reportmongodb stop/waiting. Verify that you are unable to start MongoDB. Run sudo start mongodb. It will reportmongodb start/running, process XXXX no matter what. But if you run sudo status mongodb again, you’ll get stop/waiting. Check your logs to see that you in fact have the same problem as me. Your logs should be at /var/log/mongodb/mongodb.log. You should see an error like this: ************** old....
↧
Trending Articles
More Pages to Explore .....