Mongod Service start exits with code 100
Asked Answered
H

7

41

Problem

My mongo service does not start anymore:

root@machine ~ # service mongod start
root@machine ~ # service mongod status
● mongod.service - High-performance, schema-free document-oriented database
   Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Tue 2017-08-15 12:03:51 CEST; 2s ago
     Docs: https://docs.mongodb.org/manual
  Process: 26942 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=100)
 Main PID: 26942 (code=exited, status=100)

Aug 15 12:03:50 machine systemd[1]: Started High-performance, schema-free document-oriented database.
Aug 15 12:03:51 machine systemd[1]: mongod.service: Main process exited, code=exited, status=100/n/a
Aug 15 12:03:51 machine systemd[1]: mongod.service: Unit entered failed state.
Aug 15 12:03:51 machine systemd[1]: mongod.service: Failed with result 'exit-code'.

Where exit code 100 is blurry defined as:

Returned by mongod when the process throws an uncaught exception.

What I did

First, I have installed my mongodb (3.4.7) on Ubuntu 16.04.2 LTS via the official guide.

Starting and stopping the service worked fine. So I continued to enable authentication (again via the official guide).

Then I added the service to be able to run on server startup.

root@machine ~ # systemctl enable mongod.service

mongod.conf

I also edited my config file, which is passed a yaml linter:

# Where and how to store data.
storage:
  dbPath: /var/lib/mongodb
  journal:
    enabled: true

#  engine: mmapv1
#  mmapv1:
#  wiredTiger:

# where to write logging data.
systemLog:
  destination: file
  logAppend: true
  path: /var/log/mongodb/mongod.log

# network interfaces
net:
  port: 27017
  bindIp: 127.0.0.1


#processManagement:

security:
  authorization: enabled

The ownership of the file is

root@machine ~ # ls -la /etc/ | grep mongo
-rw-r--r--   1 root  root     599 Aug 15 11:42 mongod.conf

DbPath

I know there are issues with the dbpath so this is what /var/lib/mongodb has in terms of ownership:

root@ machine ~ # ls -la /var/lib/ | grep mongo
drwxr-xr-x  4 mongodb      mongodb      4096 Aug 15 11:54 mongodb

Service List

When listing all services via service --status-all there is no entry for any mongo related service.

Somebody has a clue what could cause the issue?


UPDATE

As suggested I ran the following command (with a slight modification):

root@machine ~ /usr/bin/mongod --verbose --config /etc/mongod.conf &
[1] 28495

When I get it right, this is a direct execute of the binary. This allows me now to at least login into mongo shell:

root@machine ~ # mongo
MongoDB shell version v3.4.7
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.7
> 

However, the service status is still remaining failed with exit code 100.


UPDATE UPDATE

When typing root@machine ~ # /usr/bin/mongod --verbose

I receive the following error:

2017-08-15T13:45:40.973+0200 I CONTROL  [initandlisten] MongoDB starting : pid=28642 port=27017 dbpath=/data/db 64-bit host=machine
2017-08-15T13:45:40.973+0200 I CONTROL  [initandlisten] db version v3.4.7
2017-08-15T13:45:40.973+0200 I CONTROL  [initandlisten] git version: cf38c1b8a0a8dca4a11737581beafef4fe120bcd
2017-08-15T13:45:40.973+0200 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.2g  1 Mar 2016
2017-08-15T13:45:40.973+0200 I CONTROL  [initandlisten] allocator: tcmalloc
2017-08-15T13:45:40.973+0200 I CONTROL  [initandlisten] modules: none
2017-08-15T13:45:40.973+0200 I CONTROL  [initandlisten] build environment:
2017-08-15T13:45:40.973+0200 I CONTROL  [initandlisten]     distmod: ubuntu1604
2017-08-15T13:45:40.973+0200 I CONTROL  [initandlisten]     distarch: x86_64
2017-08-15T13:45:40.973+0200 I CONTROL  [initandlisten]     target_arch: x86_64
2017-08-15T13:45:40.973+0200 I CONTROL  [initandlisten] options: { systemLog: { verbosity: 1 } }
2017-08-15T13:45:40.973+0200 D -        [initandlisten] User Assertion: 29:Data directory /data/db not found. src/mongo/db/service_context_d.cpp 98
2017-08-15T13:45:40.973+0200 I STORAGE  [initandlisten] exception in initAndListen: 29 Data directory /data/db not found., terminating
2017-08-15T13:45:40.973+0200 I NETWORK  [initandlisten] shutdown: going to close listening sockets...
2017-08-15T13:45:40.973+0200 I NETWORK  [initandlisten] shutdown: going to flush diaglog...
2017-08-15T13:45:40.973+0200 I CONTROL  [initandlisten] now exiting
2017-08-15T13:45:40.973+0200 I CONTROL  [initandlisten] shutting down with code:100
Holystone answered 15/8, 2017 at 10:26 Comment(5)
Start the service through terminal /usr/bin/mongod --config /etc/mongodb.conf and see what errors do you see?Mediative
I update my descriptionHolystone
I don't see any update error? I don't want to see the service status, i want you to check running it in a normal terminalMediative
No errors, when running the command, just the PID printed [1] 28495Holystone
Okie try /usr/bin/mongod --verbose don't pass your config and no &, also check contents of /var/log/mongodb/mongod.logMediative
D
114

You may still have some problems with the permissions in your data directory. Especially if you have run mongod from the terminal to start with.

I find that the data files are created under root not the mongodb user when you run from the terminal. To fix ..

sudo chown -R mongodb:mongodb /var/lib/mongodb/*
Defeasance answered 2/12, 2017 at 7:33 Comment(5)
Thank you, I will accept it as an answer but I can't confirm it anymore, since I already have a fresh install on a an updated Ubuntu 16.04. LTS with mongo 3.6.Holystone
Thanks! Worked for me too. Also had to sudo chown -R mongodb:mongodb /var/lib/mongodb. I was getting a mongod.service: Failed with result 'core-dump'. until I did that.Jacinthe
Is this apply also to mongo version 2.6?Breeder
It's really bad practice to run a command like sudo chown -R mongodb:mongodb * . You're one symbol/command away from f***ing up permissions on your OS. Always use full paths to recursively change a dir's permissions.Orientalism
for me, I was running mongodb -auth for some user pass tweaks, which caused this. note to self, chown after auth.Queston
P
15
rm /var/lib/mongodb/mongod.lock
systemctl restart mongod
systemctl status mongod

Try this!

Pannier answered 21/5, 2018 at 14:32 Comment(2)
Can you elaborate on what that actually does please?Torpor
@Torpor Lock files are used to prevent other processes or programs from writing to a file or accessing a resource when it is already in use or being modified to. This is a safeguard to prevent conflicts or corruption from occurring. Ideally these files should be deleted when the process exits, however if it is terminated uncleanly, these files may not get deleted, which makes it appear as if it is still in use when you try to start the service. Note: For this reason you must always apply extreme caution when deleting a lock file to ensure that it is in fact not being used by another process.Ormand
S
1

Remove the mongod.lock file under 'dbath', and it should start without issues.

Sabir answered 22/6, 2018 at 1:32 Comment(0)
A
1

I know it's quite late, but maybe this will help someone in need.

I checked the /var/log/mongodb and found this:

Failed to unlink socket file /tmp/mongodb-27017.sock Operation not permitted

I guess that permission is set to root, not mongodb because I used sudo to start mongod. (Maybe someone can help clarifying this)

So the solution is to delete that /tmp/mongodb-27017.sock and restart the service again. At least that worked for me. (Sorry for my bad English)

https://mkyong.com/mongodb/mongodb-failed-to-unlink-socket-file-tmpmongodb-27017/

Abradant answered 2/7, 2020 at 15:55 Comment(0)
C
0

Check the log file on dbath . This is located normally on /var/log/mongodb The log file is mongodb.log

The problem for me was low space on disk... I had the same error message you have.

I had no empty space on disk so I have used the smallfiles options on the file /etc/mongodb.conf Simply add the line on this configuration file: smallfiles = true

Chisel answered 26/8, 2020 at 1:12 Comment(0)
H
0

I use mongoDB at Windows Desktop, so

start it as administrator

or

from cmd with admin.

Then check if it already started))))))

It's important

Because if you try to start it twice it will also give you

exit code 100

Maybe you should check your start args.

My starter:

"C:\Program Files\MongoDB\Server\5.0\bin\mongod.exe" --dbpath "C:\Program Files\MongoDB\Server\5.0\data" --auth 
Hecatomb answered 14/3, 2022 at 15:24 Comment(0)
T
-1

If you are on windows simply follow some simple steps and you are ready to go.

  1. Go to your C Drive
  2. create a folder named data
  3. Move inside the created data folder and create another folder db
  4. Close the windows and refresh.
  5. Your problem is solved.
Tsingyuan answered 11/7, 2022 at 5:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.