kafka JVM调优

Kafka 堆内存建议每个节点:10G ~ 15G ,在 kafka-server-start.sh 中修改

vim bin/kafka-server-start.sh

if [ "x$KAFKA_HEAP_OPTS" = "x" ]; then     
	export KAFKA_HEAP_OPTS="-Xmx10G -Xms10G" 
fi

查看 Kafka 进程号

[root@hadoop100 bin]# jps
1122 QuorumPeerMain
12834 Jps
1519 Kafka

根据 Kafka 进程号,查看 Kafka 的 GC 情况

[root@hadoop100 bin]# jstat -gc 1519 1s 10 
 S0C    S1C    S0U    S1U      EC       EU        OC         OU       MC     MU    CCSC   CCSU   YGC     YGCT    FGC    FGCT     GCT   
 0.0   5120.0  0.0   5120.0 454656.0 412672.0 1637376.0   147725.0  50044.0 45195.5 6524.0 5946.2     14    0.655   0      0.000    0.655
 0.0   5120.0  0.0   5120.0 454656.0 412672.0 1637376.0   147725.0  50044.0 45195.5 6524.0 5946.2     14    0.655   0      0.000    0.655
 0.0   5120.0  0.0   5120.0 454656.0 412672.0 1637376.0   147725.0  50044.0 45195.5 6524.0 5946.2     14    0.655   0      0.000    0.655
 0.0   5120.0  0.0   5120.0 454656.0 412672.0 1637376.0   147725.0  50044.0 45195.5 6524.0 5946.2     14    0.655   0      0.000    0.655
 0.0   5120.0  0.0   5120.0 454656.0 413696.0 1637376.0   147725.0  50044.0 45195.5 6524.0 5946.2     14    0.655   0      0.000    0.655
 0.0   5120.0  0.0   5120.0 454656.0 413696.0 1637376.0   147725.0  50044.0 45195.5 6524.0 5946.2     14    0.655   0      0.000    0.655
 0.0   5120.0  0.0   5120.0 454656.0 413696.0 1637376.0   147725.0  50044.0 45195.5 6524.0 5946.2     14    0.655   0      0.000    0.655
 0.0   5120.0  0.0   5120.0 454656.0 413696.0 1637376.0   147725.0  50044.0 45195.5 6524.0 5946.2     14    0.655   0      0.000    0.655
 0.0   5120.0  0.0   5120.0 454656.0 414720.0 1637376.0   147725.0  50044.0 45195.5 6524.0 5946.2     14    0.655   0      0.000    0.655
 0.0   5120.0  0.0   5120.0 454656.0 414720.0 1637376.0   147725.0  50044.0 45195.5 6524.0 5946.2     14    0.655   0      0.000    0.655

参数说明:

S0C:第一个幸存区的大小;      S1C:第二个幸存区的大小 
S0U:第一个幸存区的使用大小;  S1U:第二个幸存区的使用大小 
EC:伊甸园区的大小;           EU:伊甸园区的使用大小 
OC:老年代大小;               OU:老年代使用大小 
MC:方法区大小;               MU:方法区使用大小 
CCSC:压缩类空间大小;           CCSU:压缩类空间使用大小 
YGC:年轻代垃圾回收次数;      YGCT:年轻代垃圾回收消耗时间 
FGC:老年代垃圾回收次数;       FGCT:老年代垃圾回收消耗时间 
GCT:垃圾回收消耗总时间; 

根据 Kafka 进程号,查看 Kafka 的堆内存

[root@hadoop100 ~]# jmap -heap 1519
Attaching to process ID 1519, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.311-b11

using thread-local object allocation.
Garbage-First (G1) GC with 8 thread(s)

Heap Configuration:
   MinHeapFreeRatio         = 40
   MaxHeapFreeRatio         = 70
   MaxHeapSize              = 2147483648 (2048.0MB)
   NewSize                  = 1363144 (1.2999954223632812MB)
   MaxNewSize               = 1287651328 (1228.0MB)
   OldSize                  = 5452592 (5.1999969482421875MB)
   NewRatio                 = 2
   SurvivorRatio            = 8
   MetaspaceSize            = 21807104 (20.796875MB)
   CompressedClassSpaceSize = 1073741824 (1024.0MB)
   MaxMetaspaceSize         = 17592186044415 MB
   G1HeapRegionSize         = 1048576 (1.0MB)

Heap Usage:
G1 Heap:
   regions  = 2048
   capacity = 2147483648 (2048.0MB)
   used     = 161066704 (153.6051788330078MB)
   free     = 1986416944 (1894.3948211669922MB)
   7.50025287270546% used
G1 Young Generation:
Eden Space:
   regions  = 3
   capacity = 106954752 (102.0MB)
   used     = 3145728 (3.0MB)
   free     = 103809024 (99.0MB)
   2.9411764705882355% used
Survivor Space:
   regions  = 6
   capacity = 6291456 (6.0MB)
   used     = 6291456 (6.0MB)
   free     = 0 (0.0MB)
   100.0% used
G1 Old Generation:
   regions  = 146
   capacity = 2034237440 (1940.0MB)
   used     = 151629520 (144.6051788330078MB)
   free     = 1882607920 (1795.3948211669922MB)
   7.453875197577722% used

12666 interned Strings occupying 1403296 bytes.

你可能感兴趣的:(kafka,Java,大数据,kafka,jvm,java)