1. 环境
- Ubuntu 18.04;
- MongoDB version v3.6.3;
2. 问题 & 解决
2.1. Unit mongod.service not found. 报错
- 报错
Failed to start mongod.service: Unit mongod.service not found.
- 解决:
-- 创建文件
sudo vim /etc/systemd/system/mongodb.service
-- 追加文本
[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target
[Service]
User=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf
[Install]
WantedBy=multi-user.target
-- 保存退出,再次启动发现还是报错。
2.2. NonExistentPath: Data directory /data/db not found., terminating 报错
- 报错
2020-08-18T04:16:47.802+0000 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory /data/db not found., terminating
2020-08-18T04:16:47.802+0000 I CONTROL [initandlisten] now exiting
2020-08-18T04:16:47.802+0000 I CONTROL [initandlisten] shutting down with code:100
- 解决
sudo mkdir /data/db/
- 再次启动,问题解决。
sudo mongod
网友评论