My Environment
CentOS (I'm not sure the exact version since it's on iPage's VPS server.)
My Goal
Start mongod as a service:
sudo service mongod start
(Once I get this working, I want to get mongod to start when the server reboots via chkconfig:
sudo /sbin/chkconfig --level 345 mongod on
)
What Happens
It comes back with [FAILED] and I get this message in my logs:
2014-08-27T03:17:40.126+0000 ***** SERVER RESTARTED *****
2014-08-27T03:17:40.132+0000 [initandlisten] MongoDB starting : pid=3950 port=27017 dbpath=/var/lib/mongo 64-bit host=162-144-108-42.ipage.com
2014-08-27T03:17:40.132+0000 [initandlisten] db version v2.6.4
2014-08-27T03:17:40.132+0000 [initandlisten] git version: 3a830be0eb92d772aa855ebb711ac91d658ee910
2014-08-27T03:17:40.132+0000 [initandlisten] build info: Linux build7.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-08-27T03:17:40.132+0000 [initandlisten] allocator: tcmalloc
2014-08-27T03:17:40.132+0000 [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1" }, processManagement: { fork: true, pidFilePath: "/var/run/mongodb/mongod.pid" }, storage: { dbPath: "/var/lib/mongo" }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } }
2014-08-27T03:17:40.133+0000 [initandlisten] exception in initAndListen: 10309 Unable to create/open lock file: /var/lib/mongo/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating
2014-08-27T03:17:40.133+0000 [initandlisten] dbexit:
2014-08-27T03:17:40.133+0000 [initandlisten] shutdown: going to close listening sockets...
2014-08-27T03:17:40.133+0000 [initandlisten] shutdown: going to flush diaglog...
2014-08-27T03:17:40.133+0000 [initandlisten] shutdown: going to close sockets...
2014-08-27T03:17:40.133+0000 [initandlisten] shutdown: waiting for fs preallocator...
2014-08-27T03:17:40.133+0000 [initandlisten] shutdown: lock for final commit...
2014-08-27T03:17:40.133+0000 [initandlisten] shutdown: final commit...
2014-08-27T03:17:40.133+0000 [initandlisten] shutdown: closing all files...
2014-08-27T03:17:40.133+0000 [initandlisten] closeAllFiles() finished
2014-08-27T03:17:40.133+0000 [initandlisten] shutdown: removing fs lock...
2014-08-27T03:17:40.133+0000 [initandlisten] couldn't remove fs lock errno:9 Bad file descriptor
2014-08-27T03:17:40.133+0000 [initandlisten] dbexit: really exiting now
What I've Tried:
Grepping the current processes doesn't find any mongod process:
ps aux | grep mongod
Removing the mongod.lock file doesn't help:
sudo rm mongod.lock
Changing the owner of the database doesn't help:
sudo chown -R my_username /var/lib/mongo
This looks like a permissions issue:
2014-08-27T03:17:40.133+0000 [initandlisten] exception in initAndListen: 10309 Unable to create/open lock file: /var/lib/mongo/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating
Look if the user which mongo is running has the permission to write on that folder, assuming you're already removed the .lock file.
You are using chown with your username, but it seems that user must be mongo, not your username. Check the ownwer when the service tries to startup.
I was able to verify running sudo chown -R mongodb /var/lib/mongo works on my CentOS system. My /etc/init.d/mongod script runs the mongod process as user mongod. When I did a sudo chown -R root /var/lib/mongo I received the same Permission denied error, but when I set the directory permissions as mongod (sudo chown -R mongodb /var/lib/mongo) running sudo service mongod start works
Related
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.
I've been trying to set up MongoDB on my Ubuntu 16.04.2 LTS (GNU/Linux 4.4.0-22-generic x86_64) VPS and I've been running into a few problems. I am running as a user on my server that has root access but not using the root account itself.
I started to notice the problem when I was executing db.createUser() on the admin database so I could add other users and I was getting this error:
not authorized to execute command
So I then proceeded to uninstall and install again using the tutorial as provided on the website: https://docs.mongodb.com/v3.2/tutorial/install-mongodb-on-ubuntu/
Now when I'm on stage 2 Verify that MongoDB has started successfully on the Run MongoDB Community Edition section, that is I look at my output from the file /var/log/mongodb/mongod.log, I get the following:
2017-04-14T14:23:09.309+0200 I CONTROL [main] ***** SERVER RESTARTED *****
2017-04-14T14:23:09.316+0200 I CONTROL [initandlisten] MongoDB starting : pid=9691 port=27017 dbpath=/var/lib/mongodb 64-bit host=vps338741
2017-04-14T14:23:09.316+0200 I CONTROL [initandlisten] db version v3.4.3
2017-04-14T14:23:09.316+0200 I CONTROL [initandlisten] git version: f07437fb5a6cca07c10bafa78365456eb1d6d5e1
2017-04-14T14:23:09.316+0200 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016
2017-04-14T14:23:09.316+0200 I CONTROL [initandlisten] allocator: tcmalloc
2017-04-14T14:23:09.316+0200 I CONTROL [initandlisten] modules: none
2017-04-14T14:23:09.316+0200 I CONTROL [initandlisten] build environment:
2017-04-14T14:23:09.316+0200 I CONTROL [initandlisten] distmod: ubuntu1604
2017-04-14T14:23:09.316+0200 I CONTROL [initandlisten] distarch: x86_64
2017-04-14T14:23:09.316+0200 I CONTROL [initandlisten] target_arch: x86_64
2017-04-14T14:23:09.316+0200 I CONTROL [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1", port: 27017 }, storage: { dbPath: "/var/lib/mongodb", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log", quiet: true } }
2017-04-14T14:23:09.349+0200 I STORAGE [initandlisten]
2017-04-14T14:23:09.349+0200 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2017-04-14T14:23:09.349+0200 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
2017-04-14T14:23:09.349+0200 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=464M,session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2017-04-14T14:23:09.366+0200 E STORAGE [initandlisten] WiredTiger error (2) [1492172589:366629][9691:0x7f1755946cc0], file:WiredTiger.wt, connection: /var/lib/mongodb/WiredTiger.wt: handle-open: open: No such file or directory
2017-04-14T14:23:09.367+0200 I - [initandlisten] Assertion: 28595:2: No such file or directory src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp 267
2017-04-14T14:23:09.367+0200 I STORAGE [initandlisten] exception in initAndListen: 28595 2: No such file or directory, terminating
2017-04-14T14:23:09.367+0200 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2017-04-14T14:23:09.367+0200 I NETWORK [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2017-04-14T14:23:09.367+0200 I NETWORK [initandlisten] shutdown: going to flush diaglog...
2017-04-14T14:23:09.367+0200 I CONTROL [initandlisten] now exiting
2017-04-14T14:23:09.367+0200 I CONTROL [initandlisten] shutting down with code:100
I've looked around and it is not the same error as found here, because that is to do with the fact there isn't an /data/db folder which I have. From that log I can see it is something to do with this line:
2017-04-14T14:23:09.366+0200 E STORAGE [initandlisten] WiredTiger error (2) [1492172589:366629][9691:0x7f1755946cc0], file:WiredTiger.wt, connection: /var/lib/mongodb/WiredTiger.wt: handle-open: open: No such file or directory
Which is true, when I go to /var/lib/mongodb and do ls -l it results with:
drwxr-xr-x 2 mongodb mongodb 4096 Apr 14 14:10 journal
-rw-r--r-- 1 mongodb mongodb 0 Apr 14 14:02 mongod.lock
-rw-r--r-- 1 mongodb mongodb 0 Apr 14 14:10 WiredTiger
-rw-r--r-- 1 mongodb mongodb 21 Apr 14 14:10 WiredTiger.lock
-rw-r--r-- 1 mongodb mongodb 1004 Apr 14 14:10 WiredTiger.turtle
But I don't know if I should manually create that file as not seen this problem elsewhere. I made sure that mongodb user has permissions on these files too as stated in the answer to this question, but still no luck.
I'm really at a loss as to what to do, any help would be very appreciated as this is my like fifth attempt at getting it working!
Thanks!
If you created the mkdir -p /data/db maybe there is a chance that you must start your server with the following command : sudo mongod
macOS/OSX : https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/
try :
sudo service mongod start ;
then run the mongodb with:
mongo
This is a known bug in MongoDB, check the report
Your problem is not that files are missing in general, it's that they go missing when you restart after a clean shutdown. Your problem is not related to the /data/db directory but more to WiredTiger.wt file that is missing after a restart.
Oct 1 20:00:44 alpha mongod.27017[1074]: [initandlisten] WiredTiger
(2) [1443729644:306783][1074:0x7fdba8fd4bc0], file:WiredTiger.wt,
connection: /data/db/WiredTiger.wt: No such file or directory
The bug report talks about the same thing.
Try:
I would suggest try and disable WiredTiger in the config file.
MongoDB Config Options
WiredTiger
UPDATE: To disable WiredTiger you have to change the storage.engine option in your mongo config file, by default mongod uses WiredTiger but you can also use InMemory LINK
Make a directory
sudo mkdir /data/db
Provide access to the directory
sudo chown -R $USER /data/db
Then run
mongod
If you get port already in use the stop mongod, it might be running in the background
sudo service mongod stop
If the last line is
waiting for connections on port 27017
then the mongod is working
This command helped me:
mongod --dbpath /data/db --repair
for me the 'answer' was to execute the following command (since service mongod start and just mongod failed)
sudo mongod --fork --port 27017 --replSet admin --logpath /data/log/mongo.log
I did not need to turn off wired tiger
Docker container:
In my case, I was using a docker container running
mongodb:
image: 'bitnami/mongodb:latest'
user: root
command: "chown -R $USER /bitnami/mongodb"
volumes:
- '/var/www/mongodb_data:/bitnami'
environment:
- MONGODB_USERNAME=bn_parse
- MONGODB_PASSWORD=3yfQexfqcc
- MONGODB_DATABASE=bitnami_parse
I migrated the docker host to other VPS/VM (aws is too expensive).
I added temporarily the command "chown -R $USER /bitnami/mongodb" to change the owner of that folder /bitnami/mongodb. It worked.
sudo mdkir data/db
sudo service mongod stop
sudo mongod
mongosh
this fixed it for me on ubuntu 22.04 after hours and hours of hunting down solutions
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.
I have a problem with my MongoDB installation on Linux. I just need to install MongoDB local.
I started with a outdated version (2.4.9), so I used these command lines to delete the entire old version:
sudo apt-get purge mongodb mongodb-clients mongodb-server mongodb-dev
sudo apt-get purge mongodb-10gen
sudo apt-get autoremove
So at this moment I had no version of MongoDB installed on my Linux Mint Qaina 17
I went to the website: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/
Did the following command lines, just like the websites told me to do:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
sudo apt-get update
sudo apt-get install -y mongodb-org
sudo service mongod start
At this moment I have MongoDB 2.6.5 installed. The latest version.
After I got none error, I restart my terminal.
This is my result in terminal after I typed: sudo mongod
mongod --help for help and startup options
2014-10-31T19:24:30.653+0100 [initandlisten] MongoDB starting : pid=2749 port=27017 dbpath=/data/db 64-bit host=XXX-pc
2014-10-31T19:24:30.653+0100 [initandlisten] db version v2.6.5
2014-10-31T19:24:30.653+0100 [initandlisten] git version: e99d4fcb4279c0279796f237aa92fe3b64560bf6
2014-10-31T19:24:30.653+0100 [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-10-31T19:24:30.653+0100 [initandlisten] allocator: tcmalloc
2014-10-31T19:24:30.654+0100 [initandlisten] options: {}
2014-10-31T19:24:30.728+0100 [initandlisten] journal dir=/data/db/journal
2014-10-31T19:24:30.729+0100 [initandlisten] recover : no journal files present, no recovery needed
2014-10-31T19:24:30.894+0100 [initandlisten] ERROR: listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:27017
2014-10-31T19:24:30.894+0100 [initandlisten] ERROR: addr already in use
2014-10-31T19:24:30.895+0100 [initandlisten] now exiting
2014-10-31T19:24:30.895+0100 [initandlisten] dbexit:
2014-10-31T19:24:30.896+0100 [initandlisten] shutdown: going to close listening sockets...
2014-10-31T19:24:30.896+0100 [initandlisten] shutdown: going to flush diaglog...
2014-10-31T19:24:30.896+0100 [initandlisten] shutdown: going to close sockets...
2014-10-31T19:24:30.896+0100 [initandlisten] shutdown: waiting for fs preallocator...
2014-10-31T19:24:30.896+0100 [initandlisten] shutdown: lock for final commit...
2014-10-31T19:24:30.896+0100 [initandlisten] shutdown: final commit...
2014-10-31T19:24:30.969+0100 [initandlisten] shutdown: closing all files...
2014-10-31T19:24:30.970+0100 [initandlisten] closeAllFiles() finished
2014-10-31T19:24:30.970+0100 [initandlisten] journalCleanup...
2014-10-31T19:24:30.970+0100 [initandlisten] removeJournalFiles
2014-10-31T19:24:31.028+0100 [initandlisten] shutdown: removing fs lock...
2014-10-31T19:24:31.029+0100 [initandlisten] dbexit: really exiting now
Could anybody tell me what the problem is? I had the same problem on a
Thanks for your quick response!
Result:
sudo lsof -i :27017
[sudo] password for XXX:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mongod 1294 mongodb 8u IPv4 11020 0t0 TCP localhost:27017 (LISTEN)
and
sudo service mongod status
mongod start/running, process 1294
When I go to my webbrowser and type
http://localhost:27017/mydb
I get a "It looks like you are trying to access MongoDB over HTTP on the native driver port." Am I missing something here?
2014-10-31T19:24:30.894+0100 [initandlisten] ERROR: listen(): bind()
failed errno:98 Address already in use for socket: 0.0.0.0:27017
2014-10-31T19:24:30.894+0100 [initandlisten] ERROR: addr already in
use 2014-10-31T19:24:30.895+0100 [initandlisten] now exiting
means that some process is already bound to port 27017.
You can find out which one with lsof -i :27017 (running with superuser priviledge, with sudo for instance)
It is probably the mongod service installed (and started) with the mongod package.
You can verify this with sudo service mongod status
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