MongoDB Service on Ubuntu fails after upgrade - mongodb

I have a problem that is really really really messing me up! I've got so many headaches. I updated the MongoDB package on my Ubuntu 16.04 machine today morning and since then I have been unable to get it to start (mongod). I narrowed down the problem to find out that the mongod daemon is trying to load the data path at /data/db yet my mongo.conf specifically states that the path is at /var/lib/mongodb.
What is going on? When I run mongod and set the path directly then the service starts up without any problem. But I do not want to keep doing that everytime I want to start it up. Someone please help me. Am I missing something in the configurations? Thanks for time and assistance. The error I get when I look at the logs:
2018-02-01T15:22:27.879+0000 I CONTROL [initandlisten] MongoDB starting : pid=4989 port=27017 dbpath=/data/db 64-bit host=sm
2018-02-01T15:22:27.880+0000 I CONTROL [initandlisten] db version v3.6.2
2018-02-01T15:22:27.880+0000 I CONTROL [initandlisten] git version: 489d177dbd0f0420a8ca04d39fd78d0a2c539420
2018-02-01T15:22:27.880+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016
2018-02-01T15:22:27.880+0000 I CONTROL [initandlisten] allocator: tcmalloc
2018-02-01T15:22:27.880+0000 I CONTROL [initandlisten] modules: none
2018-02-01T15:22:27.880+0000 I CONTROL [initandlisten] build environment:
2018-02-01T15:22:27.880+0000 I CONTROL [initandlisten] distmod: ubuntu1604
2018-02-01T15:22:27.880+0000 I CONTROL [initandlisten] distarch: x86_64
2018-02-01T15:22:27.880+0000 I CONTROL [initandlisten] target_arch: x86_64
2018-02-01T15:22:27.881+0000 I CONTROL [initandlisten] options: {}
2018-02-01T15:22:27.881+0000 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory /data/db not found., terminating
2018-02-01T15:22:27.881+0000 I CONTROL [initandlisten] now exiting
2018-02-01T15:22:27.881+0000 I CONTROL [initandlisten] shutting down with code:100
And part of my mongod.conf file is:
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# Where and how to store data.
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
# engine:
# mmapv1:
# wiredTiger:
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
Thanks guys!
EDIT: Some would say I should create the data directory in /data/db but what will happen to the data that I already have in the lib directory :(

Related

Difference between mongodb server data file and data folder in db for dbpath

What is the difference between these two mongo data folders?
I have my mongod dbpath pointed to C:/data/db, however I also noticed I have a data folder in C:\Program Files\MongoDB\Server\4.0\ which also contains indexes and collections.
Only reason I noticed this is because I got an unclean shutdown and lost 177 million docs so was trying to look closer at the issue (side note: was not able to recover even though mongo could rebuild the index for that missing collection)
Edit
Here is a log file from the server folder where I could see a dbpath pointing elsewhere
**aborting after fassert() failure
2018-11-18T11:40:34.164+0100 I CONTROL [main] ***** SERVER RESTARTED *****
2018-11-18T11:40:36.984+0100 I CONTROL [main] Trying to start Windows service 'MongoDB'
2018-11-18T11:40:37.092+0100 I CONTROL [initandlisten] MongoDB starting : pid=4252 port=27017 dbpath=C:\Program Files\MongoDB\Server\4.0\data 64-bit host=DESKTOP-IO5LL15
2018-11-18T11:40:37.092+0100 I CONTROL [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2018-11-18T11:40:37.092+0100 I CONTROL [initandlisten] db version v4.0.4
2018-11-18T11:40:37.092+0100 I CONTROL [initandlisten] git version: f288a3bdf201007f3693c58e140056adf8b04839
2018-11-18T11:40:37.092+0100 I CONTROL [initandlisten] allocator: tcmalloc
2018-11-18T11:40:37.093+0100 I CONTROL [initandlisten] modules: none
2018-11-18T11:40:37.093+0100 I CONTROL [initandlisten] build environment:
2018-11-18T11:40:37.093+0100 I CONTROL [initandlisten] distmod: 2008plus-ssl
2018-11-18T11:40:37.093+0100 I CONTROL [initandlisten] distarch: x86_64
2018-11-18T11:40:37.093+0100 I CONTROL [initandlisten] target_arch: x86_64
2018-11-18T11:40:37.093+0100 I CONTROL [initandlisten] options: { config: "C:\Program Files\MongoDB\Server\4.0\bin\mongod.cfg", net: { bindIp: "127.0.0.1", port: 27017 }, service: true, storage: { dbPath: "C:\Program Files\MongoDB\Server\4.0\data", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "C:\Program Files\MongoDB\Server\4.0\log\mongod.log" } }
2018-11-18T11:40:37.099+0100 W STORAGE [initandlisten] Detected unclean shutdown - C:\Program Files\MongoDB\Server\4.0\data\mongod.lock is not empty.
2018-11-18T11:40:37.100+0100 I STORAGE [initandlisten] Detected data files in C:\Program Files\MongoDB\Server\4.0\data created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2018-11-18T11:40:37.100+0100 W STORAGE [initandlisten] Recovering data from the last clean checkpoint.

Mongo won't start. Getting cryptic Assertion: 28595:13: Permission denied error

I tried to start up my computer's mongodb service and it wouldn't start. I spent over an hour trying to debug it during which time I tried many solutions. Trying all of them may have messed up my mongo install, but I tried reinstalling mongo to get a fresh start. That didn't work either. I now have the following error and cannot find anything on google about how to fix it.
2017-06-01T16:57:02.339-0400 I CONTROL [main] ***** SERVER RESTARTED *****
2017-06-01T16:57:02.343-0400 I CONTROL [initandlisten] MongoDB starting : pid=15070 port=27017 dbpath=/var/lib/mongodb 64-bit host=moss-greenelab
2017-06-01T16:57:02.343-0400 I CONTROL [initandlisten] db version v3.2.13
2017-06-01T16:57:02.343-0400 I CONTROL [initandlisten] git version: 23899209cad60aaafe114f6aea6cb83025ff51bc
2017-06-01T16:57:02.343-0400 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016
2017-06-01T16:57:02.343-0400 I CONTROL [initandlisten] allocator: tcmalloc
2017-06-01T16:57:02.343-0400 I CONTROL [initandlisten] modules: none
2017-06-01T16:57:02.343-0400 I CONTROL [initandlisten] build environment:
2017-06-01T16:57:02.343-0400 I CONTROL [initandlisten] distmod: ubuntu1604
2017-06-01T16:57:02.343-0400 I CONTROL [initandlisten] distarch: x86_64
2017-06-01T16:57:02.343-0400 I CONTROL [initandlisten] target_arch: x86_64
2017-06-01T16:57:02.343-0400 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-06-01T16:57:02.361-0400 I - [initandlisten] Detected data files in /var/lib/mongodb created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2017-06-01T16:57:02.361-0400 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=18G,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-06-01T16:57:02.364-0400 E STORAGE [initandlisten] WiredTiger (13) [1496350622:364565][15070:0x7f80e0292c80], connection: /var/lib/mongodb/journal/WiredTigerPreplog.0000000002: file-remove: unlink: Permission denied
2017-06-01T16:57:02.383-0400 I - [initandlisten] Assertion: 28595:13: Permission denied
2017-06-01T16:57:02.383-0400 I STORAGE [initandlisten] exception in initAndListen: 28595 13: Permission denied, terminating
2017-06-01T16:57:02.383-0400 I CONTROL [initandlisten] dbexit: rc: 100
I'm running Ubuntu 16.04.
Here's the telling part of the log:
/var/lib/mongodb/journal/WiredTigerPreplog.0000000002: file-remove: unlink: Permission denied
So have a look at ls -la /var/lib/mongodb/journal and see what the permissions on those files are. I'm betting that those (an probably others) are not properly owned by the correct user, which is normally mongodb on Ubuntu.
Assuming you've got an issue with ownership there, you can just run chown -R mongodb:mongodb /var/lib/mongodb.
If that doesn't work, as a last resort you can always just wipe out your data directory (assuming you don't need your data!) by running rm -rf /var/lib/mongodb/*.

cannot run local mongo server on OSX

Good day,
I used to be able to run mongo server on localhost from the shell with the command mongod --config /usr/local/etc/mongod.conf but unfortunately now the command silently fails.
if I try which mongod I will get /usr/local/bin/mongod. I have tried restarting my machine and doing brew uninstall mongodb followed by brew install mongodb but I get the same effect.
The contents of my config file located at /usr/local/etc/mongod.conf are as follows:
systemLog:
destination: file
path: /usr/local/var/log/mongodb/mongo.log
logAppend: true
storage:
dbPath: /usr/local/var/mongodb
net:
bindIp: 127.0.0.1
By the way if I try to run mongod without the --config option I get the following errors:
2016-11-28T11:01:01.288-0500 I CONTROL [initandlisten] MongoDB starting : pid=4895 port=27017 dbpath=/data/db 64-bit host=Danials-MacBook-Pro.local
2016-11-28T11:01:01.289-0500 I CONTROL [initandlisten] db version v3.2.11
2016-11-28T11:01:01.289-0500 I CONTROL [initandlisten] git version: 009580ad490190ba33d1c6253ebd8d91808923e4
2016-11-28T11:01:01.289-0500 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2j 26 Sep 2016
2016-11-28T11:01:01.289-0500 I CONTROL [initandlisten] allocator: system
2016-11-28T11:01:01.289-0500 I CONTROL [initandlisten] modules: none
2016-11-28T11:01:01.289-0500 I CONTROL [initandlisten] build environment:
2016-11-28T11:01:01.289-0500 I CONTROL [initandlisten] distarch: x86_64
2016-11-28T11:01:01.289-0500 I CONTROL [initandlisten] target_arch: x86_64
2016-11-28T11:01:01.289-0500 I CONTROL [initandlisten] options: {}
2016-11-28T11:01:01.290-0500 I STORAGE [initandlisten] exception in initAndListen: 29 Data directory /data/db not found., terminating
2016-11-28T11:01:01.290-0500 I CONTROL [initandlisten] dbexit: rc: 100
Thanks
Log file clearly says that the data directory /data/db not found..
Please create the directory for data and start the mongod process.
In your case,the value given to the dbPath in your config file is the data folder.

I try to run mongod server on ubuntu : exception in initAndListen: 29 Data directory /data/db not found., terminating

I try to run a mongod server and its giving a error comment it below :
i tried few comment kill port and lock file comments not it dosent work ..
2016-11-14T03:52:20.271+0530 I CONTROL [initandlisten] MongoDB starting : pid=2921 port=27017 dbpath=/data/db 64-bit host=codepanda
2016-11-14T03:52:20.271+0530 I CONTROL [initandlisten] db version v3.2.10
2016-11-14T03:52:20.271+0530 I CONTROL [initandlisten] git version: 79d9b3ab5ce20f51c272b4411202710a082d0317
2016-11-14T03:52:20.271+0530 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016
2016-11-14T03:52:20.271+0530 I CONTROL [initandlisten] allocator: tcmalloc
2016-11-14T03:52:20.271+0530 I CONTROL [initandlisten] modules: none
2016-11-14T03:52:20.271+0530 I CONTROL [initandlisten] build environment:
2016-11-14T03:52:20.271+0530 I CONTROL [initandlisten] distmod: ubuntu1604
2016-11-14T03:52:20.271+0530 I CONTROL [initandlisten] distarch: x86_64
2016-11-14T03:52:20.271+0530 I CONTROL [initandlisten] target_arch: x86_64
2016-11-14T03:52:20.271+0530 I CONTROL [initandlisten] options: {}
2016-11-14T03:52:20.308+0530 I STORAGE [initandlisten] exception in initAndListen: 29 Data directory /data/db not found., terminating
2016-11-14T03:52:20.308+0530 I CONTROL [initandlisten] dbexit: rc: 100
You need to create the directory:
mkdir -p /data/db
This is because the directory '/data/db' you created is writable only by super user but you are trying to run as normal user. So, the following command
sudo chown -R $USER /data/db
makes you super user.
Now, try running
mongod.
MongoDB requires a data directory to store all data. MongoDB’s default data directory path is the absolute path \data\db on the drive from which you start MongoDB. Create this folder by running the following command in a Command Prompt
md \data\db
More detailed information given here.
https://stackoverflow.com/a/46886272/6242317
For new arrivals, consider that your /etc/mongodb.conf file may be out of date. Did you copy it from a previous installation or modify it using outdated instructions?
For example, as of Mongo 4.2 the smallfiles option is no longer recognized and MongoDB will reject the conf file and resort to defaults ( i.e. /data/db ).
The configuration file documentation is here:
https://docs.mongodb.com/manual/reference/configuration-options/

MongoDB not working in Vagrant Centos Box

I cant seem to fork off an instance of the MongoDB daemon when I am logged in to a Centos 7.1 Box. I have created the data/db folder and everytime I try to run
./bin/mongod --dbpath data/db
I get a mess of errors
2016-01-26T00:44:23.820+0000 I CONTROL [initandlisten] MongoDB starting : pid=2735 port=27017 dbpath=data/db 64-bit host=localhost.localdomain
2016-01-26T00:44:23.820+0000 I CONTROL [initandlisten] db version v3.2.1
2016-01-26T00:44:23.820+0000 I CONTROL [initandlisten] git version: a14d55980c2cdc565d4704a7e3ad37e4e535c1b2
2016-01-26T00:44:23.821+0000 I CONTROL [initandlisten] allocator: tcmalloc
2016-01-26T00:44:23.821+0000 I CONTROL [initandlisten] modules: none
2016-01-26T00:44:23.821+0000 I CONTROL [initandlisten] build environment:
2016-01-26T00:44:23.821+0000 I CONTROL [initandlisten] distarch: x86_64
2016-01-26T00:44:23.821+0000 I CONTROL [initandlisten] target_arch: x86_64
2016-01-26T00:44:23.821+0000 I CONTROL [initandlisten] options: { storage: { dbPath: "data/db" } }
2016-01-26T00:44:23.842+0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=1G,session_max=20000,eviction=(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),
2016-01-26T00:44:23.853+0000 E STORAGE [initandlisten] WiredTiger (22) [1453769063:853352][2735:0x7f09f2eddcc0], connection: data/db/WiredTiger.wt: fsync: Invalid argument
2016-01-26T00:44:23.856+0000 I - [initandlisten] Fatal Assertion 28561
2016-01-26T00:44:23.856+0000 I - [initandlisten]
***aborting after fassert() failure
The strange thing is I did it earlier and it worked. What could be the problem?
It turns out that putting the downloaded mongodb database in the synced folder between the host machine and the virtual machine caused some type of permissions issue or configuration issue.
When you take it out of the synced folder - which most likely has the Vagrantfile - and put it in a folder thats not synced/shared it seems to work just fine. Thought id save someone the 5 hours I wasted :-)