cannot run local mongo server on OSX - mongodb

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.

Related

Mongodb on macOS Catalina still using /data/db, despite new path specified in config file

On mac Catalina, /data/db is no longer writeable, and so the new brew install of mongodb-community uses a new path, /usr/local/var/mongodb. I upgraded, following these instructions:
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/#install-mongodb-community-edition
and to confirm:
$ ls -al /usr/local/bin/mongod
lrwxr-xr-x 1 rkohr admin 44 Feb 5 10:49 /usr/local/bin/mongod -> ../Cellar/mongodb-community/4.2.3/bin/mongod
$ cat /usr/local/etc/mongod.conf
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
But it seems that the config is being ignored since it is still trying to use the old /data/db path:
$ mongod
2020-02-05T10:55:42.210-0500 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2020-02-05T10:55:42.215-0500 I CONTROL [initandlisten] MongoDB starting : pid=1518 port=27017 dbpath=/data/db 64-bit host=Robs-MacBook-Pro.local
2020-02-05T10:55:42.215-0500 I CONTROL [initandlisten] db version v4.2.3
2020-02-05T10:55:42.215-0500 I CONTROL [initandlisten] git version: 6874650b362138df74be53d366bbefc321ea32d4
2020-02-05T10:55:42.215-0500 I CONTROL [initandlisten] allocator: system
2020-02-05T10:55:42.215-0500 I CONTROL [initandlisten] modules: none
2020-02-05T10:55:42.215-0500 I CONTROL [initandlisten] build environment:
2020-02-05T10:55:42.215-0500 I CONTROL [initandlisten] distarch: x86_64
2020-02-05T10:55:42.215-0500 I CONTROL [initandlisten] target_arch: x86_64
2020-02-05T10:55:42.215-0500 I CONTROL [initandlisten] options: {}
2020-02-05T10:55:42.216-0500 E NETWORK [initandlisten] Failed to unlink socket file /tmp/mongodb-27017.sock Permission denied
2020-02-05T10:55:42.216-0500 F - [initandlisten] Fatal Assertion 40486 at src/mongo/transport/transport_layer_asio.cpp 683
2020-02-05T10:55:42.216-0500 F - [initandlisten]
***aborting after fassert() failure
#RobKohr To make it works, you have to run following command:
mongod --config /usr/local/etc/mongod.conf
See: https://docs.mongodb.com/manual/reference/configuration-options/#use-the-configuration-file

MongoDB Service on Ubuntu fails after upgrade

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 :(

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/*.

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/

Error on Installing MongoDB

After I install mongodb via homebrew, I get the following message when I type mongod:
kamflamenco ~ $ mongod
2016-08-02T15:34:39.934-0700 I CONTROL [initandlisten] MongoDB starting : pid=4167 port=27017 dbpath=/data/db 64-bit host=Kenzos-MacBook-Pro.local
2016-08-02T15:34:39.935-0700 I CONTROL [initandlisten] db version v3.2.8
2016-08-02T15:34:39.935-0700 I CONTROL [initandlisten] git version: ed70e33130c977bda0024c125b56d159573dbaf0
2016-08-02T15:34:39.935-0700 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2h 3 May 2016
2016-08-02T15:34:39.935-0700 I CONTROL [initandlisten] allocator: system
2016-08-02T15:34:39.935-0700 I CONTROL [initandlisten] modules: none
2016-08-02T15:34:39.935-0700 I CONTROL [initandlisten] build environment:
2016-08-02T15:34:39.935-0700 I CONTROL [initandlisten] distarch: x86_64
2016-08-02T15:34:39.935-0700 I CONTROL [initandlisten] target_arch: x86_64
2016-08-02T15:34:39.935-0700 I CONTROL [initandlisten] options: {}
2016-08-02T15:34:39.936-0700 I - [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2016-08-02T15:34:39.938-0700 I STORAGE [initandlisten] exception in initAndListen: 98 Unable to create/open lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating
2016-08-02T15:34:39.938-0700 I CONTROL [initandlisten] dbexit: rc: 100
I am new to this and I've tried researching on the error. However, I have no luck, including typing
sudo chmod 777
The only time mongod works is if I type sudo in front of it
sudo mongod
But I do not feel this is correct...
remove the mongod.lock file:
sudo rm /data/db/mongod.lock