mongodb:指定慢速操作的阈值

mongodb:指定慢速操作的阈值,mongodb,mongodb-query,Mongodb,Mongodb Query,我总是在mongod.cfg中添加配置时遇到问题 现在,我想根据以下内容启用operationProfiling: 为指定慢速操作的阈值 systemLog: destination: file path: C:\Mongo\log\mongod.log logAppend: true storage: journal: enabled: true dbPath: C:\Mongo\db operationProfiling: mo

我总是在mongod.cfg中添加配置时遇到问题

现在,我想根据以下内容启用operationProfiling: 为指定慢速操作的阈值

systemLog:
    destination: file
    path: C:\Mongo\log\mongod.log
    logAppend: true
storage:
    journal:
        enabled: true
    dbPath: C:\Mongo\db
operationProfiling:
    mode: 2
    slowOpThresholdMs: 500
    slowOpSampleRate: 1.0
但当我想从服务启动mongodb时,我得到了一个错误:

Error1053:The service did not response to the start or control request in a timely fashion
cfg文件哪里错了?实际上没有

operationProfiling:
    mode: 2
    slowOpThresholdMs: 500
    slowOpSampleRate: 1.0
服务已启动,但添加此配置时出现错误

******编辑******


我使用的是mongodb 3.6,模式是一个字符串值,默认值为off,因此在您的情况下需要on,如下所示:
模式:在

上,我希望它能工作,请尝试以下操作:

operationProfiling:
    mode: slowOp (Different modes: off, slowOp, all)
    slowOpThresholdMs: 500
    slowOpSampleRate: 1.0


有关此()的详细信息,请浏览URL下方()

嗯,operationProfiling.mode仅支持字符串值。默认情况下,模式为关闭。其他两个选项是slowOp和all。在我的例子中,我使用“全部”。 在你的情况下,应该是

operationProfiling:
 mode: "all"
 slowOpThresholdMs: 500
 slowOpSampleRate: 1.0
欲了解更多信息,请点击链接

关于MongoDB日志文件中的错误,应该有更多信息,但可能的问题是您指定了一个无效的。如果您在
db.setProfilingLevel(2)
之后,则该字符串值应为“all”。如果将
模式更改为字符串值无效,请确认您正在使用的MongoDB服务器的特定版本。