由于出现错误,MongoDB无法启动

时间:2019-01-31 01:54:15

标签: database mongodb ubuntu

我最近在vps上安装了mongodb,但它为我返回了一个错误:

  

1月31日01:35:47 servidor-1 mongod [6960]:读取配置文件时出错:否   这样的文件或目录Jan 31 01:35:47 servidor-1 mongod [6960]:尝试   '/ usr / bin / mongod --help'了解更多信息

service mongodb status

我正在使用Ubuntu 18.04

1 个答案:

答案 0 :(得分:0)

请检查或创建此文件。

  

/etc/systemd/system/mongodb.service

它指定配置文件的位置。根据您的计算机,它应该是/etc/mongodb.conf/etc/mongod.conf

#Unit contains the dependencies to be satisfied before the service is started.
[Unit]
Description=MongoDB Database
After=network.target
Documentation=https://docs.mongodb.org/manual
# Service tells systemd, how the service should be started.
# Key `User` specifies that the server will run under the mongodb user and
# `ExecStart` defines the startup command for MongoDB server.
[Service]
User=mongodb
Group=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongodb.conf
# Install tells systemd when the service should be automatically started.
# `multi-user.target` means the server will be automatically started during boot.
[Install]
WantedBy=multi-user.target

此后,运行基本命令进行检查。

sudo systemctl enable mongodb.service
sudo systemctl start mongodb
sudo systemctl stop mongodb
sudo systemctl status mongodb
sudo systemctl restart mongodb