我有一个真正让我搞砸的问题!我有这么多头疼的问题。我今天早上在我的Ubuntu 16.04机器上更新了MongoDB软件包,从那时起我就无法启动它(mongod)。我缩小了问题,发现mongod守护程序正在尝试在/ data / db加载数据路径,但我的mongo.conf明确指出该路径位于/ var / lib / mongodb。
发生了什么事?当我运行mongod并直接设置路径时,服务启动没有任何问题。但我不希望每次想要启动时都这样做。有人请帮帮我。我在配置中遗漏了什么吗?感谢您的时间和帮助。我查看日志时得到的错误:
2018-02-01T15:22:27.879+0000 I CONTROL [initandlisten] MongoDB starting : pid=4989 port=27017 dbpath=/data/db 64-bit host=sm
2018-02-01T15:22:27.880+0000 I CONTROL [initandlisten] db version v3.6.2
2018-02-01T15:22:27.880+0000 I CONTROL [initandlisten] git version: 489d177dbd0f0420a8ca04d39fd78d0a2c539420
2018-02-01T15:22:27.880+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016
2018-02-01T15:22:27.880+0000 I CONTROL [initandlisten] allocator: tcmalloc
2018-02-01T15:22:27.880+0000 I CONTROL [initandlisten] modules: none
2018-02-01T15:22:27.880+0000 I CONTROL [initandlisten] build environment:
2018-02-01T15:22:27.880+0000 I CONTROL [initandlisten] distmod: ubuntu1604
2018-02-01T15:22:27.880+0000 I CONTROL [initandlisten] distarch: x86_64
2018-02-01T15:22:27.880+0000 I CONTROL [initandlisten] target_arch: x86_64
2018-02-01T15:22:27.881+0000 I CONTROL [initandlisten] options: {}
2018-02-01T15:22:27.881+0000 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory /data/db not found., terminating
2018-02-01T15:22:27.881+0000 I CONTROL [initandlisten] now exiting
2018-02-01T15:22:27.881+0000 I CONTROL [initandlisten] shutting down with code:100
我的mongod.conf文件的一部分是:
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# Where and how to store data.
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
# engine:
# mmapv1:
# wiredTiger:
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
谢谢你们!
编辑:有人会说我应该在/ data / db中创建数据目录,但是我在lib目录中已有的数据会发生什么:(