Discussion:
[mongodb-user] unable to start mongod as a service but am able to start it from shell
Upendra Sharma
2018-12-06 19:43:01 UTC
Permalink
Hi All,
I am facing a weird problem.
I am unable to start mongod using systemd but when I sudo mongodb and try
to start the daemon it works fine. We have checked the permissions of all
files, namely dbpath, pid and logs files, and they all belong to the user
mongodb.

*-- failure to start as a service -- *
[***@cm-db-1 mongo]# systemctl status mongod.service
● mongod.service - High-performance, schema-free document-oriented database
Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor
preset: disabled)
Active: failed (Result: exit-code) since Wed 2018-12-05 21:41:11 UTC;
56s ago
Process: 6991 ExecStart=/usr/bin/mongod $OPTIONS run (code=exited,
status=100)
Main PID: 24086 (code=exited, status=0/SUCCESS)

Dec 05 21:41:11 cm-db-1.ci80.lsf04.ibmwhc.net systemd[1]: Starting
High-performance, schema-free document-oriented database...
Dec 05 21:41:11 cm-db-1.ci80.lsf04.ibmwhc.net mongod[6991]: about to fork
child process, waiting until server is ready for connections.
Dec 05 21:41:11 cm-db-1.ci80.lsf04.ibmwhc.net mongod[6991]: forked process:
7032
Dec 05 21:41:11 cm-db-1.ci80.lsf04.ibmwhc.net mongod[6991]: ERROR: child
process failed, exited with error number 100
Dec 05 21:41:11 cm-db-1.ci80.lsf04.ibmwhc.net systemd[1]: mongod.service:
control process exited, code=exited status=100
Dec 05 21:41:11 cm-db-1.ci80.lsf04.ibmwhc.net systemd[1]: Failed to start
High-performance, schema-free document-oriented database.
Dec 05 21:41:11 cm-db-1.ci80.lsf04.ibmwhc.net systemd[1]: Unit
mongod.service entered failed state.
Dec 05 21:41:11 cm-db-1.ci80.lsf04.ibmwhc.net systemd[1]: mongod.service
failed.

*-- successful start from commandline --*
-bash-4.2$ /usr/bin/mongod --quiet -f /etc/mongod.conf run
about to fork child process, waiting until server is ready for connections.
forked process: 30878
child process started successfully, parent exiting
--
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 mongodb-***@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/e8e1e81a-ec8f-477b-9fe7-8c9ea0c997d1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Upendra Sharma
2018-12-07 01:57:31 UTC
Permalink
Found out the root cause and the fix:
Root Cause: the security context of mongodb data files had changed; I could
confirm it by comparing the results of *ls -Z* data files between a working
server and the failed one.
Fix: resetting it with *chcon* fixed the problem.
Post by Upendra Sharma
Hi All,
I am facing a weird problem.
I am unable to start mongod using systemd but when I sudo mongodb and try
to start the daemon it works fine. We have checked the permissions of all
files, namely dbpath, pid and logs files, and they all belong to the user
mongodb.
*-- failure to start as a service -- *
● mongod.service - High-performance, schema-free document-oriented database
Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor
preset: disabled)
Active: failed (Result: exit-code) since Wed 2018-12-05 21:41:11 UTC;
56s ago
Process: 6991 ExecStart=/usr/bin/mongod $OPTIONS run (code=exited,
status=100)
Main PID: 24086 (code=exited, status=0/SUCCESS)
Dec 05 21:41:11 cm-db-1.ci80.lsf04.ibmwhc.net systemd[1]: Starting
High-performance, schema-free document-oriented database...
Dec 05 21:41:11 cm-db-1.ci80.lsf04.ibmwhc.net mongod[6991]: about to fork
child process, waiting until server is ready for connections.
Dec 05 21:41:11 cm-db-1.ci80.lsf04.ibmwhc.net mongod[6991]: forked
process: 7032
Dec 05 21:41:11 cm-db-1.ci80.lsf04.ibmwhc.net mongod[6991]: ERROR: child
process failed, exited with error number 100
control process exited, code=exited status=100
Dec 05 21:41:11 cm-db-1.ci80.lsf04.ibmwhc.net systemd[1]: Failed to start
High-performance, schema-free document-oriented database.
Dec 05 21:41:11 cm-db-1.ci80.lsf04.ibmwhc.net systemd[1]: Unit
mongod.service entered failed state.
Dec 05 21:41:11 cm-db-1.ci80.lsf04.ibmwhc.net systemd[1]: mongod.service
failed.
*-- successful start from commandline --*
-bash-4.2$ /usr/bin/mongod --quiet -f /etc/mongod.conf run
about to fork child process, waiting until server is ready for connections.
forked process: 30878
child process started successfully, parent exiting
--
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 mongodb-***@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/1c58c1cb-8044-4459-978a-7f509b887e0e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...