不停机修改 JVM GC 参数

查看哪些参数是支持不停机管理的

java -XX:+PrintFlagsFinal -version|grep manageable,关键在于 manageable

$ java -XX:+PrintFlagsFinal -version|grep manageable
     intx CMSAbortablePrecleanWaitMillis            = 100                                 {manageable}
     intx CMSTriggerInterval                        = -1                                  {manageable}
     intx CMSWaitDuration                           = 2000                                {manageable}
     bool HeapDumpAfterFullGC                       = false                               {manageable}
     bool HeapDumpBeforeFullGC                      = false                               {manageable}
     bool HeapDumpOnOutOfMemoryError                = false                               {manageable}
    ccstr HeapDumpPath                              =                                     {manageable}
    uintx MaxHeapFreeRatio                          = 100                                 {manageable}
    uintx MinHeapFreeRatio                          = 0                                   {manageable}
     bool PrintClassHistogram                       = false                               {manageable}
     bool PrintClassHistogramAfterFullGC            = false                               {manageable}
     bool PrintClassHistogramBeforeFullGC           = false                               {manageable}
     bool PrintConcurrentLocks                      = false                               {manageable}
     bool PrintGC                                   = false                               {manageable}
     bool PrintGCDateStamps                         = false                               {manageable}
     bool PrintGCDetails                            = false                               {manageable}
     bool PrintGCID                                 = false                               {manageable}
     bool PrintGCTimeStamps                         = false                               {manageable}
java version "1.8.0_221"
Java(TM) SE Runtime Environment (build 1.8.0_221-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)

jps 查看当前运行的 jvm 进程

jps -ml 可以看到当前运行的有3个 elastic search jvm进程

$ jps -ml
13712 D:\WeiFuWu\es\cerebro-0.9.4\bin\\\..\lib\\cerebro.cerebro-0.9.4-launcher.jar
3456 org.elasticsearch.bootstrap.Elasticsearch
15652 org.elasticsearch.bootstrap.Elasticsearch -E path.data=data3 -E path.logs=log3
3304 org.elasticsearch.bootstrap.Elasticsearch -E path.data=data2 -E path.logs=log2
10124 sun.tools.jps.Jps -ml

使用 jinfo 修改 GC 参数

修改进程 pid = 3456 的 jvm 进程的 gc 参数

$ jinfo -flag +PrintGCTimeStamps 3456

查看 GC 日志,发现打印的日志内容已经有变化

你看,变了

你可能感兴趣的:(不停机修改 JVM GC 参数)