JVM 堆配置

  1. -Xms64g
  2. -Xmx64g

专家配置

垃圾回收配置

  1. -XX:+UseConcMarkSweepGC
  2. -XX:CMSInitiatingOccupancyFraction=75
  3. -XX:+UseCMSInitiatingOccupancyOnly

  1. -XX:+AlwaysPreTouch

JVM 堆 dumps

JVM遇到OutOfMemoryError时拍摄一个“堆转储快照”,并将其保存在一个文件中。

  1. -XX:+HeapDumpOnOutOfMemoryError
  2. -XX:HeapDumpPath=/tmp/heapdump.hprof
  3. -XX:ErrorFile=logs/hs_err_pid%p.log
  1. ## JVM configuration
  2. ################################################################
  3. ## IMPORTANT: JVM heap size
  4. ################################################################
  5. ##
  6. ## You should always set the min and max JVM heap
  7. ## size to the same value. For example, to set
  8. ## the heap to 4 GB, set:
  9. ##
  10. ## -Xms4g
  11. ## -Xmx4g
  12. ##
  13. ## See https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html
  14. ## for more information
  15. ##
  16. ################################################################
  17. # Xms represents the initial size of total heap space
  18. # Xmx represents the maximum size of total heap space
  19. -Xms64g
  20. -Xmx64g
  21. ################################################################
  22. ## Expert settings
  23. ################################################################
  24. ##
  25. ## All settings below this section are considered
  26. ## expert settings. Don't tamper with them unless
  27. ## you understand what you are doing
  28. ##
  29. ################################################################
  30. ## GC configuration
  31. -XX:+UseConcMarkSweepGC
  32. -XX:CMSInitiatingOccupancyFraction=75
  33. -XX:+UseCMSInitiatingOccupancyOnly
  34. ## optimizations
  35. # pre-touch memory pages used by the JVM during initialization
  36. -XX:+AlwaysPreTouch
  37. ## basic
  38. # explicitly set the stack size
  39. -Xss3m
  40. # set to headless, just in case
  41. -Djava.awt.headless=true
  42. # ensure UTF-8 encoding by default (e.g. filenames)
  43. -Dfile.encoding=UTF-8
  44. # use our provided JNA always versus the system one
  45. -Djna.nosys=true
  46. # turn off a JDK optimization that throws away stack traces for common exceptions because stack traces are important for debugging
  47. -XX:-OmitStackTraceInFastThrow
  48. # flags to configure Netty
  49. -Dio.netty.noUnsafe=true
  50. -Dio.netty.noKeySetOptimization=true
  51. -Dio.netty.recycler.maxCapacityPerThread=0
  52. # log4j 2
  53. -Dlog4j.shutdownHookEnabled=false
  54. -Dlog4j2.disable.jmx=true
  55. -Djava.io.tmpdir=${ES_TMPDIR}
  56. ## heap dumps
  57. # generate a heap dump when an allocation from the Java heap fails
  58. # heap dumps are created in the working directory of the JVM
  59. -XX:+HeapDumpOnOutOfMemoryError
  60. # specify an alternative path for heap dumps; ensure the directory exists and
  61. # has sufficient space
  62. -XX:HeapDumpPath=data
  63. # specify an alternative path for JVM fatal error logs
  64. -XX:ErrorFile=logs/hs_err_pid%p.log
  65. ## JDK 8 GC logging
  66. 8:-XX:+PrintGCDetails
  67. 8:-XX:+PrintGCDateStamps
  68. 8:-XX:+PrintTenuringDistribution
  69. 8:-XX:+PrintGCApplicationStoppedTime
  70. 8:-Xloggc:logs/gc.log
  71. 8:-XX:+UseGCLogFileRotation
  72. 8:-XX:NumberOfGCLogFiles=32
  73. 8:-XX:GCLogFileSize=64m
  74. # JDK 9+ GC logging
  75. 9-:-Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m
  76. # due to internationalization enhancements in JDK 9 Elasticsearch need to set the provider to COMPAT otherwise
  77. # time/date parsing will break in an incompatible way for some date patterns and locals
  78. 9-:-Djava.locale.providers=COMPAT
文档更新时间: 2019-06-21 11:55   作者:admin