Can't start mongodb on AWS instance - node.js

I have worked on mongodb database. I have installed this in my server & worked on this. But currently I am facing a problem. My mongodb database is not responding. When I am giving this command : mongo
MongoDB shell version: 2.6.10
connecting to: test
2015-07-02T06:22:11.363+0000 warning: Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2015-07-02T06:22:11.364+0000 Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed at src/mongo/shell/mongo.js:146
exception: connect failed
I have already delete the lock file, then repair mongodb then restart mongodb. But cant solve my problem.
Here is my mongodb.log file:
2015-07-02T06:30:48.789+0000 [initandlisten] MongoDB starting : pid=5551 port=27017 dbpath=/var/lib/mongodb 64-bit host=ip-172-31-5-213
2015-07-02T06:30:48.789+0000 [initandlisten] db version v2.6.10
2015-07-02T06:30:48.789+0000 [initandlisten] git version: 5901dbfb49d16eaef6f2c2c50fba534d23ac7f6c
2015-07-02T06:30:48.789+0000 [initandlisten] build info: Linux build18.nj1.10gen.cc 2.6.32-431.3.1.el6.x86_64 #1 SMP Fri Jan 3 21:39:27 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49
2015-07-02T06:30:48.789+0000 [initandlisten] allocator: tcmalloc
2015-07-02T06:30:48.789+0000 [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1" }, storage: { dbPath: "/var/lib/mongodb" }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } }
2015-07-02T06:30:48.800+0000 [initandlisten] journal dir=/var/lib/mongodb/journal
2015-07-02T06:30:48.800+0000 [initandlisten] recover : no journal files present, no recovery needed
2015-07-02T06:30:48.800+0000 [initandlisten]
2015-07-02T06:30:48.800+0000 [initandlisten] ERROR: Insufficient free space for journal files
2015-07-02T06:30:48.800+0000 [initandlisten] Please make at least 3379MB available in /var/lib/mongodb/journal or use --smallfiles
2015-07-02T06:30:48.800+0000 [initandlisten]
2015-07-02T06:30:48.800+0000 [initandlisten] exception in initAndListen: 15926 Insufficient free space for journals, terminating
2015-07-02T06:30:48.800+0000 [initandlisten] dbexit:
2015-07-02T06:30:48.800+0000 [initandlisten] shutdown: going to close listening sockets...
2015-07-02T06:30:48.800+0000 [initandlisten] shutdown: going to flush diaglog...
2015-07-02T06:30:48.800+0000 [initandlisten] shutdown: going to close sockets...
2015-07-02T06:30:48.800+0000 [initandlisten] shutdown: waiting for fs preallocator...
2015-07-02T06:30:48.800+0000 [initandlisten] shutdown: lock for final commit...
2015-07-02T06:30:48.801+0000 [initandlisten] shutdown: final commit...
2015-07-02T06:30:48.801+0000 [initandlisten] shutdown: closing all files...
2015-07-02T06:30:48.801+0000 [initandlisten] closeAllFiles() finished
2015-07-02T06:30:48.801+0000 [initandlisten] journalCleanup...
2015-07-02T06:30:48.801+0000 [initandlisten] removeJournalFiles
2015-07-02T06:30:48.802+0000 [initandlisten] shutdown: removing fs lock...
2015-07-02T06:30:48.803+0000 [initandlisten] dbexit: really exiting now

According to your mongodb.log file:
ERROR: Insufficient free space for journal files
Please make at least 3379MB available in /var/lib/mongodb/journal or use --smallfiles
You don't have enough disk space to start your MongoDB service. MongoDB fails to allocate disk space for its Journal Files.
I can see four possible solutions for your problem:
Add more disk space (cleanup something, or use larger storage). If you're using AWS, you could expand your EBS Storage Space keeping all existing data.
Reduce journal size using --smallfiles key or by setting storage.mmapv1.smallFiles to true.
Disable Journaling using --nojournal key or by setting storage.journal.enabled to false (not recommended).
Upgrade your MongoDB to 3.x and change your storage engine to WiredTiger, it'll reduce your overall database size and free some disk space. But you'll need additional disk space for data migration.

Error has been rised typically it was mongodb crash.
Solution :
sudo rm /var/lib/mongodb/mongod.lock
sudo service mongod restart
sudo service mongod stop
sudo service mongod start

Related

Weird MongoDB login error after backend shut down

Yesterday, OVH services went down, so a backend of an app of my own stopped working completely. Today, I tried starting up my app to see if everything was ok, and I was glad to see that the backend is already working, but... my app didn't show any data.
So I connected via PuTTy to my VPS to see my Node app was correctly working. I saw in pm2 (process manager for Node) that my app's instance was perfectly online. But in the Parse logs, I could see this error:
{"message":"error getting auth for sessionToken","name":"MongoError" // more redundant error messages saying pretty much the same}
I could perfectly check that the current problem, is that my Node app can't connect the Mongo server, though the credentials are the same...
Some aclarations:
The app backend and the MongoDB are stored in the same VPS.
The Mongo credentials are the same; they didn't change at all.
Tried restarting the node instance, but it won't change anything.
So, what's going on? How can I restart the mongo services and try again? And in case I need it... how can I change my mongo credentials?
Thank you!
EDIT: When I write "mongod" (it's a mongo service, right?) I get the following unexpected error:
mongod --help for help and startup options
2017-11-10T12:21:56.933+0100 [initandlisten] MongoDB starting : pid=7255 port=27017 dbpath=/data/db 64-bit host=vps332549
2017-11-10T12:21:56.934+0100 [initandlisten] db version v2.6.10
2017-11-10T12:21:56.935+0100 [initandlisten] git version: nogitversion
2017-11-10T12:21:56.935+0100 [initandlisten] OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016
2017-11-10T12:21:56.935+0100 [initandlisten] build info: Linux lgw01-12 3.19.0-25-generic #26~14.04.1-Ubuntu SMP Fri Jul 24 21:16:20 UTC 2015 x86_64 BOOST_LIB_VERSION=1_58
2017-11-10T12:21:56.935+0100 [initandlisten] allocator: tcmalloc
2017-11-10T12:21:56.935+0100 [initandlisten] options: {}
2017-11-10T12:21:56.936+0100 [initandlisten] exception in initAndListen: 10296
*********************************************************************
ERROR: dbpath (/data/db) does not exist.
Create this directory or give existing directory in --dbpath.
See http://dochub.mongodb.org/core/startingandstoppingmongo
*********************************************************************
, terminating
2017-11-10T12:21:56.936+0100 [initandlisten] dbexit:
2017-11-10T12:21:56.936+0100 [initandlisten] shutdown: going to close listening sockets...
2017-11-10T12:21:56.936+0100 [initandlisten] shutdown: going to flush diaglog...
2017-11-10T12:21:56.936+0100 [initandlisten] shutdown: going to close sockets...
2017-11-10T12:21:56.936+0100 [initandlisten] shutdown: waiting for fs preallocator...
2017-11-10T12:21:56.936+0100 [initandlisten] shutdown: lock for final commit...
2017-11-10T12:21:56.936+0100 [initandlisten] shutdown: final commit...
2017-11-10T12:21:56.936+0100 [initandlisten] shutdown: closing all files...
2017-11-10T12:21:56.937+0100 [initandlisten] closeAllFiles() finished
2017-11-10T12:21:56.937+0100 [initandlisten] dbexit: really exiting now
EDIT:
Tried to do what the first answer said, though you can see here the result is not anywhere near good; the service just won't start, I don't know why. Also, how can I know where is my db root?
root#vps332549:~# service mongod status
● mongod.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)
root#vps332549:~# service mongod restart
Failed to restart mongod.service: Unit mongod.service not found.
root#vps332549:~# mongod --dbpath=data/db/
2017-11-11T16:46:56.568+0100 [initandlisten] MongoDB starting : pid=6980 port=27017 dbpath=data/db/ 64-bit host=vps332549
2017-11-11T16:46:56.573+0100 [initandlisten] db version v2.6.10
2017-11-11T16:46:56.573+0100 [initandlisten] git version: nogitversion
2017-11-11T16:46:56.573+0100 [initandlisten] OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016
2017-11-11T16:46:56.573+0100 [initandlisten] build info: Linux lgw01-12 3.19.0-25-generic #26~14.04.1-Ubuntu SMP Fri Jul 24 21:16:20 UTC 2015 x86_64 BOOST_LIB_VERSION=1_58
2017-11-11T16:46:56.573+0100 [initandlisten] allocator: tcmalloc
2017-11-11T16:46:56.573+0100 [initandlisten] options: { storage: { dbPath: "data/db/" } }
2017-11-11T16:46:56.573+0100 [initandlisten] exception in initAndListen: 10296
*********************************************************************
ERROR: dbpath (data/db/) does not exist.
Create this directory or give existing directory in --dbpath.
See http://dochub.mongodb.org/core/startingandstoppingmongo
*********************************************************************
, terminating
2017-11-11T16:46:56.573+0100 [initandlisten] dbexit:
2017-11-11T16:46:56.573+0100 [initandlisten] shutdown: going to close listening sockets...
2017-11-11T16:46:56.573+0100 [initandlisten] shutdown: going to flush diaglog...
2017-11-11T16:46:56.573+0100 [initandlisten] shutdown: going to close sockets...
2017-11-11T16:46:56.573+0100 [initandlisten] shutdown: waiting for fs preallocator...
2017-11-11T16:46:56.573+0100 [initandlisten] shutdown: lock for final commit...
2017-11-11T16:46:56.574+0100 [initandlisten] shutdown: final commit...
2017-11-11T16:46:56.574+0100 [initandlisten] shutdown: closing all files...
2017-11-11T16:46:56.574+0100 [initandlisten] closeAllFiles() finished
2017-11-11T16:46:56.574+0100 [initandlisten] dbexit: really exiting now
root#vps332549:~# service mongod restart
Failed to restart mongod.service: Unit mongod.service not found.
root#vps332549:~# service mongod start
Failed to start mongod.service: Unit mongod.service not found.
root#vps332549:~#
If you have already set up mongod as a service, then you should be able to check if it is running or not:
$ service mongod status
If it is simply inactive, just restart your service:
# service mongod restart
If it is not registered as a service, then the mongod command expects a dbpath parameter:
$ mongod --dbpath=data/db/
where data/db/ is the path to the data directory of your database.

Cannot start mongo db

I have did the mongodb installation process mentioned in the following link https://docs.mongodb.com/manual/installation/ but i can't start the mongodb this is my log kindly tell me the possible way to start mongo db
C:\>"C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe"
2017-03-12T12:42:55.378+0530 I CONTROL [initandlisten] MongoDB starting : pid=5
400 port=27017 dbpath=C:\data\db\ 64-bit host=vimals
2017-03-12T12:42:55.379+0530 I CONTROL [initandlisten] targetMinOS: Windows 7/W
indows Server 2008 R2
2017-03-12T12:42:55.380+0530 I CONTROL [initandlisten] db version v3.4.2
2017-03-12T12:42:55.381+0530 I CONTROL [initandlisten] git version: 3f76e40c105
fc223b3e5aac3e20dcd026b83b38b
2017-03-12T12:42:55.382+0530 I CONTROL [initandlisten] OpenSSL version: OpenSSL
1.0.1u-fips 22 Sep 2016
2017-03-12T12:42:55.382+0530 I CONTROL [initandlisten] allocator: tcmalloc
2017-03-12T12:42:55.383+0530 I CONTROL [initandlisten] modules: enterprise
2017-03-12T12:42:55.384+0530 I CONTROL [initandlisten] build environment:
2017-03-12T12:42:55.385+0530 I CONTROL [initandlisten] distmod: windows-64
2017-03-12T12:42:55.385+0530 I CONTROL [initandlisten] distarch: x86_64
2017-03-12T12:42:55.386+0530 I CONTROL [initandlisten] target_arch: x86_64
2017-03-12T12:42:55.387+0530 I CONTROL [initandlisten] options: {}
2017-03-12T12:42:55.389+0530 I STORAGE [initandlisten] exception in initAndList
en: 98 Unable to create/open lock file: C:\data\db\mongod.lock The process canno
t access the file because it is being used by another process.. Is a mongod inst
ance already running?, terminating
2017-03-12T12:42:55.390+0530 I NETWORK [initandlisten] shutdown: going to close
listening sockets...
2017-03-12T12:42:55.390+0530 I NETWORK [initandlisten] shutdown: going to flush
diaglog...
2017-03-12T12:42:55.391+0530 I CONTROL [initandlisten] now exiting
2017-03-12T12:42:55.392+0530 I CONTROL [initandlisten] shutting down with code:
100
Looks as if your database file is locked by another process, did you try restarting the machine?
Just for notes.
In my case, after I create db with:
sudo mkdir -p /data/db
I also have to do this:
sudo chmod 777 /data/db
Then the environment is up for running by entering:
mongod
to enter the mongoldb shell.

I'm not able to start mongo because of no space left on disk to create lock file, but I have lots of space on disk

I have instalation of mongo on my PC with arch linux (64 bit machine).
Before start I had move mongo database files on new location with plenty (11 Gb) space. But if i run mongod, it fails because of no space left on device. If I run this as root, ti works. Where is my potential problem? Im totaly newbie in mongo.
mongo version
$ mongod --version
db version v3.0.7
git version: nogitversion
mongo conf
$ cat /etc/mongodb.conf
# See http://www.mongodb.org/display/DOCS/File+Based+Configuration for format details
# Run mongod --help to see a list of options
bind_ip = 127.0.0.1
quiet = true
#dbpath = /var/lib/mongodb
dbpath = /home/data/mongodb
logpath = /var/log/mongodb/mongod.log
logappend = true
$
check free space
$ sudo -u mongodb df -h /home/data/mongodb/
Souborový systém Velikost Užito Volno Uži% Připojeno do
/dev/sda3 208G 187G 11G 95% /home
$
check privileges
$ sudo -u mongodb ls -lisa /home/data/mongodb
celkem 12
3547175 4 drwx------ 2 mongodb daemon 4096 28. lis 21.38 .
3538945 4 drwxr-xr-x 5 postgres root 4096 28. lis 21.14 ..
3544083 4 -rw-r--r-- 1 mongodb root 69 28. lis 21.17 storage.bson
$ sudo -u mongodb ls /home/data/mongodb/
storage.bson
problem
$ sudo -u mongodb mongod --repair
2015-11-29T16:24:08.722+0100 I STORAGE [initandlisten] exception in initAndListen: 39 Unable to write process id 4565 to file: /data/db/mongod.lock errno:28 No space left on device, terminating
2015-11-29T16:24:08.722+0100 I CONTROL [initandlisten] now exiting
2015-11-29T16:24:08.722+0100 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2015-11-29T16:24:08.722+0100 I NETWORK [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2015-11-29T16:24:08.722+0100 I NETWORK [initandlisten] shutdown: going to flush diaglog...
2015-11-29T16:24:08.722+0100 I NETWORK [initandlisten] shutdown: going to close sockets...
2015-11-29T16:24:08.722+0100 I STORAGE [initandlisten] shutdown: waiting for fs preallocator...
2015-11-29T16:24:08.722+0100 I STORAGE [initandlisten] shutdown: closing all files...
2015-11-29T16:24:08.722+0100 I STORAGE [initandlisten] closeAllFiles() finished
2015-11-29T16:24:08.722+0100 I CONTROL [initandlisten] dbexit: rc: 100
$
as root
$sudo mongod --repair
2015-11-29T16:25:56.792+0100 I CONTROL [initandlisten] MongoDB starting : pid=4610 port=27017 dbpath=/data/db 64-bit host=optiplex
2015-11-29T16:25:56.792+0100 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2015-11-29T16:25:56.792+0100 I CONTROL [initandlisten]
2015-11-29T16:25:56.792+0100 I CONTROL [initandlisten]
2015-11-29T16:25:56.792+0100 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2015-11-29T16:25:56.792+0100 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2015-11-29T16:25:56.792+0100 I CONTROL [initandlisten]
2015-11-29T16:25:56.792+0100 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2015-11-29T16:25:56.792+0100 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2015-11-29T16:25:56.792+0100 I CONTROL [initandlisten]
2015-11-29T16:25:56.792+0100 I CONTROL [initandlisten] db version v3.0.7
2015-11-29T16:25:56.792+0100 I CONTROL [initandlisten] git version: nogitversion
2015-11-29T16:25:56.792+0100 I CONTROL [initandlisten] build info: Linux flo 4.2.3-1-ARCH #1 SMP PREEMPT Sat Oct 3 18:52:50 CEST 2015 x86_64 BOOST_LIB_VERSION=1_59
2015-11-29T16:25:56.792+0100 I CONTROL [initandlisten] allocator: tcmalloc
2015-11-29T16:25:56.792+0100 I CONTROL [initandlisten] options: { repair: true }
2015-11-29T16:25:56.793+0100 I STORAGE [initandlisten] finished checking dbs
2015-11-29T16:25:56.793+0100 I CONTROL [initandlisten] now exiting
2015-11-29T16:25:56.793+0100 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2015-11-29T16:25:56.793+0100 I NETWORK [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2015-11-29T16:25:56.793+0100 I NETWORK [initandlisten] shutdown: going to flush diaglog...
2015-11-29T16:25:56.793+0100 I NETWORK [initandlisten] shutdown: going to close sockets...
2015-11-29T16:25:56.793+0100 I STORAGE [initandlisten] shutdown: waiting for fs preallocator...
2015-11-29T16:25:56.793+0100 I STORAGE [initandlisten] shutdown: closing all files...
2015-11-29T16:25:56.793+0100 I STORAGE [initandlisten] closeAllFiles() finished
2015-11-29T16:25:56.793+0100 I STORAGE [initandlisten] shutdown: removing fs lock...
2015-11-29T16:25:56.793+0100 I CONTROL [initandlisten] dbexit: rc: 0
in log i have no new records...
Thanks for your help.

Mongodb Upgrade issue

I have upgraded my MONGODB version from 2.6.7 to 3.0.3.
When I run following command
./mongod --dbpath database --storageEngine wiredTiger
getting output,
2015-10-19T14:47:04.936+0530 I CONTROL [initandlisten] MongoDB starting : pid=22642 port=27017 dbpath=database 64-bit host=inkilab-Vostro-2520
2015-10-19T14:47:04.937+0530 I CONTROL [initandlisten]
2015-10-19T14:47:04.937+0530 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2015-10-19T14:47:04.937+0530 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2015-10-19T14:47:04.937+0530 I CONTROL [initandlisten]
2015-10-19T14:47:04.937+0530 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2015-10-19T14:47:04.937+0530 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2015-10-19T14:47:04.937+0530 I CONTROL [initandlisten]
2015-10-19T14:47:04.937+0530 I CONTROL [initandlisten] db version v3.0.0
2015-10-19T14:47:04.937+0530 I CONTROL [initandlisten] git version: a841fd6394365954886924a35076691b4d149168
2015-10-19T14:47:04.937+0530 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
2015-10-19T14:47:04.937+0530 I CONTROL [initandlisten] build info: Linux ip-10-179-177-12 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49
2015-10-19T14:47:04.937+0530 I CONTROL [initandlisten] allocator: tcmalloc
2015-10-19T14:47:04.937+0530 I CONTROL [initandlisten] options: { storage: { dbPath: "database", engine: "wiredTiger" } }
2015-10-19T14:47:04.963+0530 E NETWORK [initandlisten] listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:27017
2015-10-19T14:47:04.963+0530 E NETWORK [initandlisten] addr already in use
2015-10-19T14:47:05.203+0530 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=1G,session_max=20000,eviction=(threads_max=4),statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2015-10-19T14:47:27.542+0530 I CONTROL [initandlisten] now exiting
2015-10-19T14:47:27.543+0530 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2015-10-19T14:47:27.543+0530 I NETWORK [initandlisten] shutdown: going to flush diaglog...
2015-10-19T14:47:27.543+0530 I NETWORK [initandlisten] shutdown: going to close sockets...
2015-10-19T14:47:27.600+0530 I STORAGE [initandlisten] WiredTigerKVEngine shutting down
2015-10-19T14:47:49.491+0530 I STORAGE [initandlisten] shutdown: removing fs lock...
2015-10-19T14:47:49.518+0530 I CONTROL [initandlisten] dbexit: rc: 48
Please help me.
The bindIp error indicates you already have a service running on the default port. In order to override, you must first stop or delete the service and start the mongod again.
In order to kill the services on the default port, you can try the following commands:
ps -eAf | grep mongo
This will give you current instances, if any of any service by name like "mongo", or interpret as service like 'mongo%'. Now you will have to kill the traces you have on the default port and this can be done using the kill command in shell. For help type:
man kill
Alternatively, you can start mongod on a new assigned port by using the -p or --port switch

Why getting error mongod dead but subsys locked and Insufficient free space for journal files on Linux?

I have installed mongo-10gen mongo-10gen-server on Linux CentOS server.
I followed the steps from Link.
I have configured /etc/mongod.conf as -
logpath=/var/log/mongo/mongod.log
port=27017
dbpath=/var/lib/mongo
I have set port 27017 for mongo in iptables.
To start mongo I used commands -
service mongod start and
mongo
It get started well, but after few days I am getting the error -
Tue Jan 29 08:41:54 [initandlisten] ERROR: Insufficient free space for journal files
Tue Jan 29 08:41:54 [initandlisten] Please make at least 3379MB available in /var/lib/mongo/journal or use --smallfiles
Tue Jan 29 08:41:54 [initandlisten]
Tue Jan 29 08:41:54 [initandlisten] exception in initAndListen: 15926 Insufficient free space for journals, terminating
Tue Jan 29 08:41:54 dbexit:
Tue Jan 29 08:41:54 [initandlisten] shutdown: going to close listening sockets...
Tue Jan 29 08:41:54 [initandlisten] shutdown: going to flush diaglog...
Tue Jan 29 08:41:54 [initandlisten] shutdown: going to close sockets...
Tue Jan 29 08:41:54 [initandlisten] shutdown: waiting for fs preallocator...
Tue Jan 29 08:41:54 [initandlisten] shutdown: lock for final commit...
Tue Jan 29 08:41:54 [initandlisten] shutdown: final commit...
Tue Jan 29 08:41:54 [initandlisten] shutdown: closing all files...
Tue Jan 29 08:41:54 [initandlisten] closeAllFiles() finished
Tue Jan 29 08:41:54 [initandlisten] journalCleanup...
Tue Jan 29 08:41:54 [initandlisten] removeJournalFiles
Tue Jan 29 08:41:54 [initandlisten] shutdown: removing fs lock...
Tue Jan 29 08:41:54 dbexit: really exiting now
When I execute the command -
service mongod status
It gives Error -
mongod dead but subsys locked
Please help me to solve the problem of mongod dead but subsys locked and Insufficient free space for journals, terminating
You can add following to the config file provided when running mongod --config mongod.conf
For MongoDB 3.x (latest version)
storage:
mmapv1:
smallFiles: true
For version 2.6+
storage:
smallFiles: true
For version 2.4 and less
smallfiles = true
Then just execute mongod to accept your config file (here it assumes that location of the config is /etc/mongodb.conf):
mongod -f /etc/mongodb.conf
Documentation for smallfiles parameter:
Set to true to modify MongoDB to use a smaller default data file size.
Specifically, smallfiles reduces the initial size for data files and
limits them to 512 megabytes. The smallfiles setting also reduces the
size of each journal files from 1 gigabyte to 128 megabytes.
Start mongod instance using following command
mongod --dbpath /data/db --smallfiles
I was following the official guide at http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/
After using
$sudo service mongod start
I went to verify if MongoDB had started successfully by reviewing this log:
/var/log/mongodb/mongod.log
This is the problem that I found:
2014-11-11T12:54:05.808-0500 [initandlisten] ERROR: Insufficient free space for journal files
2014-11-11T12:54:05.808-0500 [initandlisten] Please make at least 3379MB available in /var/lib/mongodb/journal or use --smallfiles
2014-11-11T12:54:05.808-0500 [initandlisten]
2014-11-11T12:54:05.808-0500 [initandlisten] exception in initAndListen: 15926 Insufficient free space for journals, terminating
2014-11-11T12:54:05.808-0500 [initandlisten] dbexit:
2014-11-11T12:54:05.808-0500 [initandlisten] shutdown: going to close listening sockets...
2014-11-11T12:54:05.808-0500 [initandlisten] shutdown: going to flush diaglog...
2014-11-11T12:54:05.808-0500 [initandlisten] shutdown: going to close sockets...
2014-11-11T12:54:05.808-0500 [initandlisten] shutdown: waiting for fs preallocator...
2014-11-11T12:54:05.808-0500 [initandlisten] shutdown: lock for final commit...
2014-11-11T12:54:05.808-0500 [initandlisten] shutdown: final commit...
2014-11-11T12:54:05.808-0500 [initandlisten] shutdown: closing all files...
2014-11-11T12:54:05.808-0500 [initandlisten] closeAllFiles() finished
2014-11-11T12:54:05.808-0500 [initandlisten] journalCleanup...
2014-11-11T12:54:05.808-0500 [initandlisten] removeJournalFiles
2014-11-11T12:54:05.814-0500 [initandlisten] shutdown: removing fs lock...
2014-11-11T12:54:05.814-0500 [initandlisten] dbexit: really exiting now
Solution:
At the end of the file /etc/mongod.conf I added this line:
smallfiles = true
After that, I restarted the mongod service:
$sudo service mongod restart
Then when I went to review the log, I realized that everything was perfect, and the problem was fixed:
2014-11-11T22:32:20.544-0500 ***** SERVER RESTARTED *****
2014-11-11T22:32:20.552-0500 [initandlisten] MongoDB starting : pid=5200 port=27017 dbpath=/var/lib/mongodb 64-bit host=jaimemontoya-VirtualBox
2014-11-11T22:32:20.552-0500 [initandlisten] db version v2.6.5
2014-11-11T22:32:20.552-0500 [initandlisten] git version: e99d4fcb4279c0279796f237aa92fe3b64560bf6
2014-11-11T22:32:20.552-0500 [initandlisten] build info: Linux build8.nj1.10gen.cc 2.6.32-431.3.1.el6.x86_64 #1 SMP Fri Jan 3 21:39:27 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49
2014-11-11T22:32:20.552-0500 [initandlisten] allocator: tcmalloc
2014-11-11T22:32:20.552-0500 [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1" }, storage: { dbPath: "/var/lib/mongodb", smallFiles: true }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } }
2014-11-11T22:32:20.564-0500 [initandlisten] journal dir=/var/lib/mongodb/journal
2014-11-11T22:32:20.564-0500 [initandlisten] recover : no journal files present, no recovery needed
2014-11-11T22:32:20.738-0500 [initandlisten] waiting for connections on port 27017
2014-11-11T22:33:20.748-0500 [clientcursormon] mem (MB) res:36 virt:245
2014-11-11T22:33:20.748-0500 [clientcursormon] mapped (incl journal view):64
2014-11-11T22:33:20.748-0500 [clientcursormon] connections:0
For anyone having this issue despite having enough space for the journal file to be created.
My problem: I had more than enough space for the journal file to be created. Mongo gave me a connection failed issue. I used kill command to kill the mongod process which in turn gave me the subsys issue. Here is what worked for me:
Go to /var/lock/subsys and delete file mongod
now service mongod stopand then service mongod start
Started mongo shell now and everything seems to be running fine.
first
cd /usr/local/src/mongo/bin/<br>
then
./mongod --dbpath /usr/local/src/mongo/data/db/ --smallfiles
Just a note, which helped me. Though there were no technical issue related to mongo. It was just the system's space was insufficient. Clearing the system's cache worked out to me and mongo was back running smoothly.
yum clean all
Problem Background: I upgraded DB server from t2.micro to the larger instance without stopping database services. which in return created this lock file and throwing this error,
mongod dead but subsys locked
After this I was unable to use mongo shell.
If you have enough disk space. Then follow these steps,
1.sudo mongod
(if you find below failed reason)
Failed to unlink socket file /tmp/mongodb-27017.sock Operation not permitted)
Go to /tmp/ directory
Remove mongodb-27017.sock file
Restart mongod with sudo service mongod restart

Resources