You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

MongoDB 4.4.0(CentOS7)配置LDAP报security.ldap.servers未识别错误求助

MongoDB 4.4.0 LDAP配置报错“Unrecognized option: security.ldap.servers”的解决办法

你在CentOS 7上运行MongoDB 4.4.0时,配置LDAP相关参数后启动报错“Unrecognized option: security.ldap.servers”,核心原因和解决办法如下:

报错原因

MongoDB 4.4的社区版不支持LDAP认证/授权功能,只有MongoDB企业版才提供这些配置项。你当前用的是社区版,所以配置文件里的security.ldap节点及下属所有参数都是无效的,启动时会被判定为未识别选项。

解决办法

情况1:确实需要LDAP功能

  • 卸载当前社区版MongoDB,重新安装MongoDB 4.4企业版。
  • 企业版安装完成后,你的配置结构本身是正确的,但需要调整几个细节:
    • 去掉security.authorization: enabled前的注释,LDAP依赖授权功能开启才能生效。
    • 确认setParameter里的authenticationMechanisms包含PLAIN(LDAP认证必须用这个机制)。
    • 核对LDAP服务器地址、绑定用户账号密码等信息是否符合实际环境。

修正后的企业版配置示例:

systemLog:
  destination: file
  path: "/home/mongo/mongodb/logs/mongod.log"
  logAppend: true

storage:
  dbPath: "/home/mongo/mongodb/data/db"

net:
  bindIp: localhost,127.0.0.1
  port: 27017

security:
  authorization: enabled
  ldap:
    servers: "ldap"
    bind:
      queryUser: user
      queryPassword: pass
    transportSecurity: none
    userToDNMapping: '[{match: "(.+)", ldapQuery: "o=int,c=com?uid?sub?userPrincipalName={0}@ldap.xxx.com"}]'
    authz:
      queryTemplate: '{USER}?memberOf?base'
setParameter:
  authenticationMechanisms: 'PLAIN,SCRAM-SHA-1'

情况2:不需要LDAP功能

直接删除配置文件中security节点下所有ldap相关内容,保留你需要的基础安全配置即可。

修正后的社区版配置示例:

systemLog:
  destination: file
  path: "/home/mongo/mongodb/logs/mongod.log"
  logAppend: true

storage:
  dbPath: "/home/mongo/mongodb/data/db"

net:
  bindIp: localhost,127.0.0.1
  port: 27017

security:
  authorization: enabled

setParameter:
  authenticationMechanisms: 'SCRAM-SHA-1'

内容的提问来源于stack exchange,提问作者Ravai

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.21 22:15:36