各位老师 好,部署环境mongodb v3.2.7 近几个月后内存逐渐递增, 目前内存占用达到80% 的系统内存了。 cacheSizeGB默认值。系统内存32GB,现通过mongostat查看:
insert query update delete getmore command % dirty % used flushes vsize res qr|qw ar|aw netIn netOut conn set repl time
17 9 *0 8 0 13|0 0.5 79.0 0 30.1G 28.4G 0|0 0|0 977k 995k 501 cloudReplSet PRI 2021-05-07T16:33:42+08:00
21 11 *0 10 0 6|0 0.5 79.1 0 30.1G 28.4G 0|0 0|1 704k 904k 501 cloudReplSet PRI 2021-05-07T16:33:43+08:00
如何调整cacheSizeGB值呢
linkface_2021 发表新评论
您好,直接修改配置文件,修改 cacheSizeGB 值即可
“`
storage:
dbPath: xxx
directoryPerDB: true
journal:
enabled: true
engine: wiredTiger
wiredTiger:
engineConfig:
cacheSizeGB: 12
directoryForIndexes: true
journalCompressor: snappy
“`
linkface_2021 选择最佳答案
@jiakunpeng @xiaoxu 感谢,目前线上主库服务器 相关系统userd内存及mongodb vsize 、res 值都看超过了80%,现在使用动态调整db.adminCommand( { “setParameter”: 1, “wiredTigerEngineRuntimeConfig”: “cache_size=15GB”})
$ free -h
total used free shared buffers cached
Mem: 31G 31G 274M 776K 136M 2.2G
-/+ buffers/cache: 28G 2.6G
Swap: 0B 0B 0B
$ top
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
13240 root 20 0 30.536g 0.027t 0 S 6.3 89.5 44345:31 /usr/bin/mongod -f /etc/mongod.conf
$ mongostat
insert query update delete getmore command % dirty % used flushes vsize res qr|qw ar|aw netIn netOut conn set repl time
23 13 *0 11 2 11|0 0.6 78.9 0 30.5G 28.1G 0|0 0|0 4m 7m 500 cloudReplSet PRI 2021-05-27T19:43:37+08:00
20 13 *0 9 3 6|0 0.6 78.9 0 30.5G 28.1G 0|0 0|0 6m 9m 500 cloudReplSet PRI 2021-05-27T19:43:38+08:00