MongoDB installation Default and Manual on Ubuntu 20.04

Hi ,

I have 2 questions.
i) I have installed MongoDB on Ubuntu 20.04 using apt
MongoDB install

I see the below permissions . Are they correct?

id mongodb
uid=116(mongodb) gid=65534(nogroup) groups=65534(nogroup),122(mongodb)

ii) I installed another MongoDB manually on Ubuntu 20.04 and created MongoDB data folder as
/mongodb/replsetname/data
What should be the permissions on the above directory structure for MongoDB user
chown -R mongodb:mongodb /mongodb -------> is this correct
chmod -R 755 /mongodb -------> is this correct

Thanks
{“Satya”}

Hi Team,

@Jack_Woehr @chris @Britt_Snyman
Can someone please respond to the above questions.

Thanks
{“Satya”}

What are the permissions on the data directory on the system where you installed automatically?

Thanks @Jack_Woehr for the update.

What are the permissions on the data directory on the system where you installed automatically?

ls -lrt /var/lib/mongodb
total 340
-rw------- 1 mongodb mongodb 21 Jun 9 06:48 WiredTiger.lock
-rw------- 1 mongodb mongodb 50 Jun 9 06:48 WiredTiger
-rw------- 1 mongodb mongodb 114 Jun 9 06:48 storage.bson
drwx------ 2 mongodb mongodb 4096 Jun 9 06:52 testdb
drwx------ 2 mongodb mongodb 4096 Jun 9 06:55 local
drwx------ 2 mongodb mongodb 4096 Jun 9 06:55 config
drwx------ 2 mongodb mongodb 4096 Jun 9 06:55 admin
drwx------ 2 mongodb mongodb 4096 Oct 16 01:23 journal
drwx------ 2 mongodb mongodb 4096 Oct 16 03:43 diagnostic.data
-rw------- 1 mongodb mongodb 1796 Oct 16 03:43 WiredTiger.turtle
-rw------- 1 mongodb mongodb 32768 Oct 16 03:43 WiredTigerHS.wt
-rw------- 1 mongodb mongodb 36864 Oct 16 03:43 sizeStorer.wt
-rw------- 1 mongodb mongodb 36864 Oct 16 03:43 _mdb_catalog.wt
-rw------- 1 mongodb mongodb 192512 Oct 16 03:43 WiredTiger.wt
-rw------- 1 mongodb mongodb 0 Oct 16 03:43 mongod.lock

ls -lrt /var/log/mongodb
total 97948
-rw------- 1 mongodb mongodb 100292917 Oct 16 03:43 mongod.log

It is clear from the above output that just the last directory named “mongodb” in side /var/lib/mongodb and /var/log/mongodb are owned by the OS user “mongodb”

My query is incase I create a /mongodb/replsetname/data
What should be the permissions for MongoDB user
chown -R mongodb:mongodb /mongodb -------> is this correct
chmod -R 755 /mongodb -------> is this correct

What I mean
can mongodb user own whole /mongodb, instead of having permissions on the last sub directory as seen in default installation
Is there any harm, if mongodb OS user owns whole /mongodb

Thanks
{“Satya”}

chown’ing the whole data directory to mongodb should be correct.
chmod’ing everything 755 is wrong.

  1. files should be 600
  2. directories should be 700

At least, that’s the way it is in my installation.

PLEASE NOTE the following: https://www.mongodb.com/docs/manual/reference/configuration-options/#mongodb-setting-storage.dbPath

When one asks questions of this sort, it’s usually an indication that one is trying to do something that one shouldn’t be doing :grin:

1 Like

Thanks @Jack_Woehr for the update.

When one asks questions of this sort, it’s usually an indication that one is trying to do something that one shouldn’t be doing :grin:

I respect the gray hairs :smile:

Thanks
{“Satya”}

1 Like

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