JVM - ElasticSearch 默认虚拟机配置参考

## JVM configuration

################################################################

## IMPORTANT: JVM heap size

################################################################

##

## You should always set the min and max JVM heap

## size to the same value. For example, to set

## the heap to 4 GB, set:

##

## -Xms4g

## -Xmx4g

##

## See https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html

## for more information

##

################################################################

# Xms represents the initial size of total heap space

# Xmx represents the maximum size of total heap space

## JVM 堆大小设置

-Xms1g

-Xmx1g

################################################################

## Expert settings

################################################################

##

## All settings below this section are considered

## expert settings. Don't tamper with them unless

## you understand what you are doing

##

################################################################

## GC configuration

-XX:+UseConcMarkSweepGC

@## 即CMS收集,设置年老代为并发收集

-XX:CMSInitiatingOccupancyFraction=75

@## 表示年老代内存空间使用到75%时就开始执行CMS收集,以确保年老代有足够的空间接纳来自年轻代的对象,避免Full GC的发生

-XX:+UseCMSInitiatingOccupancyOnly

@## 扩展CMS垃圾回收机制

@## https://www.cnblogs.com/Leo_wl/p/5393300.html

## optimizations

# pre-touch memory pages used by the JVM during initialization

-XX:+AlwaysPreTouch

@## JVM就会先访问所有分配给它的内存,让操作系统把内存真正的分配给JVM

@## https://blog.csdn.net/linsongbin1/article/details/55049477

## basic

# explicitly set the stack size

-Xss1m

# set to headless, just in case

-Djava.awt.headless=true

@## 如果没有安装图形界面,可以在Java运行时加上参数:-Djava.awt.headless=true

# ensure UTF-8 encoding by default (e.g. filenames)

-Dfile.encoding=UTF-8

# use our provided JNA always versus the system one

-Djna.nosys=true

# turn off a JDK optimization that throws away stack traces for common

# exceptions because stack traces are important for debugging

-XX:-OmitStackTraceInFastThrow

@## 强制要求JVM始终抛出含堆栈的异常(-XX:-OmitStackTraceInFastThrow)  

# flags to configure Netty

-Dio.netty.noUnsafe=true

-Dio.netty.noKeySetOptimization=true

-Dio.netty.recycler.maxCapacityPerThread=0

@## 设置io.netty.noUnsafe属性为true,则默认会使用Heap堆内存创建ByteBuf

# log4j 2

-Dlog4j.shutdownHookEnabled=false

-Dlog4j2.disable.jmx=true

-Djava.io.tmpdir=${ES_TMPDIR}

## heap dumps

# generate a heap dump when an allocation from the Java heap fails

# heap dumps are created in the working directory of the JVM

-XX:+HeapDumpOnOutOfMemoryError

@## 参数表示当JVM发生OOM时,自动生成DUMP文件

# specify an alternative path for heap dumps

# ensure the directory exists and has sufficient space

#-XX:HeapDumpPath=/heap/dump/path

@## 参数表示生成DUMP文件的路径

## JDK 8 GC logging

8:-XX:+PrintGCDetails

8:-XX:+PrintGCDateStamps

8:-XX:+PrintTenuringDistribution

8:-XX:+PrintGCApplicationStoppedTime

8:-Xloggc:logs/gc.log

8:-XX:+UseGCLogFileRotation

8:-XX:NumberOfGCLogFiles=32

8:-XX:GCLogFileSize=64m

# JDK 9+ GC logging

9-:-Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m

# due to internationalization enhancements in JDK 9 Elasticsearch need to set the provider to COMPAT otherwise

# time/date parsing will break in an incompatible way for some date patterns and locals

9-:-Djava.locale.providers=COMPAT

猜你喜欢

转载自blog.csdn.net/lewee0215/article/details/111240848
今日推荐