-1

I am trying to setup a replicaset for my dev environment, and have three machines running debian 9.3 stretch with a mongod service. The replicaset is working, and all seems okay.

But when I reboot one of the servers the mongod service doesn't come up. When I check the status it says it failed status=48

    mongod.service - MongoDB Database Server
   Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Tue 2018-08-28 22:17:37 CEST; 10s ago
     Docs: https://docs.mongodb.org/manual
  Process: 392 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=48)
 Main PID: 392 (code=exited, status=48)
      CPU: 33ms

aug 28 22:17:37 staging-manager-1 systemd[1]: Started MongoDB Database Server.
aug 28 22:17:37 staging-manager-1 mongod[392]: 2018-08-28T22:17:37.389+0200 I CONTROL  [main] Automatically disabling TLS 1.0, to fo
aug 28 22:17:37 staging-manager-1 systemd[1]: mongod.service: Main process exited, code=exited, status=48/n/a
aug 28 22:17:37 staging-manager-1 systemd[1]: mongod.service: Unit entered failed state.
aug 28 22:17:37 staging-manager-1 systemd[1]: mongod.service: Failed with result 'exit-code'.

I already enabled the service with systemctl enable mongod and in the status I can see that it is indeed enabled, but why does it fail after I reboot the machine?

update:

root@machine:/home/<user># journalctl -u mongod
-- Logs begin at Thu 2018-08-30 21:11:33 CEST, end at Thu 2018-08-30 21:26:42 CEST. --
aug 30 21:11:33 staging-manager-1 systemd[1]: Started MongoDB Database Server.
aug 30 21:11:33 staging-manager-1 mongod[398]: 2018-08-30T21:11:33.388+0200 I CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
aug 30 21:11:33 staging-manager-1 systemd[1]: mongod.service: Main process exited, code=exited, status=48/n/a
aug 30 21:11:33 staging-manager-1 systemd[1]: mongod.service: Unit entered failed state.
aug 30 21:11:33 staging-manager-1 systemd[1]: mongod.service: Failed with result 'exit-code'.


root@machine:/home/<user># ll /etc/init
total 48
-rw-r--r-- 1 root root  278 mei 29  2017 anacron.conf
-rw-r--r-- 1 root root 1875 jul 18 21:01 docker.conf
-rw-r--r-- 1 root root 2493 jun  2  2015 networking.conf
-rw-r--r-- 1 root root  933 jun  2  2015 network-interface.conf
-rw-r--r-- 1 root root  530 jun  2  2015 network-interface-container.conf
-rw-r--r-- 1 root root 1756 jun  2  2015 network-interface-security.conf
-rw-r--r-- 1 root root 1359 mrt 14  2017 sddm.conf
-rw-r--r-- 1 root root  637 mrt  1 13:36 ssh.conf
-rw-r--r-- 1 root root  337 jun 13 22:20 udev.conf
-rw-r--r-- 1 root root  360 jun 13 22:20 udevmonitor.conf
-rw-r--r-- 1 root root  352 jun 13 22:20 udevtrigger.conf
-rw-r--r-- 1 root root  138 jan 23  2017 usb-modeswitch-upstart.conf
root@machine:/home/<user># ll /etc/init.d
total 168
-rwxr-xr-x 1 root root 5336 feb  1  2016 alsa-utils
-rwxr-xr-x 1 root root 2014 mei 29  2017 anacron
-rwxr-xr-x 1 root root 8181 apr  5 20:32 apache2
-rwxr-xr-x 1 root root 2489 mei 13 18:52 apache-htcacheclean
-rwxr-xr-x 1 root root 2401 jan 23  2017 avahi-daemon
-rwxr-xr-x 1 root root 2948 sep 13  2017 bluetooth
-rwxr-xr-x 1 root root 1904 nov 18  2015 cgroupfs-mount
-rwxr-xr-x 1 root root 1232 apr  7  2017 console-setup.sh
-rwxr-xr-x 1 root root 3049 okt  7  2017 cron
-rwxr-xr-x 1 root root 2816 jul 10 15:57 cups
-rwxr-xr-x 1 root root 1961 jan 19  2017 cups-browsed
-rwxr-xr-x 1 root root 2813 mrt  2 09:59 dbus
-rwxr-xr-x 1 root root 3843 jul 18 21:01 docker
-rwxr-x--- 1 root root 4285 jul 20 07:27 elasticsearch
-rwxr-xr-x 1 root root 3033 aug  9 21:30 gdm3
-rwxr-xr-x 1 root root 1604 feb  2  2017 gdomap
-rwxr-xr-x 1 root root 3809 mrt  7 19:29 hwclock.sh
-rwxr-xr-x 1 root root 1479 mei 19  2016 keyboard-setup.sh
-rwxr-xr-x 1 root root 2044 dec 26  2016 kmod
-rwxr-xr-x 1 root root 2241 apr 26  2017 minissdpd
-rwxr-xr-x 1 root root 4597 sep 16  2016 networking
-rwxr-xr-x 1 root root 1757 mrt 18  2017 network-manager
-rwxr-xr-x 1 root root  612 dec  4  2015 pppd-dns
-rwxr-xr-x 1 root root 1191 mei 17 12:56 procps
-rwxr-xr-x 1 root root 4355 dec 10  2017 rsync
-rwxr-xr-x 1 root root 2868 jan 18  2017 rsyslog
-rwxr-xr-x 1 root root 2330 mei 21  2017 saned
-rwxr-xr-x 1 root root 1222 apr  3  2017 screen-cleanup
-rwxr-xr-x 1 root root 1808 mrt 14  2017 sddm
-rwxr-xr-x 1 root root 2117 aug  2  2017 speech-dispatcher
-rwxr-xr-x 1 root root 2484 okt 12  2016 spice-vdagent
-rwxr-xr-x 1 root root 4033 mrt  1 13:36 ssh
-rwxr-xr-x 1 root root  731 jun  5  2017 sudo
-rwxr-xr-x 1 root root 6087 jun 13 22:20 udev
-rwxr-xr-x 1 root root 1391 mei  6  2017 unattended-upgrades
-rwxr-xr-x 1 root root 2757 nov 23  2016 x11-common
  • Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See [What topics can I ask about here](http://stackoverflow.com/help/on-topic) in the Help Center. Perhaps [Unix & Linux Stack Exchange](http://unix.stackexchange.com/) or [Database Administrators Stack Exchange](http://dba.stackexchange.com/) would be a better place to ask. – jww Aug 28 '18 at 21:07
  • This belongs on the Unix & Linux StackExchange site, which hosts a number of systemd-related questions. – Mark Stosberg Aug 29 '18 at 14:32

4 Answers4

0

That is the whole output message?

Check if the default mongod port(27017) is not in use.

netstat -a

Or try starting in a different port

mongod --fork --port 8000
Lucca Portes
  • 76
  • 10
0

MongoDB defines exit code 48 as: "A newly started mongod or mongos could not start listening for incoming connections, due to an error."

You have pasted just the status output for the MongoDB service. For the full logs of a service on a systemd based system, you should review the systemd journal output:

 journalctl -u mongod

As Lucca suggested, the problem may be something else is already running on the port when you are trying to start.

Check that you are't also trying to start MongoDB via Upstart or SysVInit by looking for MongoDB files in /etc/init and /etc/init.d. If any are found, move them somewhere else so that only the systemd service file is being used to start the service.

Mark Stosberg
  • 12,961
  • 6
  • 44
  • 49
0
a@a-57:~$ sudo systemctl stop mongod.service
a@a-57:~$ sudo systemctl start mongod.service
a@a-57:~$ sudo systemctl status mongod.service
● mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor      preset: enabled)
Active: active (running) since Mon 2021-08-09 16:38:29 CST; 6s ago
 Docs: https://docs.mongodb.org/manual
Main PID: 2205 (mongod)
CGroup: /system.slice/mongod.service
       └─2205 /usr/bin/mongod --config /etc/mongod.conf
八  09 16:38:29 a-57 systemd[1]: Started MongoDB Database Server.

Somehow it's dangerous to edit the rc files under /etc in these modern days. And people would prefer to use system command API as we knew.

-1

You need to edit etc/rc.local in order for it to start on boot up

Just add service mongod start to end of the rc.local file

Frogmonkey
  • 45
  • 5
  • First, rc.local is not how systemd services are started. Second, the issue is not the service doesn't start on boot, it's that the service crashes when it attempts to start on boot. – Mark Stosberg Aug 29 '18 at 14:35