Mongod.db will not start--as if /etc/mongod.conf ignored

1,520 views
Skip to first unread message

Carl Seiler

unread,
Feb 15, 2019, 12:35:49 PM2/15/19
to mongodb-user
Using MongoDB v4.0.6 installed in Lubuntu 18.0.4.2

/etc/mongod.conf reads as such:

# mongod.conf

# for documentation of all options, see:

# Where and how to store data.
storage:
dbPath: /media/carl/data/data/db
journal:
enabled: true
# engine:
# mmapv1:
# wiredTiger:

# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /media/carl/data/data/db/log/mongod.log

# network interfaces
net:
port: 27017
bindIp: 172.17.2.92


# how the process runs
processManagement:
timeZoneInfo: /usr/share/zoneinfo

#security:

#operationProfiling:

#replication:

#sharding:

## Enterprise-Only Options:

#auditLog:

#snmp:


Ran sudo chown -R mongodb:mongodb /media/carl/data/data/db and sudo chown -R mongodb:mongodb /media/carl/data/data/db/log 
because it is my understanding that the service runs as user mongodb per the docs found at https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/ 

When I attempt to start the service with sudo service mongod start the service fails to start.  Typing sudo servuce mongod status gives:

mongod.service - MongoDB Database Server
   Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: 
   Active: failed (Result: exit-code) since Fri 2019-02-15 10:40:16 CST; 6s ago
  Process: 3257 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited
 Main PID: 3257 (code=exited, status=1/FAILURE)

Feb 15 10:40:16 carl-VirtualBox systemd[1]: Started MongoDB Database Server.
Feb 15 10:40:16 carl-VirtualBox mongod[3257]: 2019-02-15T10:40:16.154-0600 F CON
Feb 15 10:40:16 carl-VirtualBox systemd[1]: mongod.service: Main process exited,
Feb 15 10:40:16 carl-VirtualBox systemd[1]: mongod.service: Failed with result '

Starting mongod directly from the command line gives:  
2019-02-15T11:00:15.374-0600 I CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2019-02-15T11:00:15.376-0600 I CONTROL  [initandlisten] MongoDB starting : pid=3943 port=27017 dbpath=/data/db 64-bit host=carl-VirtualBox
2019-02-15T11:00:15.376-0600 I CONTROL  [initandlisten] db version v4.0.6
2019-02-15T11:00:15.376-0600 I CONTROL  [initandlisten] git version: caa42a1f75a56c7643d0b68d3880444375ec42e3
2019-02-15T11:00:15.376-0600 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.1.0g  2 Nov 2017
2019-02-15T11:00:15.377-0600 I CONTROL  [initandlisten] allocator: tcmalloc
2019-02-15T11:00:15.377-0600 I CONTROL  [initandlisten] modules: none
2019-02-15T11:00:15.377-0600 I CONTROL  [initandlisten] build environment:
2019-02-15T11:00:15.377-0600 I CONTROL  [initandlisten]     distmod: ubuntu1804
2019-02-15T11:00:15.377-0600 I CONTROL  [initandlisten]     distarch: x86_64
2019-02-15T11:00:15.377-0600 I CONTROL  [initandlisten]     target_arch: x86_64
2019-02-15T11:00:15.377-0600 I CONTROL  [initandlisten] options: {}
2019-02-15T11:00:15.377-0600 I STORAGE  [initandlisten] exception in initAndListen: NonExistentPath: Data directory /data/db not found., terminating
2019-02-15T11:00:15.377-0600 I NETWORK  [initandlisten] shutdown: going to close listening sockets...
2019-02-15T11:00:15.377-0600 I NETWORK  [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2019-02-15T11:00:15.377-0600 I CONTROL  [initandlisten] now exiting
2019-02-15T11:00:15.377-0600 I CONTROL  [initandlisten] shutting down with code:100

Note the dbpath=/data/db and Data directory /data/db not found which is where I had it originally before I decided to move it to an xfs file system drive. Mounted at /media/carl/data   
It is almost as if it is reading a different /etc/mongod.conf and ignoring the fact that it should now be looking in /media/carl/data/data/db instead. Is there some mongod.conf it is reading, and is there some way I can get it to tell me what mongod.conf that might be?

Thanks

Carl Seiler

unread,
Feb 19, 2019, 11:54:24 AM2/19/19
to mongodb-user
Just for further information, I found that I can start it from the command line using sudo mongod --conf /etc/mongod.conf  I still cannot start it with sudo service mongod start

Does the data directory or log directory have to have some certain permission I'm missing?  What about /etc/mongod.conf?

File: /media/carl/data/data/db
  Size: 4096            Blocks: 8          IO Block: 4096   directory
Device: 811h/2065d      Inode: 4194400     Links: 5
Access: (0775/drwxrwxr-x)  Uid: (  112/ mongodb)   Gid: (  123/ mongodb)
Access: 2019-02-19 10:23:37.361184708 -0600
Modify: 2019-02-19 10:46:14.309896087 -0600
Change: 2019-02-19 10:46:14.309896087 -0600
 Birth: -

  File: /etc/mongod.conf
  Size: 648             Blocks: 8          IO Block: 4096   regular file
Device: 801h/2049d      Inode: 132118      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2019-02-19 09:51:43.690802349 -0600
Modify: 2019-02-15 10:16:29.040495776 -0600
Change: 2019-02-15 10:16:29.040495776 -0600
 Birth: 

Carl Seiler

unread,
Feb 19, 2019, 4:15:55 PM2/19/19
to mongodb-user
Found that I was missing the init.d file found here:


Now it is clearly reading my mongod.conf file because it is reporting:

  Feb 19 14:52:44 carl-VirtualBox mongod[4728]: 2019-02-19T14:52:44.250-0600 F CONTROL  [main] Failed global initialization: FileNotOpen: Failed probe for "/media/carl/data/data/db/log/mongod.log": Permission denied
 
and stat mongod.log yields:

  File: mongod.log
  Size: 22327      Blocks: 48         IO Block: 4096   regular file
Device: 811h/2065d Inode: 8409185     Links: 1
Access: (0775/-rwxrwxr-x)  Uid: (  112/ mongodb)   Gid: (  123/ mongodb)
Access: 2019-02-19 14:40:21.187815147 -0600
Modify: 2019-02-19 14:36:32.629593148 -0600
Change: 2019-02-19 14:36:32.629593148 -0600
 Birth: -

And mongodb appears to be the user specified in the init.d file:

DAEMONUSER=${DAEMONUSER:-mongodb}
DAEMONGROUP=${DAEMONGROUP:-mongodb}

If I'm reading that right. What am I missing?

Oleg Toropov

unread,
Feb 19, 2019, 7:23:38 PM2/19/19
to mongod...@googlegroups.com
Did you check permission on folders and file "/media/carl/data/data/db/log/mongod.log"?


--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/fa4656e1-51eb-44f2-a577-26042df025f4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
//
// Oleg V.Toropov, MCP | oleg.t...@gmail.com
// -----------------------------------------------------------------
// I have discovered that if I read enough stuff that's over my head,
// I actually begin to understand some of it.
//

Kevin Adistambha

unread,
Feb 19, 2019, 11:16:54 PM2/19/19
to mongodb-user

Hi Carl,

As Oleg mentioned, this sounds like a permission issue in your custom data directory.

The log output from sudo service mongod start you provided appear truncated, but I assume it look similar to this:

● mongod.service - MongoDB Database Server
   Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Wed 2019-02-20 04:05:14 UTC; 3s ago
     Docs: https://docs.mongodb.org/manual
  Process: 2579 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=1/FAILURE)
 Main PID: 2579 (code=exited, status=1/FAILURE)

Feb 20 04:05:14 xxxx systemd[1]: Started MongoDB Database Server.
Feb 20 04:05:14 xxxx mongod[2579]: 2019-02-20T04:05:14.761+0000 F CONTROL  [main] Failed global initialization: FileNotOpen: Failed to open "/media/mdb/data/mongod.log"
Feb 20 04:05:14 xxxx systemd[1]: mongod.service: Main process exited, code=exited, status=1/FAILURE
Feb 20 04:05:14 xxxx systemd[1]: mongod.service: Failed with result 'exit-code'.

Note the line Failed to open ... above. Is your output showing similar thing? In my experiment, this was caused by the mongodb user not having access to the directory /media/mdb/data.

You might want to double check if the directories /media, /media/carl, /media/carl/data are all world-executable (permission set to at least 755).

Best regards,
Kevin

Carl Seiler

unread,
Feb 20, 2019, 9:38:01 AM2/20/19
to mongodb-user
Thank you Oleg and Kevin,

I know we are on the right track here, and I have been setting the permissions on everything.  Just to make sure I went through and did:

 sudo chmod 755 /media
 sudo chmod 755 /media/carl
 sudo chmod 755 /media/carl/data
 sudo chmod 755 /media/carl/data/data

When I go through, each of them have permissions 755 now.  /media/carl/data/data has 775 and belongs to mongodb:mongodb, and the same with /media/carl/data/data/db/log

So I attempt to start the service:

 sudo service mongod start 

When I do sudo service mongo status I get (sorry about the truncated version in earlier post):

● mongod.service - MongoDB Database Server
   Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Wed 2019-02-20 08:12:27 CST; 2s ago
  Process: 2639 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=14)
 Main PID: 2639 (code=exited, status=14)

Feb 20 08:12:26 carl-VirtualBox systemd[1]: Started MongoDB Database Server.
Feb 20 08:12:27 carl-VirtualBox systemd[1]: mongod.service: Main process exited, code=exited, status=14/n/a
Feb 20 08:12:27 carl-VirtualBox systemd[1]: mongod.service: Failed with result 'exit-code'.

Note that I'm not getting the "failed to open" although I was getting that a few days ago when I first posted the problem.

However, I am clearly now getting better logging now that my service process can write to the log file:

2019-02-20T08:12:27.225-0600 E STORAGE  [initandlisten] WiredTiger error (13) [1550671947:225035][2639:0x7f80a0945a40], connection: __directory_list_worker, 48: /media/carl/data/data/db/journal: directory-list: opendir: Permission denied Raw: [1550671947:225035][2639:0x7f80a0945a40], connection: __directory_list_worker, 48: /media/carl/data/data/db/journal: directory-list: opendir: Permission denied
2019-02-20T08:12:27.230-0600 E STORAGE  [initandlisten] WiredTiger error (13) [1550671947:230011][2639:0x7f80a0945a40], connection: __directory_list_worker, 48: /media/carl/data/data/db/journal: directory-list: opendir: Permission denied Raw: [1550671947:230011][2639:0x7f80a0945a40], connection: __directory_list_worker, 48: /media/carl/data/data/db/journal: directory-list: opendir: Permission denied
2019-02-20T08:12:27.231-0600 W STORAGE  [initandlisten] Failed to start up WiredTiger under any compatibility version.
2019-02-20T08:12:27.231-0600 F STORAGE  [initandlisten] Reason: 13: Permission denied
2019-02-20T08:12:27.231-0600 F -        [initandlisten] Fatal Assertion 28595 at src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp 704
2019-02-20T08:12:27.231-0600 F -        [initandlisten] 

***aborting after fassert() failure

So, I changed ownership on the directory /media/carl/data/data/db/journal to mongodb and changed permissions to 755 and TADA!  

I think it was permissions on the journal directory and my logging directory.  The journal directory was causing the main problem and I couldn't at first see what the problem was because it wasn't able to write to the log.  The journal directory belonged to my main user and not mongodb.  I think it was created when I ran it from simply running mongod --config /etc/mongod.conf  Thereafter, running as a service couldn't get it to work because it belonged to user carl not mongodb.

Thanks for pointing me in the right direction.  I just had to keep digging for the permissions for the right directory.

Oleg Toropov

unread,
Feb 20, 2019, 3:39:54 PM2/20/19
to mongod...@googlegroups.com
Glad it works out for you... I have a script somewhere that goes and change permission/owner for all tree sub-directories...


--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages