MongoDB服务无法启动. errno:13权限被拒绝 [英] MongoDB service doesn't start. errno:13 Permission denied

查看:429
本文介绍了MongoDB服务无法启动. errno:13权限被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已在文档 http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/.然后,我修改了配置文件/etc/mongod.conf,以便稍后运行mongod服务.

I have installed MongoDB on a Ubuntu server like is indicated in the docs http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/. Then, I have modified the configuration file /etc/mongod.conf for, later, run a mongod service.

如果执行以下命令,MongoDB将正确运行:

MongoDB runs correctly if I execute:

sudo mongod -f /etc/mongod.conf

但是如果我执行,MongoDB就会停止:

But MongoDB stops if I execute:

sudo service mongod start

在配置文件/etc/mongod.conf中,我仅对此进行了更改:

In the config file /etc/mongod.conf I changed only this:

dbpath=/data/db
logpath=/root/logs/mongod.log
port=20000

使用此配置,也不会创建日志文件.

With this configuration, the log file is not created too.

如果我不修改先前指示的值,则该服务将正确启动.默认值为:

If I don't modify the previous values indicated, the service starts correctly. The default values are:

dbpath=/var/lib/mongodb
logpath=/var/log/mongodb/mongod.log
port = 27017

由于未使用自定义配置创建日志文件,因此我仅更改了dbpath以查看错误:

Because the log file is not created with the custom configuration, I have only changed the dbpath for see the error:

[initandlisten] exception in initAndListen: 10309 Unable to create/open lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?

我尝试运行以下命令,但没有成功:

I tried to run the following commands but without success:

sudo chown -R `id -u` /data/db

sudo rm /var/lib/mongodb/mongod.lock
mongod --repair

堆栈:

  • Ubuntu 14.10
  • MongoDB 2.6.5

推荐答案

我们必须制作 mongod用户拥有的所有目录/文件.为此:

We must make all the directories/files owned by mongod user. For this:

sudo chown -R mongodb:mongodb /data/db

这篇关于MongoDB服务无法启动. errno:13权限被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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