9

I typed mongod on in my mac terminal and got the following error:

2015-04-27T22:11:46.471-0400 W -        [initandlisten] Detected unclean  shutdown - /data/db/mongod.lock is not empty.
2015-04-27T22:11:46.479-0400 I STORAGE  [initandlisten] ************** 
old lock file: /data/db/mongod.lock.  probably means unclean shutdown,
but there are no journal files to recover.
this is likely human error or filesystem corruption.
please make sure that your journal directory is mounted.
found 4 dbs.
see: http://dochub.mongodb.org/core/repair for more information

How do I make sure my journal directory is mounted? Will that solve the problem?

DBWeinstein
  • 8,605
  • 31
  • 73
  • 118
  • Is it a replica set? Is journaling enabled? – user2829759 Apr 28 '15 at 02:59
  • Off-topic. This definetly is a question to be asked on http://dba.stackexchange.com Hint: you should [read a bit about UNIX like filesystems](https://en.wikipedia.org/wiki/File_system#Unix_and_Unix-like_operating_systems) – Markus W Mahlberg Apr 28 '15 at 08:16

5 Answers5

21

You have an unclean shutdown. You should start mongod with --repair option.

mongod --repair

Note that after repair you will need to restart mongod

styvane
  • 59,869
  • 19
  • 150
  • 156
  • Solution for docker: `docker-compose run mongo mongod --repair`, where `mongo` is your DB service name, not a container name. – bora89 Feb 02 '22 at 13:14
5

1.delete mongo.lock

2.Mongod --dbpath path --repair

3.mongod --dbpath path

Run command with Admin accesss.I had sloved in Windows machine.

Vishe
  • 3,383
  • 1
  • 24
  • 23
2

Journal is stored in the path specified in --dbpath option. In your case /data/db/.

To check if this directory is a mountpoint, use mountpoint /data/db/. But I don't think it is the cause.

/data/db/mongod.lock exist when mongod starts, and destroyed when mongod shutdown. It's existence means improper shutdown, for whatever reason.

You should remove mongod.lock, then issue a mongod --repair.

user2829759
  • 3,372
  • 2
  • 29
  • 53
  • @Michael The `mongod.lock` prevent two `mongod` instance sharing the same directory. `If the mongod.lock file in the data directory specified by dbPath, /data/db by default, is not a zero-byte file, then mongod will refuse to start` -[http://docs.mongodb.org/manual/tutorial/recover-data-following-unexpected-shutdown/](http://docs.mongodb.org/manual/tutorial/recover-data-following-unexpected-shutdown/). You have to remove it before doing anything else. – user2829759 Apr 28 '15 at 03:17
  • I deleted the file and restarted the mongod again and it worked – therealprashant Mar 31 '16 at 18:24
  • Removing `/data/db/mongod.lock` file fixed my problem – kaxi1993 Mar 07 '17 at 20:48
0

For 32Bit you need to use this

    mongod --storageEngine=mmapv1 --dbpath [your-path] --repair
JSP.NET
  • 188
  • 13
0

I received the message "Detected unclean shutdown - /data/db/mongod.lock is not empty." and a google search brought me to this question - however my problem was different.

I was on a mac and I ran $ mongod when I should have run $ sudo mongod

kris
  • 11,868
  • 9
  • 88
  • 110