Installation issues for MongoDB on Mac OS Catalina

MongoDB expects the Data/data/db folders to be in a location which Mac OS Catalina does not allow. As a consequence the folders must be placed elsewhere, on one of the disk volumes. But modifying the MongoDB settings to find the new data folders is not working properly.

There are many supposed solutions for this in various places on the web but none of them have solved my issues.

MongoDB was installed using homebrew. There is no MongoDB directory on the file system - should there be?

The actual database file structure for this installation is: /System/Volumes/MacProSSD1TB/Data/data/db

When I run the Mongod command I get the following errors:

sudo Mongod --dbpath /System/Volumes/MacProSSD1TB/Data/data/db
2020-04-19T10:00:25.693+1000 I  CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2020-04-19T10:00:25.697+1000 W  ASIO     [main] No TransportLayer configured during NetworkInterface startup
2020-04-19T10:00:25.698+1000 I  CONTROL  [initandlisten] MongoDB starting : pid=6480 port=27017 dbpath=/System/Volumes/MacProSSD1TB/Data/data/db 64-bit host=192-168-1-102.tpgi.com.au
2020-04-19T10:00:25.698+1000 I  CONTROL  [initandlisten] db version v4.2.5
2020-04-19T10:00:25.698+1000 I  CONTROL  [initandlisten] git version: 2261279b51ea13df08ae708ff278f0679c59dc32
2020-04-19T10:00:25.698+1000 I  CONTROL  [initandlisten] allocator: system
2020-04-19T10:00:25.698+1000 I  CONTROL  [initandlisten] modules: none
2020-04-19T10:00:25.698+1000 I  CONTROL  [initandlisten] build environment:
2020-04-19T10:00:25.698+1000 I  CONTROL  [initandlisten]     distarch: x86_64
2020-04-19T10:00:25.698+1000 I  CONTROL  [initandlisten]     target_arch: x86_64
2020-04-19T10:00:25.698+1000 I  CONTROL  [initandlisten] options: { storage: { dbPath: "/System/Volumes/MacProSSD1TB/Data/data/db" } }
2020-04-19T10:00:25.699+1000 I  STORAGE  [initandlisten] exception in initAndListen: NonExistentPath: Data directory /System/Volumes/MacProSSD1TB/Data/data/db not found., terminating
2020-04-19T10:00:25.699+1000 I  NETWORK  [initandlisten] shutdown: going to close listening sockets...
2020-04-19T10:00:25.699+1000 I  -        [initandlisten] Stopping further Flow Control ticket acquisitions.
2020-04-19T10:00:25.699+1000 I  CONTROL  [initandlisten] now exiting
2020-04-19T10:00:25.699+1000 I  CONTROL  [initandlisten] shutting down with code:100

It seems to me that I need to:
(a) specify to MongoDB exactly where the new data/db folders are
(b) grant the appropriate permissions do that Mongood can access them

How do I do this?

Why sudo while starting mongod?
Normally it is not recommended to use sudo

Does this dirpath physically exist on your mac box?
/System/Volumes/MacProSSD1TB/Data/data/db
Did you create data/db dir?
If yes as which user
cd /System/Volumes/MacProSSD1TB/Data
ls -lrt data
Chek permissions
Make sure the user who is running mongod has read/write privileges on this dir

:wave: Hi @Sunbeam_Rapier welcome to the MongoDB community. The error you are getting is that the mongod process cannot find the data path you specified. Have you created that?

Also note that on Mac, if you use homebrew you can brew install mongodb and this will set everything up for you.

If the directory existed and the permissions were incorrect the error would be along the lines of

2020-04-19T14:07:21.196-0600 I STORAGE  [initandlisten] exception in initAndListen: IllegalOperation: Attempted to create a lock file on a read-only directory: data/db, terminating

Hi Doug

The issue is that Mac OS Catalina does not allow files to be placed in the location expected by MongoDB.

The simplest workaround is to place the Data/data/db files in the User’s directory and then use a --dbpath statement when running mongod.

Unless you are installing on a server or have multiple users sharing a mac, there is no reason for these files to be anywhere other than the user’s directory anyway.

I have now moves the file structure to my Mac User directory and I use a --dbpath statement when running mongod.

It works with sudo - so I can complete the tutorials. I think it very unlikely I will ever use MongoDB in a production environment but, if I do, I will have another look at sudo and access permissions.

Resolving this has been an unpleasant and lengthy process and, if MongoDB were serious about Mac users, they would have resolved this issue ages ago. I dpn’t like to spend time in the terminal - for me this is not what a Mac is all about…

Hi,

If you installed using the mongodb-community recipe as per Install MongoDB Community Edition on macOS, the installation should have created:

The expected way to manage MongoDB would be using brew services (for example: brew services start mongodb-community), which will use the default configuration file and paths. You can change the dbPath and other options by editing the configuration file before starting MongoDB.

If you start mongod manually (as per your initial example), you will have to provide the --dbpath and other desired options. The legacy hardcoded default dbPath of /data/db is not supported in Catalina.

Regards,
Stennie

2 Likes

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.