使用samllFiles存储引擎mmapv1的mongodb配置错误

时间:2015-12-25 08:56:25

标签: mongodb

我在尝试启动mongodb时收到此错误

2015-12-25T08:45:24.381+0000 I CONTROL  [initandlisten] MongoDB starting : pid=2132 port=27017 dbpath=/var/lib/mongodb 64-bit host=sulubuntu
2015-12-25T08:45:24.381+0000 I CONTROL  [initandlisten] db version v3.0.8
2015-12-25T08:45:24.381+0000 I CONTROL  [initandlisten] git version: 83d8cc25e00e42856924d84e220fbe4a839e605d
2015-12-25T08:45:24.381+0000 I CONTROL  [initandlisten] build info: Linux ip-10-187-89-126 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64$2015-12-25T08:45:24.381+0000 I CONTROL  [initandlisten] allocator: tcmalloc
2015-12-25T08:45:24.381+0000 I CONTROL  [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1", port: 27017 }, storage: { dbPath: "/$2015-12-25T08:45:24.441+0000 W STORAGE  [initandlisten] Detected configuration for non-active storage engine mmapv1 when current storage engine is
2015-12-25T08:45:24.442+0000 I STORAGE  [initandlisten] exception in initAndListen: 18656 Cannot start server with an unknown storage engine: , terminating
2015-12-25T08:45:24.442+0000 I CONTROL  [initandlisten] dbexit:  rc: 100

这是我的配置文件

# 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: false
  engine:
  mmapv1:
    smallFiles: true
#  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

如果我注释掉这些值,错误就会消失:engine,mmapv1,smallFiles

这看起来像配置错误,但我只是遵循编写配置文件found here

的指导原则

1 个答案:

答案 0 :(得分:2)

我认为您的问题是,如果您指定它,则不能将\n键留空。换句话说,它默认为storage.engine,但前提是您根本不添加它。

这是我在我的服务器上的工作配置:

mmapv1

对于MongoDB 3.0,引擎密钥可以省略,因为它默认为systemLog: destination: file path: "/var/log/mongodb/mongod.log" logAppend: true storage: mmapv1: smallFiles: true engine: mmapv1 journal: enabled: true dbPath: "/var/lib/mongodb" net: bindIp: 127.0.0.1 port: 27017 ,但从3.2开始它默认为mmapv1,我建议将其显式化并避免在升级时出现问题...