MongoDB:initAndListen中的异常:20试图在只读目录/data/db上创建锁定文件,终止 [英] MongoDB: exception in initAndListen: 20 Attempted to create a lock file on a read-only directory: /data/db, terminating

查看:91
本文介绍了MongoDB:initAndListen中的异常:20试图在只读目录/data/db上创建锁定文件,终止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在根目录中创建了/data/db并运行了./mongod:

I created /data/db in root directory and ran ./mongod:

[initandlisten] exception in initAndListen: 20 Attempted to create a lock file on a read-only directory: /data/db, terminating
[initandlisten] shutdown: going to close listening sockets...
[initandlisten] shutdown: going to flush diaglog...
[initandlisten] now exiting
[initandlisten] shutting down with code:100

推荐答案

问题是您创建的目录/data/db由root用户拥有,并且只能由root用户写入,但是您自己运行mongod.有几种方法可以解决此问题,但是最终,您必须为相关目录提供正确的权限.如果这是用于生产,我建议您检查一下文档并仔细考虑一下-您可能要特别注意.

The problem is that the directory you created, /data/db is owned by and only writable by the root user, but you are running mongod as yourself. There are several ways to resolve this, but ultimately, you must give the directory in question the right permissions. If this is for production, I would advise you to check the docs and think this over carefully -- you probably want to take special care.

但是,如果这只是为了进行测试,并且您只需要进行此工作并继续使用它,则可以尝试执行此操作,这将使该目录对每个人都可写:

However, if this is just for testing and you just need this to work and get on with it, you could try this, which will make the directory writable by everyone:

> sudo chmod -R go+w /data/db

或这个,将使该目录归您所有:

or this, which will make the directory owned by you:

> sudo chown -R $USER /data/db

这篇关于MongoDB:initAndListen中的异常:20试图在只读目录/data/db上创建锁定文件,终止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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