linux环境下mongodb启动报错 :Job for mongodb.service failed because the control process exited with error

使用在启动mongodb 时报如下错误:

Job for mongodb.service failed because the control process exited with error code. See "systemctl status mongodb.service" and "journalctl -xe" for details.

[root@jt-server1 mongodb]# systemctl start mongodb.service
Job for mongodb.service failed because the control process exited with error code. See "systemctl status mongodb.service" and "journalctl -xe" for details.

运行 journalctl -xe ,查看错误日志,看到:

Feb 25 10:35:15 jt-server1 mongod[26053]: Error reading config file: No such file or directory
Feb 25 10:35:15 jt-server1 mongod[26053]: try '/opt/soft/mongodb/bin/mongod --help' for more information
接着去检查 mongodb.service文件

[Unit]  
  
Description=mongodb   
After=network.target remote-fs.target nss-lookup.target  
  
[Service]  
Type=forking  
ExecStart=/opt/soft/mongodb/bin/mongod --config /soft/mongodb/mongodb.conf  
ExecReload=/bin/kill -s HUP $MAINPID  
ExecStop=/opt/soft/mongodb/bin/mongod --shutdown --config /soft/mongodb/mongodb.conf  
PrivateTmp=true  
    
[Install]  
WantedBy=multi-user.target 

发现文件中配置的mongodb.conf 文件目录错误,修改正确后如下:

[Unit]  
  
Description=mongodb   
After=network.target remote-fs.target nss-lookup.target  
  
[Service]  
Type=forking  
ExecStart=/opt/soft/mongodb/bin/mongod --config /opt/soft/mongodb/mongodb.conf  
ExecReload=/bin/kill -s HUP $MAINPID  
ExecStop=/opt/soft/mongodb/bin/mongod --shutdown --config /opt/soft/mongodb/mongodb.conf  
PrivateTmp=true  
    
[Install]  
WantedBy=multi-user.target 

重新加载配置systemctl daemon-reload后,启动成功!!!

 

你可能感兴趣的:(nosql学习,mongodb,linux,服务器)