身安不如心安,屋宽不如心宽 。

es heap配置了2G,启动却耗费了7G多

Elasticsearch | 作者 yuedingwangji | 发布于2018年10月31日 | 阅读数:3154

 ES 在配置文件里面限制了堆内存大小
 
es 启动命令如下
501       1789  0.9 91.4 13449140 7371160 ?    Sl   Oct30  17:04 /data/es-yidong/jdk1.8.0_101//bin/java -Xms2g -Xmx2g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -server -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -Dlog4j.skipJansi=true -XX:+HeapDumpOnOutOfMemoryError -Xms7680m -Xmx7680m -Des.path.home=/data/es-yidong/elasticsearch-5.2.2 -cp /data/es-yidong/elasticsearch-5.2.2/lib/elasticsearch-5.2.2.jar:/data/es-yidong/elasticsearch-5.2.2/lib/* org.elasticsearch.bootstrap.Elasticsearch -d
 
配置文件指定了 -Xms2g -Xmx2g
 
启动的时候通过ps aux 看到内存占用了7G多, 
pmap 查看如下
[root@es-yidong_data-3_64_116 config]# jmap  -heap 1789
Attaching to process ID 1789, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.101-b13

using parallel threads in the new generation.
using thread-local object allocation.
Concurrent Mark-Sweep GC

Heap Configuration:
   MinHeapFreeRatio         = 40
   MaxHeapFreeRatio         = 70
   MaxHeapSize              = 8053063680 (7680.0MB)
   NewSize                  = 348913664 (332.75MB)
   MaxNewSize               = 348913664 (332.75MB)
   OldSize                  = 7704150016 (7347.25MB)
   NewRatio                 = 2
   SurvivorRatio            = 8
   MetaspaceSize            = 21807104 (20.796875MB)
   CompressedClassSpaceSize = 1073741824 (1024.0MB)
   MaxMetaspaceSize         = 17592186044415 MB
   G1HeapRegionSize         = 0 (0.0MB)

Heap Usage:
New Generation (Eden + 1 Survivor Space):
   capacity = 314048512 (299.5MB)
   used     = 190005672 (181.20352935791016MB)
   free     = 124042840 (118.29647064208984MB)
   60.502013141205396% used
Eden Space:
   capacity = 279183360 (266.25MB)
   used     = 183547176 (175.04422760009766MB)
   free     = 95636184 (91.20577239990234MB)
   65.74431083571743% used
From Space:
   capacity = 34865152 (33.25MB)
   used     = 6458496 (6.1593017578125MB)
   free     = 28406656 (27.0906982421875MB)
   18.524215812969924% used
To Space:
   capacity = 34865152 (33.25MB)
   used     = 0 (0.0MB)
   free     = 34865152 (33.25MB)
   0.0% used
concurrent mark-sweep generation:
   capacity = 7704150016 (7347.25MB)
   used     = 344729288 (328.7594680786133MB)
   free     = 7359420728 (7018.490531921387MB)
   4.47459210015466% used
 
 
free -m查看
[root@es-yidong_data-3_64_116 config]# free -m
             total       used       free     shared    buffers     cached
Mem:          7870       7704        165          0        105        214
-/+ buffers/cache:       7384        485
Swap:         8191       1092       7099
 
刚开始怀疑是 lucene的问题,可是看free 的话, cached 几乎没有怎么使用到, 所以感觉lucene 应该没占用什么内存,
查看其他的内存占用
[root@es-yidong_master_64_119 config]# curl "192.168.64.119:9200/_cat/nodes?h=name,fm,fcm,sm,qcm,im&v"
name                         fm    sm    qcm
es-yidong_data-3_64_116 704.3kb   6mb  3.2mb
es-yidong_data-2_64_117     1mb   6mb 10.5mb
es-yidong_data-1_64_118     1mb 6.1mb   14mb
es-yidong_master_64_119      0b    0b     0b
 
64.116 为当前节点
 
大佬帮忙分析下,为什么ES 启动占用这么多内存
 
已邀请:

zqc0512 - andy zhou

赞同来自:

+HeapDumpOnOutOfMemoryError -Xms7680m -Xmx7680m 
这是撒??

moluck

赞同来自:

我也一样,没啥数据内存占用了7G多。mapping也没啥
{
  "mapping": {
    "_doc": {
      "_meta": {},
      "properties": {
        "@timestamp": {
          "type": "date"
        },
        "ip": {
          "type": "ip"
        },
        "log": {
          "properties": {
            "file": {
              "properties": {
                "path": {
                  "type": "text",
                  "fields": {
                    "keyword": {
                      "type": "keyword",
                      "ignore_above": 256
                    }
                  }
                }
              }
            }
          }
        },
        "message": {
          "type": "text",
          "index": false
        },
        "method": {
          "type": "keyword"
        },
        "request": {
          "type": "keyword"
        },
        "status": {
          "type": "keyword"
        },
        "tags": {
          "type": "keyword"
        }
      }
    }

要回复问题请先登录注册