暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Mongodb查看内存占用情况

原创 zayki 2023-02-15
3240

db.serverStatus()

其中有这个
“storageEngine” : { “name” : “wiredTiger”, “supportsCommittedReads” : true, “readOnly” : false, “persistent” : true },

查看WiredTiger内部缓存到底占用了多少内存的方式是,在mongo shell中之行以下命令
db.runCommand( { serverStatus: 1 } ).wiredTiger.cache[“bytes currently in the cache”]

mongodb修改cache-size大小
db.serverStatus().wiredTiger.cache[‘maximum bytes configured’]/1024/1024/1024
如果不想重启mongoDB,可以在线修改,如下
db.adminCommand({setParameter: 1, wiredTigerEngineRuntimeConfig: “cache_size=10G”})

查看当前实际内存的大小:

db.serverStatus().mem

由于默认情况下,cache_size超过80%会触发淘汰,因此,cache_size的大小应该为数据加index大小的1.25倍(cache_size*0.8=data+index)
在内存中可以找到的数据 /你发起的读取数据的需求 * 100 = cache hit ratio

var cache = db.serverStatus().wiredTiger.cache;
var missc = cache[‘pages read into cache’]* 100/cache[‘pages requested from the cache’];
var hitr = 100 - missc;
print(hitr)
99.80766247867226

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论