MongoDB服务器无法启动

时间:2013-07-09 17:38:55

标签: mongodb

我今天刚刚安装了Arch Linux。我正在设置我的开发堆栈,我被mongodb困住了。

我在安装时遵循此维基: https://wiki.archlinux.org/index.php/MongoDB#Installing_MongoDB

当我尝试进入mongo控制台时,我明白了:

jan@arch:~$ mongo
MongoDB shell version: 2.4.5
connecting to: test
Tue Jul  9 19:38:13.365 JavaScript execution failed: Error: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:L112
exception: connect failed
jan@arch:~$ 

我在这里缺少什么?

编辑:当我直接从终端运行mongod时,我发现它可以很好地启动服务器。但是systemctl start mongodb无法启动它。

1 个答案:

答案 0 :(得分:2)

好的,我已经通过扫描journalctl输出找出了它:

ul 09 19:49:33 arch mongod[1122]: all output going to: /var/log/mongodb/mongod.log Jul 09 19:49:33 arch mongod[1122]: can't open [/var/log/mongodb/mongod.log] for log file: errno:13 Permission denied Jul 09 19:49:33 arch mongod[1122]: Bad logpath value: "/var/log/mongodb/mongod.log"; terminating.

所以我搜索了mongodb可能使用的用户:

jan@arch:~$ cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
...
mongodb:x:998:2::/var/lib/mongodb:/bin/bash

和chowned所需的文件夹:

jan@arch:~$ sudo chown -R mongodb:x /var/log/mongodb/
jan@arch:~$ sudo chown -R mongodb:x /var/lib/mongodb/

再次开始:

jan@arch:~$ sudo systemctl start mongodb

现在有效。

 jan@arch:~$ mongo
    MongoDB shell version: 2.4.5
    connecting to: test
    Welcome to the MongoDB shell.
    For interactive help, type "help".
    For more comprehensive documentation, see
        http://docs.mongodb.org/
    Questions? Try the support group
        http://groups.google.com/group/mongodb-user
    >