Broker的参数可以配置在server.properties这个配置文件中,Broker中支持的完整参数在官方文档中有体现。
针对Broker的参数,我们主要分析两块:
Log Flush Policy 参数是设置数据flush到磁盘的时机。为了减少磁盘写入的次数,broker会将消息暂时缓存起来,当消息的个数达到一定阀值或者过了一定的时间间隔后,再flush到磁盘,这样可以减少磁盘IO调用的次数。
这块主要通过两个参数控制:
[root@master kafka]# cd kafka-logs
[root@master kafka-logs]# ll
总用量 20
drwxr-xr-x. 2 root root 141 10月 28 23:05 88888888-1
drwxr-xr-x. 2 root root 141 10月 28 23:05 88888888-2
drwxr-xr-x. 2 root root 141 10月 28 23:08 88888888-3
drwxr-xr-x. 2 root root 141 10月 28 23:05 88888888-4
-rw-r--r--. 1 root root 4 10月 28 10:47 cleaner-offset-checkpoint
drwxr-xr-x. 2 root root 141 10月 28 22:57 __consumer_offsets-1
drwxr-xr-x. 2 root root 141 10月 28 22:57 __consumer_offsets-10
drwxr-xr-x. 2 root root 141 10月 28 22:57 __consumer_offsets-13
drwxr-xr-x. 2 root root 141 10月 28 22:57 __consumer_offsets-16
drwxr-xr-x. 2 root root 141 10月 28 22:57 __consumer_offsets-19
drwxr-xr-x. 2 root root 141 10月 28 22:57 __consumer_offsets-22
drwxr-xr-x. 2 root root 141 10月 28 22:57 __consumer_offsets-25
drwxr-xr-x. 2 root root 141 10月 28 22:57 __consumer_offsets-28
drwxr-xr-x. 2 root root 141 10月 28 22:57 __consumer_offsets-31
drwxr-xr-x. 2 root root 141 10月 28 22:57 __consumer_offsets-34
drwxr-xr-x. 2 root root 141 10月 28 22:57 __consumer_offsets-37
drwxr-xr-x. 2 root root 141 10月 28 22:57 __consumer_offsets-4
drwxr-xr-x. 2 root root 141 10月 28 22:57 __consumer_offsets-40
drwxr-xr-x. 2 root root 141 10月 28 22:57 __consumer_offsets-43
drwxr-xr-x. 2 root root 141 10月 28 22:57 __consumer_offsets-46
drwxr-xr-x. 2 root root 141 10月 28 22:57 __consumer_offsets-49
drwxr-xr-x. 2 root root 141 10月 28 22:57 __consumer_offsets-7
drwxr-xr-x. 2 root root 141 10月 28 20:13 hello-0
-rw-r--r--. 1 root root 4 10月 29 00:02 log-start-offset-checkpoint
-rw-r--r--. 1 root root 88 10月 28 10:07 meta.properties
drwxr-xr-x. 2 root root 141 10月 28 22:50 mytopic-0
drwxr-xr-x. 2 root root 141 10月 28 22:57 mytopic-2
drwxr-xr-x. 2 root root 141 10月 28 22:50 mytopic-3
drwxr-xr-x. 2 root root 141 10月 28 22:50 mytopic-4
-rw-r--r--. 1 root root 520 10月 29 00:02 recovery-point-offset-checkpoint
-rw-r--r--. 1 root root 520 10月 29 00:02 replication-offset-checkpoint
kafka中的数据默认会保存7天,如果kafka每天接收的数据量过大,这样是很占磁盘空间的,建议修改数据保存周期,我们之前在实际工作中是将数据保存周期改为了1天。
数据保存周期主要通过以下这几个参数控制: