Mongodb: Sort operation used more than the maximum 33554432 bytes of RAM

原因比较明确:Sort operation used more than the maximum 33554432 bytes of RAM.,33554432 bytes算下来正好是32Mb,

而Mongodb的sort操作是把数据拿到内存中再进行排序的,为了节约内存,默认给sort操作限制了最大内存为32Mb,

当数据量越来越大直到超过32Mb的时候就自然抛出异常了!解决方案有两个思路,一个是既然内存不够用那就修改默认配置多分配点内存空间;

一个是像错误提示里面说的那样创建索引。
首先说如何修改默认内存配置,在Mongodb命令行窗口中执行如下命令即可:
---------------------
作者:肖老板
来源:CSDN
原文:https://blog.csdn.net/cloume/article/details/70767061
版权声明:本文为博主原创文章,转载请附上博文链接!

 

一、修改mongodb

1. 进入mongodb

sudo docker ps -a

sudo docker exec -it 8725453ff785 bash

mongo

use admin

我这个没有密码

 

执行命令

db.adminCommand({setParameter:1, internalQueryExecMaxBlockingSortBytes:335544320})

 

不用重启,解决

 

二、添加索引

db.order_info.createIndex({create_time:-1});

 

查看索引

db.order_info.getIndexes();

Mongodb: Sort operation used more than the maximum 33554432 bytes of RAM

posted @ 2019-02-28 15:10  lyon♪♫  阅读(576)  评论(0编辑  收藏  举报