[原创]MongoDB error code 96 的解决办法
(2018-01-16 13:59:12)分类: mongodb |
一、环境:linux mongodb 3.4+java
定时任务:从mongodb中取10000个左右的排序docment。
二、现象:日志中报错:Query failed with error code 96 and error message 'Executor error during find command: OperationFailed: Sort operation used more than the maximum 33554432 bytes of RAM. Add an index, or specify a smaller limit.'
三、原因:mongodb用于排序的内存上限为32M,当一次排序的数据集超过32M的时候就会报这个错。
四、解决办法:
1、db.adminCommand({setParameter:
1,internalQueryExecMaxBlockingSortBytes:
xxxx}),xxxx的取值为自己想要的内存上限,比如,256M=256*1024*1024=268435456。此命令即时生效,不过,要注意的是,当MongoDB重启时,如果配置文件中未显示设置,则会恢复默认的32M。
2、修改/etc/mongod.conf,添加如下内容,确保重启之后不会恢复到默认值:
setParameter:
internalQueryExecMaxBlockingSortBytes:
268435456
二、现象:日志中报错:Query failed with error code 96 and error message 'Executor error during find command: OperationFailed: Sort operation used more than the maximum 33554432 bytes of RAM. Add an index, or specify a smaller limit.'
三、原因:mongodb用于排序的内存上限为32M,当一次排序的数据集超过32M的时候就会报这个错。
四、解决办法:
setParameter: