gpt4 book ai didi

MongoDB 服务器无法启动

转载 作者:可可西里 更新时间:2023-11-01 09:45:27 26 4
gpt4 key购买 nike

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

我在安装时遵循了这个 wiki: 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 没有启动它。

最佳答案

好的,我已经通过扫描 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

并关闭所需的文件夹:

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
>

关于MongoDB 服务器无法启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17554726/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com