Skip to main content
 首页 » 编程设计

c#之检查 Elasticsearch 堆大小

2024年02月05日11jpfss

我如何检查分配给 Elasticsearch 引擎的堆大小,有没有办法使用 URL API 来检查它?我可以使用 NEST 来检查吗?

谢谢

请您参考如下方法:

在集群环境中,堆设置可以查询为:

curl -sS  "localhost:9200/_cat/nodes?h=heap*&v" 

例如:

curl -sS  "localhost:9200/_cat/nodes?h=heap*&v" 
heap.current heap.percent heap.max 
     321.1mb           32  989.8mb 
     424.1mb           42  989.8mb 
     280.3mb           28  989.8mb 

这也可以从 ps 结果中检查出来,尽管它只会阐明最小值-最大值。

~#ps aux | grep --color=auto -i Xms 
elastic  6020  0.0  0.0  12788   936 pts/4    S+   04:24   0:00 grep --color=auto -i Xms elastic+  7218 
0.6  9.5 5001220 1565112 ?     Ssl  Jun24   5:14 /usr/bin/java -Xms1g -Xmx1g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+AlwaysPreTouch -Xss1m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -XX:-OmitStackTraceInFastThrow -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -Djava.io.tmpdir=/tmp/elasticsearch.WoiU4NhH -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/lib/elasticsearch -XX:ErrorFile=/var/log/elasticsearch/hs_err_pid%p.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime -Xloggc:/var/log/elasticsearch/gc.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=32 -XX:GCLogFileSize=64m -Xms1g -Xmx1g -Des.path.home=/usr/share/elasticsearch -Des.path.conf=/etc/elasticsearch -Des.distribution.flavor=default -Des.distribution.type=deb -cp /usr/share/elasticsearch/lib/* org.elasticsearch.bootstrap.Elasticsearch -p /var/run/elasticsearch/elasticsearch.pid --quiet 

其中 -Xms 是最小堆,-Xmx 是配置的最大堆。