jingxinxin / tiankeng

记录程序猿开发过程中已经遇到的各种坑,再记录解决方法 / Record the various pits that have been encountered during the development process, and then record the solution.
2 stars 0 forks source link

mongod.service - SYSV: Mongo is a scalable, document-oriented database. #5

Open jingxinxin opened 7 years ago

jingxinxin commented 7 years ago

Loaded: loaded (/etc/rc.d/init.d/mongod; bad; vendor preset: disabled) Active: failed (Result: exit-code) since Fri 2017-10-20 19:07:23 CST; 8s ago Docs: man:systemd-sysv-generator(8) Process: 10814 ExecStart=/etc/rc.d/init.d/mongod start (code=exited, status=1/FAILURE)

Oct 20 19:07:23 iZ114ypdot6Z systemd[1]: Starting SYSV: Mongo is a scalable, document-oriented database.... Oct 20 19:07:23 iZ114ypdot6Z mongod[10814]: Error starting mongod. /var/run/mongodb/mongod.pid exists. Oct 20 19:07:23 iZ114ypdot6Z systemd[1]: mongod.service: control process exited, code=exited status=1 Oct 20 19:07:23 iZ114ypdot6Z systemd[1]: Failed to start SYSV: Mongo is a scalable, document-oriented database.. Oct 20 19:07:23 iZ114ypdot6Z systemd[1]: Unit mongod.service entered failed state. Oct 20 19:07:23 iZ114ypdot6Z systemd[1]: mongod.service failed.

Cent OS 7上需要把mongoDB添加到systemd,否则会出现上面的错误

将mongoDB添加到systemd

# vim /usr/lib/systemd/system/mongod.service

[Unit] Description=mongodb database

[Service] User=mongod Group=mongod Environment="OPTIONS=--quiet -f /etc/mongod.conf" ExecStart=/usr/bin/mongod $OPTIONS run PIDFile=/var/run/mongodb/mongod.pid

[Install] WantedBy=multi-user.target

建立链接 ln -s /usr/lib/systemd/system/mongod.service /etc/systemd/system/multi-user.target.wants/

重新加载systemctl systemctl daemon-reload

jiakangyuchi commented 6 years ago

Thank you! I have been searching for 2 hours, and your solution works!

jingxinxin commented 6 years ago

@jiakangyuchi you're welcome! This project is mainly used to record the problems encountered in the development process, and very happy can help you.

vajanishant commented 6 years ago

@jingxinxin Thank you so much.

This solution works for me but if you don't mind, I want to know the root cause behind this error and why it is fixed with the solution you provided.

Can you elaborate this?

Thank you.

isaelblais commented 4 years ago

Never thought I'd find the answer to my problem here, Thanks a lot !

Rayo-Fco commented 4 years ago

Gracias, Funciona perfectamente

jingxinxin commented 1 year ago

这是来自QQ邮箱的假期自动回复邮件。您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。

sameerahmed720 commented 3 months ago

Thank you