mongo db error on startup ubuntu 16.04 - mongodb

This is the error I get after starting mongodb. I have the /data/db directory setup. any suggestions? Thank you.
root#ubuntu-512mb-sfo1-01:/data# mongod
mongod --help for help and startup options
2017-04-06T01:49:24.295+0000 [initandlisten] MongoDB starting : pid=9631 port=27017 dbpath=/data/db 64-bit host=ubuntu-512mb-sfo1-01
2017-04-06T01:49:24.296+0000 [initandlisten] db version v2.6.10
2017-04-06T01:49:24.296+0000 [initandlisten] git version: nogitversion
2017-04-06T01:49:24.296+0000 [initandlisten] OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016
2017-04-06T01:49:24.296+0000 [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-04-06T01:49:24.296+0000 [initandlisten] allocator: tcmalloc
2017-04-06T01:49:24.296+0000 [initandlisten] options: {}
2017-04-06T01:49:24.299+0000 [initandlisten] journal dir=/data/db/journal
2017-04-06T01:49:24.299+0000 [initandlisten] recover : no journal files present, no recovery needed
2017-04-06T01:49:24.427+0000 [initandlisten] ERROR: listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:27017
2017-04-06T01:49:24.428+0000 [initandlisten] ERROR: addr already in use
2017-04-06T01:49:24.443+0000 [initandlisten] now exiting
2017-04-06T01:49:24.443+0000 [initandlisten] dbexit:
2017-04-06T01:49:24.443+0000 [initandlisten] shutdown: going to close listening sockets...
2017-04-06T01:49:24.443+0000 [initandlisten] shutdown: going to flush diaglog...
2017-04-06T01:49:24.443+0000 [initandlisten] shutdown: going to close sockets...
2017-04-06T01:49:24.444+0000 [initandlisten] shutdown: waiting for fs preallocator...
2017-04-06T01:49:24.444+0000 [initandlisten] shutdown: lock for final commit...
2017-04-06T01:49:24.444+0000 [initandlisten] shutdown: final commit...
2017-04-06T01:49:24.446+0000 [initandlisten] shutdown: closing all files...
2017-04-06T01:49:24.448+0000 [initandlisten] closeAllFiles() finished
2017-04-06T01:49:24.448+0000 [initandlisten] journalCleanup...
2017-04-06T01:49:24.448+0000 [initandlisten] removeJournalFiles
2017-04-06T01:49:24.449+0000 [initandlisten] shutdown: removing fs lock...
2017-04-06T01:49:24.449+0000 [initandlisten] dbexit: really exiting now

According to your log something is already running in mongod default port that is 27017. Just stop it and give a try.
use the following command to get the PID of the process
sudo netstat -tulnp | grep 27017
copy the PID and execute the following
sudo kill -9 <PID>

Related

Can't get MongoDB to start?

Version 2.67 of MongoDB is installed. When I run MongoD in Terminal (mac os x 10.95), here is the message I get. (BTW, I have tried Sudo)![Error][1]
Alis-MacBook-Air:~ alitaghikhani$ mongod
mongod --help for help and startup options
2015-02-08T19:00:43.915-0500 [initandlisten] MongoDB starting : pid=40591 port=27017 dbpath=/data/db 64-bit host=Alis-MacBook-Air.local
2015-02-08T19:00:43.916-0500 [initandlisten]
2015-02-08T19:00:43.916-0500 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
2015-02-08T19:00:43.916-0500 [initandlisten] db version v2.6.7
2015-02-08T19:00:43.916-0500 [initandlisten] git version: nogitversion
2015-02-08T19:00:43.916-0500 [initandlisten] build info: Darwin minimavericks.local 13.4.0 Darwin Kernel Version 13.4.0: Sun Aug 17 19:50:11 PDT 2014; root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49
2015-02-08T19:00:43.916-0500 [initandlisten] allocator: tcmalloc
2015-02-08T19:00:43.916-0500 [initandlisten] options: {}
2015-02-08T19:00:43.919-0500 [initandlisten] exception in initAndListen: 10310 Unable to lock file: /data/db/mongod.lock. Is a mongod instance already running?, terminating
2015-02-08T19:00:43.919-0500 [initandlisten] dbexit:
2015-02-08T19:00:43.919-0500 [initandlisten] shutdown: going to close listening sockets...
2015-02-08T19:00:43.919-0500 [initandlisten] shutdown: going to flush diaglog...
2015-02-08T19:00:43.919-0500 [initandlisten] shutdown: going to close sockets...
2015-02-08T19:00:43.919-0500 [initandlisten] shutdown: waiting for fs preallocator...
2015-02-08T19:00:43.919-0500 [initandlisten] shutdown: lock for final commit...
2015-02-08T19:00:43.919-0500 [initandlisten] shutdown: final commit...
2015-02-08T19:00:43.919-0500 [initandlisten] shutdown: closing all files...
2015-02-08T19:00:43.920-0500 [initandlisten] closeAllFiles() finished
2015-02-08T19:00:43.920-0500 [initandlisten] dbexit: really exiting now
If it is the first time you are running MongoDB, make sure you have you have owner permission to create mongod.lock file to create in /data/db path.
sudo chown -R `id -u` /data/db
first try:
mongo localhost
to see if there already a mongod instance running. if not, you should delete the mongod.lock
sudo rm /data/db/mongod.lock
if means you had an unclear shutdown of mongod.
Important: this assumes you don't have anything important in the DB because it seems it's running on your macbook air.

MongoDB instance not starting

I have installed MongoDB on Mac OSX. When I do mongod it does not start any connections; instead it displays the output below. Can someone please help me to resolve this
$ mongod
mongod --help for help and startup options
2015-01-16T09:57:18.994-0500 [initandlisten] MongoDB starting : pid=1571 port=27017 dbpath=/data/db 64-bit host=3c15c2e72774
2015-01-16T09:57:18.995-0500 [initandlisten]
2015-01-16T09:57:18.995-0500 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
2015-01-16T09:57:18.995-0500 [initandlisten] db version v2.6.7
2015-01-16T09:57:18.995-0500 [initandlisten] git version: nogitversion
2015-01-16T09:57:18.995-0500 [initandlisten] build info: Darwin minimavericks.local 13.4.0 Darwin Kernel Version 13.4.0: Sun Aug 17 19:50:11 PDT 2014; root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49
2015-01-16T09:57:18.995-0500 [initandlisten] allocator: tcmalloc
2015-01-16T09:57:18.995-0500 [initandlisten] options: {}
2015-01-16T09:57:18.996-0500 [initandlisten] journal dir=/data/db/journal
2015-01-16T09:57:18.996-0500 [initandlisten] recover : no journal files present, no recovery needed
2015-01-16T09:57:19.056-0500 [initandlisten] bad .ns file: /data/db/local.ns
2015-01-16T09:57:19.056-0500 [initandlisten] warning database /data/db local could not be opened
2015-01-16T09:57:19.056-0500 [initandlisten] DBException 10079: bad .ns file length, cannot open database
2015-01-16T09:57:19.056-0500 [initandlisten] exception in initAndListen: 10079 bad .ns file length, cannot open database, terminating
2015-01-16T09:57:19.056-0500 [initandlisten] dbexit:
2015-01-16T09:57:19.056-0500 [initandlisten] shutdown: going to close listening sockets...
2015-01-16T09:57:19.056-0500 [initandlisten] shutdown: going to flush diaglog...
2015-01-16T09:57:19.056-0500 [initandlisten] shutdown: going to close sockets...
2015-01-16T09:57:19.056-0500 [initandlisten] shutdown: waiting for fs preallocator...
2015-01-16T09:57:19.056-0500 [initandlisten] shutdown: lock for final commit...
2015-01-16T09:57:19.056-0500 [initandlisten] shutdown: final commit...
2015-01-16T09:57:19.056-0500 [initandlisten] shutdown: closing all files...
2015-01-16T09:57:19.056-0500 [initandlisten] closeAllFiles() finished
2015-01-16T09:57:19.056-0500 [initandlisten] journalCleanup...
2015-01-16T09:57:19.060-0500 [initandlisten] removeJournalFiles
2015-01-16T09:57:19.060-0500 [initandlisten] shutdown: removing fs lock...
2015-01-16T09:57:19.060-0500 [initandlisten] dbexit: really exiting now
Remove any old or corrupted .ns files in /data/db and then restart mongodb
I had this problem. I solved it by increasing the memory size for the replica using Virtual Box.

MongoDB won't start as service [duplicate]

This question already has answers here:
unable to start mongodb local server
(25 answers)
Closed 8 years ago.
I recently installed mongodb on a Centos Dedicated Server. When i try to start mongodb as a service it is give me the following error.
Starting mongod: [FAILED]
When i just execute mongod this is what i receive.
2014-10-27T03:54:46.184+0100 [initandlisten] MongoDB starting : pid=2566 port=27017 dbpath=/data/db 64-bit host=sv.redswitches.com
2014-10-27T03:54:46.184+0100 [initandlisten] db version v2.6.5
2014-10-27T03:54:46.184+0100 [initandlisten] git version: e99d4fcb4279c0279796f237aa92fe3b64560bf6
2014-10-27T03:54:46.184+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-27T03:54:46.184+0100 [initandlisten] allocator: tcmalloc
2014-10-27T03:54:46.184+0100 [initandlisten] options: {}
2014-10-27T03:54:46.195+0100 [initandlisten] journal dir=/data/db/journal
2014-10-27T03:54:46.196+0100 [initandlisten] recover : no journal files present, no recovery needed
2014-10-27T03:54:46.233+0100 [initandlisten] ERROR: listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:27017
2014-10-27T03:54:46.233+0100 [initandlisten] ERROR: addr already in use
2014-10-27T03:54:46.234+0100 [initandlisten] now exiting
2014-10-27T03:54:46.234+0100 [initandlisten] dbexit:
2014-10-27T03:54:46.234+0100 [initandlisten] shutdown: going to close listening sockets...
2014-10-27T03:54:46.234+0100 [initandlisten] shutdown: going to flush diaglog...
2014-10-27T03:54:46.234+0100 [initandlisten] shutdown: going to close sockets...
2014-10-27T03:54:46.234+0100 [initandlisten] shutdown: waiting for fs preallocator...
2014-10-27T03:54:46.234+0100 [initandlisten] shutdown: lock for final commit...
2014-10-27T03:54:46.234+0100 [initandlisten] shutdown: final commit...
2014-10-27T03:54:46.244+0100 [initandlisten] shutdown: closing all files...
2014-10-27T03:54:46.244+0100 [initandlisten] closeAllFiles() finished
2014-10-27T03:54:46.244+0100 [initandlisten] journalCleanup...
2014-10-27T03:54:46.244+0100 [initandlisten] removeJournalFiles
2014-10-27T03:54:46.254+0100 [initandlisten] shutdown: removing fs lock...
2014-10-27T03:54:46.254+0100 [initandlisten] dbexit: really exiting now
I have already tried to re-install it twice still nothing. I also have cPanel installed on this server.
Appears it is already running:
ERROR: listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:27017
2014-10-27T03:54:46.233+0100 [initandlisten] ERROR: addr already in use
Another process is already using that port which is most likely another Mongo instance. Try running
mongo
from your command line prompt to see if you can connect using the MongoDB shell utility. Alternatively try
sudo netstat -tlnp | grep 27017
and see which process is using port 27017. On my system it's mongo:
tcp 0 0 127.0.0.1:27017 0.0.0.0:* LISTEN 25480/mongod

how to start mongodb on remote server EC2?

Am new to mongodb. I have installed it on my pc with wamp server and it is working fine. Now am trying to connect with EC2 remotely.
I have gone through this . But still am not getting to connect.
Here is the code
[ec2-user#ip-162-31-45-45 ~]$ mongod
mongod --help for help and startup options
2014-09-07T06:07:44.158+0000 [initandlisten] MongoDB starting : pid=27743 port=27017 dbpath=/data/db 64-bit host=ip-172-31-45-55
2014-09-07T06:07:44.158+0000 [initandlisten] db version v2.6.4
2014-09-07T06:07:44.158+0000 [initandlisten] git version: xxxxx
2014-09-07T06:07:44.158+0000 [initandlisten] build info: xxxxx
2014-09-07T06:07:44.158+0000 [initandlisten] allocator: tcmalloc
2014-09-07T06:07:44.158+0000 [initandlisten] options: {}
2014-09-07T06:07:44.163+0000 [initandlisten] journal dir=/data/db/journal
2014-09-07T06:07:44.163+0000 [initandlisten] recover : no journal files present, no recovery needed
2014-09-07T06:07:44.331+0000 [initandlisten] ERROR: listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:27017
2014-09-07T06:07:44.331+0000 [initandlisten] ERROR: addr already in use
2014-09-07T06:07:44.331+0000 [initandlisten] now exiting
2014-09-07T06:07:44.331+0000 [initandlisten] dbexit:
2014-09-07T06:07:44.331+0000 [initandlisten] shutdown: going to close listening sockets...
2014-09-07T06:07:44.331+0000 [initandlisten] shutdown: going to flush diaglog...
2014-09-07T06:07:44.332+0000 [initandlisten] shutdown: going to close sockets...
2014-09-07T06:07:44.332+0000 [initandlisten] shutdown: waiting for fs preallocator...
2014-09-07T06:07:44.332+0000 [initandlisten] shutdown: lock for final commit...
2014-09-07T06:07:44.332+0000 [initandlisten] shutdown: final commit...
2014-09-07T06:07:44.340+0000 [initandlisten] shutdown: closing all files...
2014-09-07T06:07:44.340+0000 [initandlisten] closeAllFiles() finished
2014-09-07T06:07:44.340+0000 [initandlisten] journalCleanup...
2014-09-07T06:07:44.340+0000 [initandlisten] removeJournalFiles
2014-09-07T06:07:44.344+0000 [initandlisten] shutdown: removing fs lock...
2014-09-07T06:07:44.344+0000 [initandlisten] dbexit: really exiting now
[ec2-user#ip-162-31-45-45 ~]$ sudo service mongod start
Starting mongod: [FAILED]
How to solve this ?
By installing all these from This was solved my problem.
The error says that the address is already in use. Are you sure it's not already running?

mongodb: Is there any way of stoping mongod from trying to set a lock on mongod.lock?

Because of the size of the mongodb database I'm trying to build and because I needed a filesystem that can handle parallel writes, I moved it on a cluster that has lustreFS, which fulfills these needs.
The problem is that I can't start mongod, so I can't connect anything to the database, because mongod can't get a lock on mongod.lock. I don't have root or sudo permissions but this does not seem to be the problem here because permissions are not mentioned, as you can see:
[user#host mongo]$ ./mongod --dbpath=path-to-db
2014-07-28T20:29:58.600+0300 [initandlisten] MongoDB starting : pid=54974 port=27017 dbpath=path-to-db 64-bit host=hostname
2014-07-28T20:29:58.600+0300 [initandlisten]
2014-07-28T20:29:58.600+0300 [initandlisten] ** WARNING: /proc/sys/vm/zone_reclaim_mode is 1
2014-07-28T20:29:58.600+0300 [initandlisten] ** We suggest setting it to 0
2014-07-28T20:29:58.600+0300 [initandlisten] ** http://www.kernel.org/doc/Documentation/sysctl/vm.txt
2014-07-28T20:29:58.600+0300 [initandlisten] db version v2.6.3
2014-07-28T20:29:58.601+0300 [initandlisten] git version: 255f67a66f9603c59380b2a389e386910bbb52cb
2014-07-28T20:29:58.601+0300 [initandlisten] build info: Linux build12.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-07-28T20:29:58.601+0300 [initandlisten] allocator: tcmalloc
2014-07-28T20:29:58.601+0300 [initandlisten] options: { storage: { dbPath: "path-to-db" } }
2014-07-28T20:29:58.614+0300 [initandlisten] exception in initAndListen: 10310 Unable to lock file: path-to-db/mongod.lock. Is a mongod instance already running?, terminating
2014-07-28T20:29:58.615+0300 [initandlisten] dbexit:
2014-07-28T20:29:58.615+0300 [initandlisten] shutdown: going to close listening sockets...
2014-07-28T20:29:58.615+0300 [initandlisten] shutdown: going to flush diaglog...
2014-07-28T20:29:58.615+0300 [initandlisten] shutdown: going to close sockets...
2014-07-28T20:29:58.615+0300 [initandlisten] shutdown: waiting for fs preallocator...
2014-07-28T20:29:58.615+0300 [initandlisten] shutdown: lock for final commit...
2014-07-28T20:29:58.615+0300 [initandlisten] shutdown: final commit...
2014-07-28T20:29:58.615+0300 [initandlisten] shutdown: closing all files...
2014-07-28T20:29:58.615+0300 [initandlisten] closeAllFiles() finished
2014-07-28T20:29:58.615+0300 [initandlisten] dbexit: really exiting now
Could you please tell me if there's any way around that lock? And no, there weren't any other mongod instances running.
Solution: File locking was being disabled by cluster admins. After file locking was enabled, mongod started and accepted connections as it should.