初始设置后,MongoDB服务将无法启动 [英] MongoDB Service Will Not Start After Initial Setup

查看:223
本文介绍了初始设置后,MongoDB服务将无法启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行Fedora 20,并按照 Red Hat安装指南.我第一次能够将mongod守护程序作为服务运行而没有错误,但是当我关闭机器并返回时,由于某些故障,该服务被拒绝启动.

I am running Fedora 20 and installed MongoDB per the Red Hat installation guide on the official documentation. I was able to run the mongod daemon as a service without error the very first time but when I shut down my machine and came back, the service refused to start due to some failure.

在成功运行后列出的日志中,我看到以下内容:

In my log, listed after the successful run, I see this:

***** SERVER RESTARTED *****
ERROR: Cannot write pid file to /var/run/mongodb/mongod.pid: No such file or directory

如果我尝试手动启动mongod或运行mongod --repair,则会在启动失败时收到此消息:

If I try starting mongod or running mongod --repair manually, I get this message in a start up failure:

ERROR: dbpath (/data/db) does not exist.
Create this directory or give existing directory in --dbpath.

考虑到在我的/etc/mongod.conf配置文件中,数据库路径的设置如下:

This is odd considering that in my config file in /etc/mongod.conf, the settings for the database path are as follows:

dbpath=/var/lib/mongo

最后,如果我运行此命令:

Finally, if I run this command:

mongod --dbpath /var/lib/mongo

守护程序启动就很好了.但是,我无法复制没有错误的行为来启动服务.

The daemon starts up just fine. However, I am unable to replicate that error free behavior for starting a service.

任何人都可以告诉我到底是什么问题以及如何开始将mongod作为服务运行吗?

Can anyone tell me what exactly is wrong and how I can begin running mongod as a service?

编辑

如果运行mongod --config /etc/mongod.conf,我会收到此消息:

I get this message if I run mongod --config /etc/mongod.conf:

about to fork child process, waiting until server is ready for connections. forked process: 2702 ERROR: child process failed, exited with error number 1

/var/run/mongodb目录不存在,因此我创建了该目录并将其分配给mongod用户.不幸的是,那并没有太大的改变.

The /var/run/mongodb directory did not exist, so I created and assigned it to the mongod user. That did not make much of a difference, unfortunately.

我的/var/log/mongodb/mongod.log显示此消息:

[initandlisten] exception in initAndListen: 10309 Unable to create/open lock file: /var/lib/mongo/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating

推荐答案

在Fedora 20上对我有用的是:我们需要在每次启动时创建temp dir,这由systemd-tmpfiles处理.因此,创建一个文件/lib/tmpfiles.d/mongodb.conf并在其中放入一行:

What worked for me on Fedora 20: we need to create the temp dir on every boot, and that's handled by systemd-tmpfiles. So, create a file /lib/tmpfiles.d/mongodb.conf and put one line in it:

d /var/run/mongodb 0755 mongod mongod

这似乎可以在重新启动时处理;如果您不想立即重启,可以执行以下操作:

That seems to handle it on restarts; if you don't want to restart right away, you can execute that with:

sudo systemd-tmpfiles --create mongodb.conf

(请参阅有关systemd-tmpfiles的手册页)

(See the man pages for systemd-tmpfiles)

这篇关于初始设置后,MongoDB服务将无法启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆