首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Mongodb服务在重启后失败

Mongodb服务在重启后失败
EN

Stack Overflow用户
提问于 2018-08-29 04:42:38
回答 4查看 1.2K关注 0票数 -1

我正在尝试为我的开发环境设置一个副本集,并让三台机器运行debian 9.3 stretch并提供mongod服务。复制集工作正常,看起来一切正常。

但是,当我重新启动其中一台服务器时,mongod服务没有出现。当我检查状态时,它显示status=48失败

代码语言:javascript
复制
    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'.

我已经通过systemctl enable mongod开启了服务,在状态下可以看到确实已经开启了,但是为什么重启机器后失败?

更新:

代码语言:javascript
复制
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
EN

回答 4

Stack Overflow用户

发布于 2018-08-29 13:49:13

这就是整个输出消息?

检查默认的mongod端口(27017)是否未被使用。

代码语言:javascript
复制
netstat -a

或者尝试从不同的端口启动

代码语言:javascript
复制
mongod --fork --port 8000
票数 0
EN

Stack Overflow用户

发布于 2018-08-29 22:39:12

MongoDB defines exit code 48 as:“由于错误,新启动的mongos无法开始侦听传入的连接。”

您只粘贴了MongoDB服务的status输出。对于基于systemd的系统上的服务的完整日志,您应该查看systemd日志输出:

代码语言:javascript
复制
 journalctl -u mongod

正如Lucca建议的那样,当您尝试启动时,问题可能已经在端口上运行了。

通过在MongoDB和/etc/init.d中查找MongoDB文件,检查您是否也在尝试通过Upstart或SysVInit启动/etc/init。如果找到,请将它们移到其他位置,以便只使用systemd服务文件启动服务。

票数 0
EN

Stack Overflow用户

发布于 2021-08-09 08:29:20

代码语言:javascript
复制
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.

不知怎么的,现在在/etc下编辑rc文件是危险的。正如我们所知,人们更喜欢使用系统命令API。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52065929

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档