I am trying to install and start mongodb locally:
I go through these steps (as shown in history):
1819 sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
1820 echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
1821 sudo apt-get update
1822 sudo apt-get install -y mongodb-org
1823 sudo service mongod start
But I get the following error log in /var/log/mongodb/mongodb.log
2016-01-05T22:51:21.869+0000 I CONTROL [main] ***** SERVER RESTARTED *****
2016-01-05T22:51:21.874+0000 I CONTROL [initandlisten] MongoDB starting : pid=5394 port=27017 dbpath=/var/lib/mongodb 64-bit host=ip-172-31-45-129
2016-01-05T22:51:21.874+0000 I CONTROL [initandlisten] db version v3.2.0
2016-01-05T22:51:21.874+0000 I CONTROL [initandlisten] git version: 45d947729a0315accb6d4f15a6b06be6d9c19fe7
2016-01-05T22:51:21.874+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
2016-01-05T22:51:21.874+0000 I CONTROL [initandlisten] allocator: tcmalloc
2016-01-05T22:51:21.874+0000 I CONTROL [initandlisten] modules: none
2016-01-05T22:51:21.874+0000 I CONTROL [initandlisten] build environment:
2016-01-05T22:51:21.874+0000 I CONTROL [initandlisten] distmod: ubuntu1404
2016-01-05T22:51:21.874+0000 I CONTROL [initandlisten] distarch: x86_64
2016-01-05T22:51:21.874+0000 I CONTROL [initandlisten] target_arch: x86_64
2016-01-05T22:51:21.874+0000 I CONTROL [initandlisten] options: { config: "/etc/mongodb.conf", net: { bindIp: "127.0.0.1" }, storage: { dbPath: "/var/lib/mongodb", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongodb.log" } }
2016-01-05T22:51:21.895+0000 E NETWORK [initandlisten] Failed to unlink socket file /tmp/mongodb-27017.sock errno:1 Operation not permitted
2016-01-05T22:51:21.895+0000 I - [initandlisten] Fatal Assertion 28578
2016-01-05T22:51:21.895+0000 I - [initandlisten]
***aborting after fassert() failure
I previously had a mongodb installed which worked fine but stopped me from connecting to it after some changes I made to other services that were using mongodb. So I tried to remove that instance of mongodb and tried reinstalling, after which I am facing this issue.
I also try to look for the file: /tmp/mongodb-27017.sock but it does not exist on my system.
I had the same problem after installing MongoDB the same way, also got the error message 'Failed to unlink socket file /tmp/mongodb-27017.sock...'.
After doing a bit more digging I realised that the installation hadn't created the path /data/db, so here's what I did:
create the full path (the flag -p creates parent folders if they don't exist)
sudo mkdir -p /data/db
recursively change ownership of the folder /data/db to mongodb
sudo chown -R mongodb:mongodb /data/db
edit: if you're planning on running different instances of mongodb from different project folders, you, and not mongodb, should be the owner of the contents of /data/db, otherwise it will give you an error of the type exception in initAndListen: 98 Unable to create/open lock file: /data/db/mongod.lock
Remove the temporary socket file
sudo rm /tmp/mongodb-27017.sock
Initialise the mongod service
sudo service mongod start
After this it was running smoothly in my system. I could start it or stop it and it would not give me any more errors.
Hope this helps :)
Related
The error generated when executed sudo mongod executed
2018-09-13T20:56:08.259+0530 I CONTROL [initandlisten] MongoDB starting : pid=3419 port=27017 dbpath=/data/db 64-bit host=admin
2018-09-13T20:56:08.260+0530 I CONTROL [initandlisten] db version v3.6.7
2018-09-13T20:56:08.260+0530 I CONTROL [initandlisten] git version: 2628472127e9f1826e02c665c1d93880a204075e
2018-09-13T20:56:08.260+0530 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
2018-09-13T20:56:08.260+0530 I CONTROL [initandlisten] allocator:
tcmalloc
2018-09-13T20:56:08.260+0530 I CONTROL [initandlisten] modules: none
2018-09-13T20:56:08.260+0530 I CONTROL [initandlisten] build environment:
2018-09-13T20:56:08.260+0530 I CONTROL [initandlisten] distmod: ubuntu1404
2018-09-13T20:56:08.260+0530 I CONTROL [initandlisten] distarch: x86_64
2018-09-13T20:56:08.260+0530 I CONTROL [initandlisten] target_arch: x86_64
2018-09-13T20:56:08.260+0530 I CONTROL [initandlisten] options: {}
2018-09-13T20:56:08.312+0530 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory /data/db not found., terminating
2018-09-13T20:56:08.312+0530 I CONTROL [initandlisten] now exiting
2018-09-13T20:56:08.312+0530 I CONTROL [initandlisten] shutting down with code:100
I'm a beginner in MEAN stack application development and stuck with this error. Please help me. Thanks in advance
This solution solves my problem
Make a directory as
sudo mkdir -p /data/db
That will make a directory named as db and than try to start with commands
sudo mongod
If you get another error or problem with starting mongod, You may find problem as
Failed to set up listener: SocketException: Address already in use
If you find that another error than you have to kill the running process of mongod by typing to terminal as
ps ax | grep mongod
Find the mongod running port and kill the process.
sudo kill ps_number
Another way is to make a specefic port when starting mongod as
sudo mongod --port 27018
cd ~
mongod
All you need to do above step to prevent the error.
Don't run the mongod at different local disk location.
eg. My computer has two local disk:
1.) Local disk E: - drive : (When I run mongod on E: drive or on targeting any location on E local disk then I will get error message as)
Admin#DESKTOP-CJBHIMO MINGW64 /e/Full-Stack-Developer
$ mongod
...
{"t":{"$date":"2021-03-22T11:33:26.675+05:30"},"s":"E", "c":"STORAGE", "id":20557, "ctx":"initandlisten","msg":"DBException in initAndListen, terminating","attr":{"error":"NonExistentPath: Data directory E:\\data\\db\\ not found. Create the missing directory or specify another path using (1) the --dbpath command line option, or (2) by adding the 'storage.dbPath' option in the configuration file."}}
...
{"t":{"$date":"2021-03-22T11:33:26.677+05:30"},"s":"I", "c":"CONTROL", "id":23138, "ctx":"initandlisten","msg":"Shutting down","attr":{"exitCode":100}}
{"error":"NonExistentPath: Data directory E:\data\db\ not found.
2.) Local disk C: - drive : (When I run mongod on C: drive, which I recommend to use, cause, we mostly do the installation of mongodb on C: drive as per the instruction. If in your case, you installed on another drive, then run mongod on that drive's folder on hyper. Eg. as I run mongod on C:
Admin#DESKTOP-CJBHIMO MINGW64 ~/Desktop
$ mongod
{"t":{"$date":"2021-03-22T00:52:23.840-07:00"},"s":"I", "c":"STORAGE", "id":22270, "ctx":"initandlisten","msg":"Storage engine to use detected by data files","attr":{"dbpath":"C:/data/db/","storageEngine":"wiredTiger"}}
...
{"t":{"$date":"2021-03-22T11:34:59.300+05:30"},"s":"I", "c":"NETWORK", "id":23016, "ctx":"listener","msg":"Waiting for connections","attr":{"port":27017,"ssl":"off"}}
"msg":"Storage engine to use detected by data files","attr":{"dbpath":"C:/data/db/","storageEngine":"wiredTiger"}}
This whole example is based on windows 10. It runs successful on root directory cause it is inside C: disk. To get inside root directory :
Just run
sudo mkdir -p /data/db
On the machine running the mongoDB server
Before doing any of the other solutions see my answer here.
Maybe your conf file is being rejected due to outdated options or format changes.
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 do gave this path for data/db
/usr/local/Cellar/mongodb/3.2.6/data/db
The following step was made in order to create a bound to mongodb folder
sudo mongod --directoryperdb --dbpath /usr/local/Cellar/mongodb/3.2.6/data/db --logpath /usr/local/Cellar/mongodb/3.2.6/log/mongodb.log --logappend -rest
When initialize sudo mongod in terminal the following error appears:
2016-06-08T14:45:06.970+0200 I CONTROL [initandlisten] MongoDB starting : pid=8107 port=27017 dbpath=/data/db 64-bit host=iMac-Krystyna-2.local
2016-06-08T14:45:06.970+0200 I CONTROL [initandlisten] db version v3.2.6
2016-06-08T14:45:06.970+0200 I CONTROL [initandlisten] git version: 05552b562c7a0b3143a729aaa0838e558dc49b25
2016-06-08T14:45:06.970+0200 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2h 3 May 2016
2016-06-08T14:45:06.970+0200 I CONTROL [initandlisten] allocator: system
2016-06-08T14:45:06.970+0200 I CONTROL [initandlisten] modules: none
2016-06-08T14:45:06.970+0200 I CONTROL [initandlisten] build environment:
2016-06-08T14:45:06.970+0200 I CONTROL [initandlisten] distarch: x86_64
2016-06-08T14:45:06.970+0200 I CONTROL [initandlisten] target_arch: x86_64
2016-06-08T14:45:06.970+0200 I CONTROL [initandlisten] options: {}
2016-06-08T14:45:06.970+0200 I STORAGE [initandlisten] exception in initAndListen: 29 Data directory /data/db not found., terminating
2016-06-08T14:45:06.970+0200 I CONTROL [initandlisten] dbexit: rc: 100
Can you please explain what is wrong and maybe show some common practice in order to work correctly with MongoDB?
You need to create this directory as root
Either you need to use sudo , e.g. sudo mkdir -p /data/db
Or you need to do su - to become superuser, and then create the directory with mkdir -p /data/db
You can also give this command sudo mongod --dbpath=/var/lib/mongodb.
Open another terminal and run your mongod.
It worked for me.
try: sudo service mongod start
I had the same issue. This worked for me:
sudo mongod --dbpath ~/data/db
In my case, an incorrect conf file caused Mongo to use default settings (i.e. using /data/db as the storage path. Because /data/db doesn't exist, it complains.
Possible sources of incorrect config include:
(1) Unquoted strings. E.g. storage.dbPath should be "some/path"
(2) Incorrect bindIp. It seems an array of IPs is not supported.
So my fix was simply to use quoted strings in those places:
storage:
dbPath: "/some/path"
net:
bindIp: "127.0.0.1"
Note: My "/some/path" has permissions drwxr-xr-x (755) and is owned by mongodb/mongodb. And it works.
MongoDB try to find data/db folder under root directory of your system. try to create folder under /data/db.
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
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