【问题描述】:Mongodb无法正常启动
[root@host01 mongo]# systemctl start mongod.service Job for mongod.service failed because a timeout was exceeded. See "systemctl status mongod.service" and "journalctl -xe" for details. [root@host01 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: timeout) since Tue 2019-03-19 15:15:55 CST; 53s ago Docs: https://docs.mongodb.org/manual Process: 19756 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=0/SUCCESS) Main PID: 6936 (code=killed, signal=KILL)
Mar 19 15:14:17 host01 systemd[1]: Starting High-performance, schema-free document-oriented database... Mar 19 15:14:17 host01 mongod[19756]: about to fork child process, waiting until server is ready for connections. Mar 19 15:14:17 host01 mongod[19756]: forked process: 19761 Mar 19 15:15:23 host01 mongod[19756]: child process started successfully, parent exiting Mar 19 15:15:54 host01 systemd[1]: mongod.service start operation timed out. Terminating. Mar 19 15:15:55 host01 systemd[1]: Failed to start High-performance, schema-free document-oriented database. Mar 19 15:15:55 host01 systemd[1]: Unit mongod.service entered failed state. Mar 19 15:15:55 host01 systemd[1]: mongod.service failed.
[root@host01 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: active (running) since Tue 2019-03-19 15:16:52 CST; 2s ago Docs: https://docs.mongodb.org/manual Process: 21843 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS) Process: 21832 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS) Process: 21830 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS) Main PID: 21847 (mongod) Tasks: 15 Memory: 284.1M CGroup: /system.slice/mongod.service ├─21847 /usr/bin/mongod -f /etc/mongod.conf ├─21858 /usr/bin/mongod -f /etc/mongod.conf └─21859 /usr/bin/mongod -f /etc/mongod.conf
Mar 19 15:16:52 host01 systemd[1]: Starting High-performance, schema-free document-oriented database... Mar 19 15:16:52 host01 systemd[1]: Started High-performance, schema-free document-oriented database. Mar 19 15:16:52 host01 mongod[21847]: about to fork child process, waiting until server is ready for connections. Mar 19 15:16:52 host01 mongod[21847]: forked process: 21859 [root@host01 mongo]#
【解决方案】 将service中的以下内容进行注释即可 Type=forking
[root@host01 mongo]# systemctl start mongod.service
[root@host01 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: active (running) since Tue 2019-03-19 15:16:52 CST; 2s ago Docs: https://docs.mongodb.org/manual Process: 21843 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS) Process: 21832 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS) Process: 21830 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS) Main PID: 21847 (mongod) Tasks: 15 Memory: 284.1M CGroup: /system.slice/mongod.service ├─21847 /usr/bin/mongod -f /etc/mongod.conf ├─21858 /usr/bin/mongod -f /etc/mongod.conf └─21859 /usr/bin/mongod -f /etc/mongod.conf
Mar 19 15:16:52 host01 systemd[1]: Starting High-performance, schema-free document-oriented database... Mar 19 15:16:52 host01 systemd[1]: Started High-performance, schema-free document-oriented database. Mar 19 15:16:52 host01 mongod[21847]: about to fork child process, waiting until server is ready for connections. Mar 19 15:16:52 host01 mongod[21847]: forked process: 21859 [root@host01 mongo]#