mongodb mongodb安装失败运行mongod
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10166612/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Mongodb installation failure to run mongod
提问by Hans Adiputra Arijanto
I have downloaded the newest version of mongodb and have moved and renamed the file to mongodb to the directory usr/local/mongodb
. When I try to run mongod i get the following error
我已经下载了最新版本的 mongodb,并将文件移动并重命名为 mongodb 到目录usr/local/mongodb
. 当我尝试运行 mongod 时,出现以下错误
`./bin/mongod --help` for help and startup options
Sun Apr 15 18:08:25 [initandlisten] MongoDB starting : pid=8801 port=27017 dbpath=/data/db/ 64-bit host=Hanss-MacBook-Air.local
Sun Apr 15 18:08:25 [initandlisten] db version v2.0.4, pdfile version 4.5
Sun Apr 15 18:08:25 [initandlisten] git version: 329f3c47fe8136c03392c8f0e548506cb21f8ebf
Sun Apr 15 18:08:25 [initandlisten] build info: Darwin erh2.10gen.cc 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386 i386 BOOST_LIB_VERSION=1_40
Sun Apr 15 18:08:25 [initandlisten] options: {}
Sun Apr 15 18:08:25 [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?, terminating
Sun Apr 15 18:08:25 dbexit:
Sun Apr 15 18:08:25 [initandlisten] shutdown: going to close listening sockets...
Sun Apr 15 18:08:25 [initandlisten] shutdown: going to flush diaglog...
Sun Apr 15 18:08:25 [initandlisten] shutdown: going to close sockets...
Sun Apr 15 18:08:25 [initandlisten] shutdown: waiting for fs preallocator...
Sun Apr 15 18:08:25 [initandlisten] shutdown: lock for final commit...
Sun Apr 15 18:08:25 [initandlisten] shutdown: final commit...
Sun Apr 15 18:08:25 [initandlisten] shutdown: closing all files...
Sun Apr 15 18:08:25 [initandlisten] closeAllFiles() finished
Sun Apr 15 18:08:25 [initandlisten] shutdown: removing fs lock...
Sun Apr 15 18:08:25 [initandlisten] couldn't remove fs lock errno:9 Bad file descriptor
Sun Apr 15 18:08:25 dbexit: really exiting now
回答by Frambot
sudo chown -R <your-username> /data/db
sudo chown -R <your-username> /data/db
Which user runs mongod? Are you running it with your regular login?
哪个用户运行 mongod?您是否使用常规登录运行它?
回答by edwin_estrada
Same as "Joe Frambach's" but a little friendlier to cut and paste right away.
与“Joe Frambach's”相同,但更易于立即剪切和粘贴。
sudo chown -R $(whoami) /data/db
回答by bbaassssiiee
systemctl kicks in because the init-script for mongod sources this file like most others:
systemctl 启动是因为 mongod 的 init-script 像大多数其他文件一样提供这个文件:
. /etc/rc.d/init.d/functions
The block with chkconfig comments is used to define the config and pid-file:
带有 chkconfig 注释的块用于定义配置和 pid 文件:
# config: /etc/my-mongod.conf
# pidfile: /var/run/mongo/mongo.pid
But that pifile's path should match up with whatever you have in config's dbpath. So this in /etc/my-mongod.conf
但是该 pifile 的路径应该与配置的 dbpath 中的任何内容相匹配。所以这个在 /etc/my-mongod.conf
dbpath = /home/mongodb/2.0.5/data
Matches with this comment in /etc/init.d/mongod
与 /etc/init.d/mongod 中的此注释匹配
# pidfile: /home/mongodb/2.0.5/data/mongod.lock
回答by KSC
got the same error, in Windows running with Administrator privileges solved the problem.
得到同样的错误,在以管理员权限运行的 Windows 中解决了这个问题。
回答by Nagaraja G Devadiga
Below command worked for me:
以下命令对我有用:
sudo chown -R `id -u` /data/db