在mongod.conf上打开auth时无法启动mongodb

时间:2017-02-24 00:46:42

标签: mongodb centos6.5

当我取消注释/etc/mongod.conf上的“security:authorization:enabled”选项时,我无法启动mongod? 在mongodb上3.4.2 在centos6.5;

这是打印出来的:

sudo service mongod restart
Stopping mongod:                                           [  OK  ]
Starting mongod:                                           [FAILED]

这是我的mongod.conf文件: 这是commond打印出来的:

# mongod.conf

# for documentation of all options, see:
#   http://docs.mongodb.org/manual/reference/configuration-options/

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

# Where and how to store data.
storage:
  dbPath: /var/lib/mongo
  journal:
    enabled: true
#  engine:
#  mmapv1:
#  wiredTiger:

# how the process runs
processManagement:
  fork: true  # fork and run in background
  pidFilePath: /var/run/mongodb/mongod.pid  # location of pidfile

# network interfaces
net:
  port: 58018
  bindIp: 127.0.0.1  # Listen to local interface only, comment to listen on all interfaces.

#security:                <---uncomment here will start failed
#  authorization:enabled  <---uncomment here will start failed
#operationProfiling:

#replication:

#sharding:

## Enterprise-Only Options

#auditLog:

#snmp:

2 个答案:

答案 0 :(得分:3)

一切正常,你只是在启用关键字之前错过了一个空格。启用之前空间非常重要

```

security:
  authorization: enabled

```

为了安全起见,请使用上面的代码段替换您的代码段。 很难找到并希望能帮助某人。

答案 1 :(得分:1)

我正在使用&#39; MongoDB服务器版本:3.6.5&#39;这个对我有用:

security.authorization: enabled