[MongoDB] - 增加 sort memory
[MongoDB] - 对于"OperationFailed: Sort operation used more than the maximum 33554432 bytes of RAM"问题的优化
背景:MongoDB v4.2.7
错误:OperationFailed: Sort operation used more than the maximum 33,554,432 bytes of RAM. Add an index, or specify a smaller limit.’ on server
修改:增加 sort memory
*** 修改当前运行时(重启MongoDB失效) ***
1. 查询现有配置
db.adminCommand({getParameter: '*'})
2. 更新配置(MongoDB v4.2)
db.adminCommand({"setParameter":1,"internalQueryExecMaxBlockingSortBytes":335544320})
更新配置(MongoDB v4.4)
参考资料:https://jira.mongodb.org/browse/SERVER-44053
db.adminCommand({"setParameter":1,"internalQueryMaxBlockingSortMemoryUsageBytes":335544320})
以上操作只能一次生效,如果想永久生效需要修改配置文件。
3. 修改配置文件 /etc/mongod.conf
更新配置(MongoDB v4.2)
setParameter: internalQueryExecMaxBlockingSortBytes: 335544320
更新配置(MongoDB v4.4)
setParameter: internalQueryMaxBlockingSortMemoryUsageBytes: 335544320
最新版mongodb配置如下:
mongodb版本:
查看sort 内存语句:
mongo test --eval 'db.adminCommand({getParameter:1, internalQueryMaxBlockingSortMemoryUsageBytes:1});'