我按照本教程here安装了mongodb,在安装过程中没有错误,但是当我尝试使用此命令sudo systemctl start mongodb
启动mongod服务器时,教程提到,当我尝试使用时出现此错误使用此命令sudo systemctl status mongodb
检查它是否正在运行。
● mongodb.service - High-performance, schema-free document-oriented
database
Loaded: loaded (/etc/systemd/system/mongodb.service; enabled; vendor preset:
Active: failed (Result: exit-code) since Rab 2016-06-01 18:04:20 MYT; 4s ago
Process: 8241 ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf (cod
Main PID: 8241 (code=exited, status=14)
Jun 01 18:04:20 yasinya systemd[1]: Started High-performance, schema-free docume
Jun 01 18:04:20 yasinya systemd[1]: mongodb.service: Main process exited, code=e
Jun 01 18:04:20 yasinya systemd[1]: mongodb.service: Unit entered failed state.
Jun 01 18:04:20 yasinya systemd[1]: mongodb.service: Failed with result 'exit-co
lines 1-10/10 (END)
所以任何人都可以说出错误以及我如何解决它。
答案 0 :(得分:38)
最近我解决了同样的问题。我无法在谷歌上找到解决方案,但我得到了线索,如何弄明白。在我的情况下,此问题与mongodb-27017.sock文件有关。
Failed to unlink socket file /tmp/mongodb-27017.sock errno:1 Operation not permitted
所以我已将/tmp/mongodb-27017.sock文件的权限更改为默认mongodb
用户。
sudo chown mongodb /tmp/mongodb-27017.sock
sudo chgrp mongodb /tmp/mongodb-27017.sock
此sudo systemctl status mongodb
工作正常并且mongodb
开始后。
答案 1 :(得分:23)
在同一问题上磕磕绊绊,只需重新启动
sudo reboot
答案 2 :(得分:6)
我有同样的用途,
得到解决
sudo reboot
答案 3 :(得分:6)
MongoDB应用程序返回的此错误,遇到不可恢复的错误,未捕获的异常或未捕获的信号。系统退出而没有执行干净关机。
我通过以下命令解决了这个问题:
sudo chown -R mongodb:mongodb /var/log/mongodb
sudo chown -R mongodb:mongodb /var/lib/mongodb
sudo chmod -R 755 /var/lib/mongodb
sudo chmod -R 755 /var/log/mongodb
sudo chown mongodb /tmp/mongodb-27017.sock
sudo chgrp mongodb /tmp/mongodb-27017.sock
然后重新启动服务
sudo systemctl restart mongod
然后检查您的mongodb服务
sudo systemctl status mongod
答案 4 :(得分:2)
首先,您应该检查mongo日志。它应该告诉你出了什么问题。
$ tail -n 100 /var/log/mongodb/mongod.log
此命令将显示日志文件的最后100行,这将指出您确切的问题。
例如,我的工作不正常,因为我使用相同的端口mongo
运行27017
实例。当我运行另一个实例时,实例无法加载。
2018-05-11T19:03:49.102-0400 I CONTROL [initandlisten] MongoDB starting : pid=1247 port=27017 dbpath=/var/lib/mongodb 64-bit host=dev-hyuen
2018-05-11T19:03:49.103-0400 I CONTROL [initandlisten] db version v3.2.20
2018-05-11T19:03:49.103-0400 I CONTROL [initandlisten] git version: a7a144f40b70bfe290906eb33ff2714933544af8
2018-05-11T19:03:49.103-0400 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016
2018-05-11T19:03:49.103-0400 I CONTROL [initandlisten] allocator: tcmalloc
2018-05-11T19:03:49.103-0400 I CONTROL [initandlisten] modules: none
2018-05-11T19:03:49.103-0400 I CONTROL [initandlisten] build environment:
2018-05-11T19:03:49.103-0400 I CONTROL [initandlisten] distmod: ubuntu1604
2018-05-11T19:03:49.103-0400 I CONTROL [initandlisten] distarch: x86_64
2018-05-11T19:03:49.103-0400 I CONTROL [initandlisten] target_arch: x86_64
2018-05-11T19:03:49.103-0400 I CONTROL [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1", port: 27017 }, storage: { dbPath: "/var/lib/mongodb", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log", quiet: true } }
2018-05-11T19:03:49.124-0400 E NETWORK [initandlisten] listen(): bind() failed errno:98 Address already in use for socket: 127.0.0.1:27017
2018-05-11T19:03:49.124-0400 E NETWORK [initandlisten] addr already in use
2018-05-11T19:03:49.124-0400 E STORAGE [initandlisten] Failed to set up sockets during startup.
2018-05-11T19:03:49.124-0400 I CONTROL [initandlisten] dbexit: rc: 48
答案 5 :(得分:1)
我得到了类似的错误,在我的情况下,mongo无法使用27017。 我需要停止使用27017端口并重启mongo。
答案 6 :(得分:1)
因为权限设置
chown -R mongodb:mongodb /var/lib/mongodb
chown mongodb:mongodb /tmp/mongodb-27017.sock
如果重新安装mongodb后这对我有用。我已经手动创建
sudo mkdir /var/lib/mongodb
sudo mkdir /var/log/mongodb
并更改了所有者两者
sudo chown -R mongodb:mongodb /var/lib/mongodb
chown -R mongodb:mongodb /var/log/mongodb
答案 7 :(得分:0)
问题可能与您的tmp.cpp:19:35: error: template template argument has different template parameters than its corresponding template template parameter
using FunctionOperator = Function<Operator>;
^
tmp.cpp:8:1: note: too many template parameters in template template argument
template <typename A, typename B, bool is_f = std::is_floating_point<A>::value || std::is_floating_point<B>::value > struct Operator;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tmp.cpp:3:11: note: previous template template parameter is here
template <template <typename, typename> class Op>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
(是我的)缺少空间有关。
使用df.groupBy("account").agg(sum("amount"),count("account")).show()
检查并查看是否有足够的可用空间。
否则,如there所述,尝试通过将日志文件移动到另一个磁盘来释放一些空间。
/dev/root/
希望对我有帮助
答案 8 :(得分:0)
就我而言,系统无法找到mongod.service 运行以下命令将对其进行修复
sudo systemct1 enable mongod
然后通过
重新启动数据库sudo service mongod restart
答案 9 :(得分:0)
在谷歌搜索一段时间后。我发现那是因为权限设置为 / var / lib / mongodb和/tmp/mongodb-27017.lock错误。您必须将所有者更改为monogdb用户
chown -R mongodb:mongodb /var/lib/mongodb
chown mongodb:mongodb /tmp/mongodb-27017.sock
答案 10 :(得分:0)
步骤1。 sudo systemctl stop mongodb
步骤2。 sudo systemctl start mongod
第3步。 sudo systemctl status mongod
希望对您有帮助
答案 11 :(得分:0)
所以,我检查了状态
sudo systemctl status mongod
得到这个:-
● mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sat 2021-02-20 18:11:19 IST; 5s ago
Docs: https://docs.mongodb.org/manual
Process: 724411 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=1/FAILURE)
Main PID: 724411 (code=exited, status=1/FAILURE)
Feb 20 18:11:18 bunty systemd[1]: Started MongoDB Database Server.
Feb 20 18:11:19 bunty mongod[724411]: {"t":{"$date":"2021-02-20T12:41:19.657Z"},"s":"F", "c":"CONTROL", "id":>
Feb 20 18:11:19 bunty systemd[1]: mongod.service: Main process exited, code=exited, status=1/FAILURE
Feb 20 18:11:19 bunty systemd[1]: mongod.service: Failed with result 'exit-code'.
如果您的情况类似...
/var/lib/mongodb
和 /var/log/mongodb
。你可以这样做:
test -d /var/lib/mongodb && echo "Directory Exists"
test -d /var/log/mongodb && echo "Directory Exists"
mkdir
命令创建。sudo mkdir /var/lib/mongodb # run only if it does not exist
sudo mkdir /var/log/mongodb # run only if it does not exist
mongodb
。对两个目录执行此操作。sudo chown -R mongodb:mongodb /var/lib/mongodb
sudo chown -R mongodb:mongodb /var/log/mongodb
sudo systemctl restart mongod
sudo systemctl status mongod
如果输出类似于
● mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)
Active: active (running) since Sat 2021-02-20 18:15:01 IST; 59min ago
Docs: https://docs.mongodb.org/manual
Main PID: 734383 (mongod)
Memory: 166.7M
CGroup: /system.slice/mongod.service
└─734383 /usr/bin/mongod --config /etc/mongod.conf
Feb 20 18:15:01 bunty systemd[1]: Started MongoDB Database Server.
你可以走了。
对于 mongo shell:
mongo
每当 mongod
失败时,这对我有用,希望它也对你有用。
纳马斯特?