【问题标题】:mongodb consuming a lot of memory to the point that there is a need to restart nodesmongodb消耗大量内存到需要重启节点的地步
【发布时间】:2020-11-19 16:03:45
【问题描述】:

已经查了很多关于这个话题的问题,我认为这是wiredTiger上的一个错误配置,我相信实际上根本没有使用它。

这是主节点上的内存详细信息:

------------------------------------------------
MALLOC:     9216501736 ( 8789.5 MiB) Bytes in use by application
MALLOC: +    295092224 (  281.4 MiB) Bytes in page heap freelist
MALLOC: +   1027054880 (  979.5 MiB) Bytes in central cache freelist
MALLOC: +       251104 (    0.2 MiB) Bytes in transfer cache freelist
MALLOC: +    214021656 (  204.1 MiB) Bytes in thread cache freelists
MALLOC: +     92561664 (   88.3 MiB) Bytes in malloc metadata
MALLOC:   ------------
MALLOC: =  10845483264 (10343.1 MiB) Actual memory used (physical + swap)
MALLOC: +   7447629824 ( 7102.6 MiB) Bytes released to OS (aka unmapped)
MALLOC:   ------------
MALLOC: =  18293113088 (17445.7 MiB) Virtual address space used
MALLOC:
MALLOC:        1038376              Spans in use
MALLOC:            493              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.

这是其中一个辅助节点的内存详细信息:

------------------------------------------------
MALLOC:     9324505232 ( 8892.5 MiB) Bytes in use by application
MALLOC: +    565633024 (  539.4 MiB) Bytes in page heap freelist
MALLOC: +    333445776 (  318.0 MiB) Bytes in central cache freelist
MALLOC: +         7680 (    0.0 MiB) Bytes in transfer cache freelist
MALLOC: +    641961696 (  612.2 MiB) Bytes in thread cache freelists
MALLOC: +     64053504 (   61.1 MiB) Bytes in malloc metadata
MALLOC:   ------------
MALLOC: =  10929606912 (10423.3 MiB) Actual memory used (physical + swap)
MALLOC: +     59404288 (   56.7 MiB) Bytes released to OS (aka unmapped)
MALLOC:   ------------
MALLOC: =  10989011200 (10479.9 MiB) Virtual address space used
MALLOC:
MALLOC:         809348              Spans in use
MALLOC:            773              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.

如果我错了请纠正我,但似乎缓存中有7GB的内存,可以清理,对吗?

当前使用的mongodb服务器版本是4.0.6。

这是 mongod.conf 上与存储相关的部分:

storage:
  dbPath: /var/lib/mongodb

wiredTiger 使用的最大 GB 没有配置,所以我相信它会使用 50%(RAM - 1 GB),对吧?机器的 RAM 为 16GB。所以这将是 7.5GB 的缓存,可能太多了,我不知道,对这个问题有什么见解吗?

每隔几天就需要重新启动节点,如果能找到解决此问题的方法会很棒。

谢谢。

【问题讨论】:

  • 我看不出你的问题中有什么表明需要重新启动任何东西。

标签: mongodb memory memory-leaks wiredtiger


【解决方案1】:

您在系统上运行哪些类型的查询?它们是长时间运行的查询,还是不使用索引的查询?您的数据库中有多少数据,您大部分时间使用多少数据?缓存驱逐率是多少?

基本上,很难知道什么是“过多”使用内存,除非您知道正在使用多少内存。如果你有一个 500Gb 的数据库,并且一直在 200G 上进行查询,那么 mongodb 需要比 16Gb 机器更多的内存,而且速度会很慢。

您在使用 MongoDB 的免费云监控吗? https://docs.mongodb.com/manual/administration/free-monitoring/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-01-16
    • 2014-01-04
    • 2012-07-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-02
    • 1970-01-01
    相关资源
    最近更新 更多