【问题标题】:mongodb ignores dbPath parameter?mongodb 忽略 dbPath 参数?
【发布时间】:2019-02-22 16:40:42
【问题描述】:

我在 Windows 10 上安装了 Mongodb 最新版 (4.0) 作为服务 它似乎忽略了bin目录中的mongod.cfg文件

C:\MongoDB4.0\bin\mongod.cfg
# Where and how to store data.
 storage:
     dbPath: C:\MongoDB4.0\data

服务不会启动,
当我从 CMD 启动它时:

c:\MongoDB4.0\bin>mongod.exe

这是它的输出:(参见 dbpath=c:\data\db)

Log:  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
Log:  [initandlisten] MongoDB starting : pid=7104 port=27017 dbpath=c:\data\db\ 64-bit host=Win10-Pc
Log:  [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
Log:  [initandlisten] db version v4.0.2
Log:  [initandlisten] git version: fc1573ba18aee42f97a3bb13b67af7d837826b47

我看到服务获取配置作为参数

C:\MongoDB4.0\bin\mongod.exe --config "C:\MongoDB4.0\bin\mongod.cfg" --service

【问题讨论】:

    标签: mongodb


    【解决方案1】:

    --service 选项用于创建初始服务定义,如果您使用的是 MongoDB 4.0+ 安装程序(在安装过程中包括此步骤),通常不需要此选项。

    要从命令行管理 MongoDB 服务,您需要使用 net start MongoDBnet stop MongoDB

    c:\MongoDB4.0\bin>mongod.exe

    如果您在没有任何参数的情况下运行 mongod.exe,则将使用默认值(例如 c:\data\db 用于 dbPath)。服务器二进制文件当前没有配置文件的默认位置。

    在 MongoDB 问题跟踪器中有一个相关的功能请求可以观看/投票:SERVER-36150: Improved Default Config File Handling

    【讨论】:

    • 感谢 Stennie 的回答,但我不明白这与 dbPath 有什么关系
    • @user648026 您提到当您从带有mongod.exe 的命令行启动时,配置文件中的dbPath 将被忽略。这是预期的行为:当前没有默认配置文件路径,因此您必须通过 "C:\MongoDB4.0\bin\mongod.exe --config "C:\MongoDB4.0\bin\mongod.exe 调用。 cfg”如果你想使用服务定义中的配置文件。由于你正在尝试对服务配置进行故障排除,你应该使用net start MongoDB从命令行管理。如果服务没有启动,应该还有更多MongoDB 日志文件中的信息。
    猜你喜欢
    • 1970-01-01
    • 2011-10-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-25
    • 2011-07-03
    • 2011-12-01
    • 2016-04-21
    相关资源
    最近更新 更多