首页 > 解决方案 > mongodb on Ubuntu 18.04 Bionic systemctl 处理 mongod.service / mongodb.service

问题描述

我在mongod.service使用systemctl. 它现在已经设置好了,只是它抱怨有其他东西在占用它的端口,尽管实际上什么都没有。我想罪魁祸首如下:(mongodb而不是mongod.service)有一个失败的服务,其错误是“找不到文件”。我需要设置或删除缺少的mongodb.service吗?我看到有一个/lib/systemd/system/mongod.service,但该目录中没有一个mongodb.service

下面是其中的一些配置/etc/mongod.conf

storage:
  dbPath: /data/db
  journal:
    enabled: true
#  engine:
#  mmapv1:
#  wiredTiger:

# where to write logging data.
systemLog:
  destination: file
  logAppend: true
  path: /var/log/mongodb/mongod.log

# network interfaces
net:
  port: 27017
  bindIp: 127.0.0.1

我还设置sudo chown -R mongodb:mongodb /data/db了哪些修复的错误,但现在我得到了/data/db/WiredTiger.turtle: handle-open: open: Permission denied

sudo chown -R mongodb:mongodb /data/db/WiredTiger.turtle ...在我认为该文件已生成并且错过了获得权限之后,是的 mongod 正在运行。

我刚刚阅读了文档:The Linux package init scripts do not expect storage.dbPath to change from the defaults. If you use the Linux packages and change storage.dbPath, you will have to use your own init scripts and disable the built-in scripts.我相信我最初更改了 dbPath ...

标签: mongodb

解决方案


检查 mongodb 是否正在运行

sudo service mongodb status

如果显示不活动,请使用以下命令激活

sudo service mongodb start

推荐阅读