2

I'm running ec2 instance of os Ubuntu 16.04.

I recently tried to upgrade my mongodb from 3.2 to 3.6.

And I tried to run sudo service mongod start and mongod service failed to start.

Below is the error message.

mongod.service - High-performance, schema-free document-oriented 

database
   Loaded: loaded (/etc/systemd/system/mongod.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Mon 2018-03-05 05:48:12 UTC; 11s ago
     Docs: https://docs.mongodb.org/manual
  Process: 18587 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=217/USER)
 Main PID: 16567 (code=exited, status=100)

Mar 05 05:48:12 ip-172-31-18-34 systemd[1]: Starting High-performance, schema-free document-oriented database...
Mar 05 05:48:12 ip-172-31-18-34 systemd[18587]: mongod.service: Failed at step USER spawning /usr/bin/mkdir: No such proc
Mar 05 05:48:12 ip-172-31-18-34 systemd[1]: mongod.service: Control process exited, code=exited status=217
Mar 05 05:48:12 ip-172-31-18-34 systemd[1]: Failed to start High-performance, schema-free document-oriented database.
Mar 05 05:48:12 ip-172-31-18-34 systemd[1]: mongod.service: Unit entered failed state.
Mar 05 05:48:12 ip-172-31-18-34 systemd[1]: mongod.service: Failed with result 'exit-code'.

And I never edited a single line of default mongod.service file.

How can I fix this issue?

Gompro
  • 2,247
  • 1
  • 16
  • 26

4 Answers4

2

If you have just copied mongod.service file from somewhere you should edit User in [Service] section

Greenev
  • 871
  • 6
  • 23
2
Changing ownership of "/var/lib/mongodb" directory worked for me
Command to change ownership:
"sudo chown -R mongodb:mongodb /var/lib/mongodb"

**Old response:**
$ sudo systemctl status mongodb
● mongodb.service - MongoDB Database
   Loaded: loaded (/etc/systemd/system/mongodb.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Wed 2019-07-31 18:52:49 IST; 17h ago
     Docs: https://docs.mongodb.org/manual
 Main PID: 13728 (code=exited, status=217/USER)

Jul 31 18:52:49 LAP-LIN-712 systemd[1]: Started MongoDB Database.
Jul 31 18:52:49 LAP-LIN-712 systemd[13728]: mongodb.service: Failed to determine user credentials: No such process
Jul 31 18:52:49 LAP-LIN-712 systemd[13728]: mongodb.service: Failed at step USER spawning /usr/bin/mongod: No such process
Jul 31 18:52:49 LAP-LIN-712 systemd[1]: mongodb.service: Main process exited, code=exited, status=217/USER
Jul 31 18:52:49 LAP-LIN-712 systemd[1]: mongodb.service: Failed with result 'exit-code'.

**New Response:**
$ sudo systemctl status mongodb
● mongodb.service - MongoDB Database
   Loaded: loaded (/etc/systemd/system/mongodb.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2019-08-01 11:54:10 IST; 8s ago
     Docs: https://docs.mongodb.org/manual
 Main PID: 8143 (mongod)
    Tasks: 20 (limit: 4915)
   CGroup: /system.slice/mongodb.service
           └─8143 /usr/bin/mongod --quiet --config /etc/mongod.conf
Anju
  • 29
  • 1
  • 2
  • Hi @Anju, explain what your code do to help other user to understand. Thank you! – red Aug 01 '19 at 07:02
  • There is no code in this just I have run Linux command "chmod" to change the permission of mongodb directory – Anju Aug 02 '19 at 08:55
0

/usr/bin/mongod - No such process. ---> This error means you have placed the mongod binary in someother path instead of the default one. Try changing the path in mongod.service file and reattempt it using service start mongodb

kk.
  • 3,747
  • 12
  • 36
  • 67
kalairaj
  • 11
  • 2
-1

For me it was solved by commenting "User" and "Group" directives in the service file as described here. I hope it helps somebody.

crvio
  • 19
  • 3
  • 1
    That makes the service run as root which can cause problems including incorrect file ownership and running code with elevated privileges which can make security vulnerability much worse. – TheAmigo May 18 '21 at 02:58
  • I see the process running as a non root user though. – crvio Jun 18 '21 at 01:37
  • There's a comment in the link I shared that states it behaves in the same way. Yet, I might not be getting your point. But I think that the process running as a non root process in my case rules out any security issue. Thanks for your input anyway. – crvio Jun 18 '21 at 01:42