一: 报错信息:
[root@www log]# journalctl -xe
-- Unit mongodb.service has begun starting up.
'/usr/local/mongodb/mongdb7/bin/mongod --help' for more information
10月 03 13:47:39 www.yhchange.com systemd[1]: mongodb.service: control process exited, code=exited status=2
10月 03 13:47:39 www.yhchange.com systemd[1]: Failed to start mongodb.
-- Subject: Unit mongodb.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mongodb.service has failed.
--
-- The result is failed.
10月 03 13:47:39 www.yhchange.com systemd[1]: Unit mongodb.service entered failed state.
10月 03 13:47:39 www.yhchange.com systemd[1]: mongodb.service failed.
10月 03 13:47:39 www.yhchange.com polkitd[656]: Unregistered Authentication Agent for unix-process:3466:463609 (system bus name :1.32, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale zh_CN.UTF-8) (disconnected from bus)
10月 03 13:48:01 www.yhchange.com anacron[2068]: Job `cron.weekly' started
10月 03 13:48:01 www.yhchange.com anacron[2068]: Job `cron.weekly' terminated
10月 03 13:48:22 www.yhchange.com polkitd[656]: Registered Authentication Agent for unix-process:3524:467959 (system bus name :1.33 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, loc
10月 03 13:48:22 www.yhchange.com systemd[1]: Starting mongodb...
-- Subject: Unit mongodb.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
二: 经过排除,发现mongodb.conf中文件少配置了 fork = true中项配置
[root@www mongdb7]# cat mongodb.conf
dbpath=/usr/local/mongodb/mongdb7/data/
logpath=/usr/local/mongodb/mongdb7/log/mongodb.log
pidfilepath=/usr/local/mongodb/mongdb7/bin/mongodb.pid
directoryperdb=true
logappend=true
bind_ip=192.168.1.111
port=27017
fork=true
重新启动OK
[root@www mongdb7]# systemctl restart mongodb
[root@www mongdb7]# systemctl status mongodb
● mongodb.service - mongodb
Loaded: loaded (/usr/lib/systemd/system/mongodb.service; enabled; vendor preset: disabled)
Active: active (running) since 二 2023-10-03 14:04:41 CST; 2s ago
Process: 4702 ExecStop=/usr/local/mongodb/mongdb7/bin/mongod --shutdown --config /usr/local/mongodb/mongdb7/mongodb.conf (code=exited, status=0/SUCCESS)
Process: 4713 ExecStart=/usr/local/mongodb/mongdb7/bin/mongod --config /usr/local/mongodb/mongdb7/mongodb.conf (code=exited, status=0/SUCCESS)
Main PID: 4715 (mongod)
Tasks: 34
CGroup: /system.slice/mongodb.service
└─4715 /usr/local/mongodb/mongdb7/bin/mongod --config /usr/local/mongodb/mongdb7/mongodb.conf10月 03 14:04:40 www.yhchange.com systemd[1]: Starting mongodb...
10月 03 14:04:40 www.yhchange.com mongod[4713]: about to fork child process, waiting until server is ready for connections.
10月 03 14:04:40 www.yhchange.com mongod[4713]: forked process: 4715
10月 03 14:04:41 www.yhchange.com mongod[4713]: child process started successfully, parent exiting
10月 03 14:04:41 www.yhchange.com systemd[1]: Started mongodb.
[root@www ~]# ps aux | grep mongodb
root 1348 4.5 2.4 2718944 94084 ? Sl 14:16 0:01 /usr/local/mongodb/mongdb7/bin/mongod --config /usr/local/mongodb/mongdb7/mongodb.conf
root 1813 0.0 0.0 112824 988 pts/0 S+ 14:17 0:00 grep --color=auto mongodb