您的位置:首页 > 汽车 > 新车 > 开网店详细步骤流程_佛山建站专家_全媒体运营师报名入口_seo思维

开网店详细步骤流程_佛山建站专家_全媒体运营师报名入口_seo思维

2025/2/10 23:44:02 来源:https://blog.csdn.net/ctypyb2002/article/details/145466112  浏览:    关键词:开网店详细步骤流程_佛山建站专家_全媒体运营师报名入口_seo思维
开网店详细步骤流程_佛山建站专家_全媒体运营师报名入口_seo思维

os 分析

内存使用

ps aux|head -1;ps aux|grep -v PID|sort -rn -k +4|head -10

swap 使用

for i in $(ls /proc | grep "^[0-9]" | awk '$0>100'); do awk '/Swap:/{a=a+$2}END{print '"$i"',a/1024"M"}' /proc/$i/smaps;done| sort -k2nr | head

mongodb 层面分析

查看tcmalloc内存分配器

data0data0:PRIMARY> db.version();
4.2.17data0data0:PRIMARY> db.serverStatus().tcmalloc.tcmalloc.formattedString
------------------------------------------------
MALLOC:    28062443328 (26762.4 MiB) Bytes in use by application
MALLOC: +  55441469440 (52873.1 MiB) Bytes in page heap freelist
MALLOC: +   8222845880 ( 7841.9 MiB) Bytes in central cache freelist
MALLOC: +        37632 (    0.0 MiB) Bytes in transfer cache freelist
MALLOC: +     20273672 (   19.3 MiB) Bytes in thread cache freelists
MALLOC: +    530448384 (  505.9 MiB) Bytes in malloc metadata
MALLOC:   ------------
MALLOC: =  92277518336 (88002.7 MiB) Actual memory used (physical + swap)
MALLOC: +   8146022400 ( 7768.7 MiB) Bytes released to OS (aka unmapped)
MALLOC:   ------------
MALLOC: = 100423540736 (95771.4 MiB) Virtual address space used
MALLOC:
MALLOC:        4213034              Spans in use
MALLOC:            118              Thread heaps in use
MALLOC:           4096              Tcmalloc page size
------------------------------------------------
Call ReleaseFreeMemory() to release freelist memory to the OS (via madvise()).
Bytes released to the OS take up virtual address space but no physical memory.

Bytes in use by application 对应的内存指 Mongod 节点实际消耗的内存
Bytes in page heap freelist 为未归还给操作系统的内存。

可以通过增大参数tcmallocReleaseRate提高释放内存速率

db.adminCommand( { getParameter: 1, tcmallocReleaseRate:1} )db.adminCommand( { setParameter: 1, tcmallocReleaseRate: 5.0 } )

进一步,如何希望立即释放内存,可以设置参数tcmallocAggressiveMemoryDecommit 为1

db.adminCommand( { getParameter: 1, tcmallocAggressiveMemoryDecommit:1} )db.adminCommand( { setParameter: 1, tcmallocAggressiveMemoryDecommit:1} )

查看wiredTiger cache

data0data0:PRIMARY> db.serverStatus().storageEngine;
{"name" : "wiredTiger","supportsCommittedReads" : true,"oldestRequiredTimestampForCrashRecovery" : Timestamp(1738804816, 1),"supportsPendingDrops" : true,"dropPendingIdents" : NumberLong(0),"supportsSnapshotReadConcern" : true,"readOnly" : false,"persistent" : true,"backupCursorOpen" : false
}

查看wiredTiger 内存当前使用大小

data0data0:PRIMARY> db.serverStatus().wiredTiger.cache

关注 bytes currently in the cache

{......"bytes belonging to page images in the cache":6511653424,"bytes belonging to the cache overflow table in the cache":65289,"bytes currently in the cache":8563140208,"bytes dirty in the cache cumulative":NumberLong("369249096605399"),......
}

查看 wiredTiger 内存配合的参数大小
单位字节

data0data0:PRIMARY> db.serverStatus().wiredTiger.cache["maximum bytes configured"]
1073741824

可以适当调小或者调大

data0data0:PRIMARY> db.adminCommand({setParameter: 1, "wiredTigerEngineRuntimeConfig": "cache_size=2GB" });

查看修改后的最新值

data0data0:PRIMARY> db.serverStatus().wiredTiger.cache["maximum bytes configured"];
2147483648

记得同步修改参数文件,避免实例重启后丢失修改值。

备注:
1、默认 WiredTiger 内部缓存大小为以下两者中的较大者:
(RAM 大小 - 1 GB)的 50%,或
256 MB.

https://www.mongodb.com/zh-cn/docs/v5.0/core/wiredtiger/#memory-use

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com