Service.properties arguments detailed

Service.properties arguments detailed

server.properties is Kafka's main configuration file, the following brief meaning of which configuration items. The core of the three most general configuration broker.id, log.dir, zookeeper.connect. Other configurations can be modified according to their own needs.

Enter the configuration directory, usually associated configuration mainly in the following three

 

 Other configuration is as follows:

 

Service.properties arguments detailed

parameter

Functional Description

Recommendations

broker.id=0

Each Broker-only identity in the cluster. Broker even if the IP address has changed, broker.id as long as no change, then the message will not affect the situation of consumers

Nowhere to be modified to a different broker Id, is typically an integer

log.dirs=/data/kafka-logs

Kafka storage address data, the plurality of addresses if a comma-separated, a plurality of directories are distributed on different disk read and write performance can be increased / data / kafka-logs-1, / data / kafka-logs-2

It needs to be modified according to the directory using the general

port =9092

broker server service port

 

message.max.bytes =6525000

It represents the maximum size of the message body, in bytes

 

num.network.threads =4

broker maximum number of threads to process messages, in general, the number is the number of cpu core

 

num.io.threads =8

broker number of processing threads disk IO, a value of two times the number of cpu core

 

background.threads =4

Some background task processing threads, for example, delete outdated message file, under normal circumstances you do not need to modify

 

queued.max.requests =500

IO Threading waiting queue maximum number of requests, if the request is waiting for IO exceeds this value, it will stop accepting external message, it should be a self-protection mechanism.

 

host.name

broker host address, if set up, it will bind to this address, if not, it will bind to all interfaces, and send one of them to ZK, generally do not set

 

socket.send.buffer.bytes=100*1024

The socket transmit buffer, socket tuning parameters SO_SNDBUFF

 

socket.receive.buffer.bytes =100*1024

the socket receive buffer, socket tuning parameters SO_RCVBUFF

 

socket.request.max.bytes =100*1024*1024

socket requested maximum value, when the cover to prevent the specified parameters serverOOM, message.max.bytes bound to less than socket.request.max.bytes, will be created topic

 

log.segment.bytes =1024*1024*1024

topic partition based on a bunch of files stored in the segment, the control of the size of each segment, covering the specified parameters will be created when the topic

Log segment size

log.roll.hours =24*7

This parameter does not reach the size of log.segment.bytes set in the log segment, covering the time specified parameters will be forced to create a new segment will be created topic

 

log.cleanup.policy = delete

Log cleanup strategy choose: delete expired and compact mainly for data processing, or log file reaches the limit on the amount of specified parameters will be created when the topic covered

 

log.retention.minutes=300

log.retention.hours=24

How long to keep data files, maximum storage time than this time will clear strategy based on log.cleanup.policy setting data
log.retention.bytes and log.retention.minutes any one or log.retention.hours meet the requirements will delete
2 has a data file deleting:
  according delete file size: log.retention.bytes
  different time granularities delete it by 2: Split minutes, hours

 

log.retention.bytes=-1

topic每个分区的最大文件大小,一个topic的大小限制 = 分区数*log.retention.bytes。-1没有大小限log.retention.bytes和log.retention.minutes任意一个达到要求,都会执行删除,会被topic创建时的指定参数覆盖

必须限制日志文件的最大大小,防止出现日志占满磁盘的情况

log.retention.check.interval.ms=5minutes

文件大小检查的周期时间,是否处罚 log.cleanup.policy中设置的策略

 

log.cleaner.enable=false

是否开启日志清理

 

log.cleaner.threads = 2

日志清理运行的线程数

 

log.cleaner.io.max.bytes.per.second=None

日志清理时候处理的最大大小

 

log.cleaner.dedupe.buffer.size=500*1024*1024

日志清理去重时候的缓存空间,在空间允许的情况下,越大越好

 

log.cleaner.io.buffer.size=512*1024

日志清理时候用到的IO块大小一般不需要修改

 

log.cleaner.io.buffer.load.factor =0.9

日志清理中hash表的扩大因子一般不需要修改

 

log.cleaner.backoff.ms =15000

检查是否处罚日志清理的间隔

 

log.cleaner.min.cleanable.ratio=0.5

日志清理的频率控制,越大意味着更高效的清理,同时会存在一些空间上的浪费,会被topic创建时的指定参数覆盖

 

log.cleaner.delete.retention.ms =1day

对于压缩的日志保留的最长时间,也是客户端消费消息的最长时间,同log.retention.minutes的区别在于一个控制未压缩数据,一个控制压缩后的数据。会被topic创建时的指定参数覆盖

 

log.index.size.max.bytes =10*1024*1024

对于segment日志的索引文件大小限制,会被topic创建时的指定参数覆盖

 

log.index.interval.bytes =4096

当执行一个fetch操作后,需要一定的空间来扫描最近的offset大小,设置越大,代表扫描速度越快,但是也更好内存,一般情况下不需要搭理这个参数

 

log.flush.interval.messages=None
例如log.flush.interval.messages=1000
表示每当消息记录数达到1000时flush一次数据到磁盘

log文件”sync”到磁盘之前累积的消息条数,因为磁盘IO操作是一个慢操作,但又是一个”数据可靠性"的必要手段,所以此参数的设置,需要在"数据可靠性"与"性能"之间做必要的权衡.如果此值过大,将会导致每次"fsync"的时间较长(IO阻塞),如果此值过小,将会导致"fsync"的次数较多,这也意味着整体的client请求有一定的延迟.物理server故障,将会导致没有fsync的消息丢失.

 

log.flush.scheduler.interval.ms =3000

检查是否需要固化到硬盘的时间间隔

 

log.flush.interval.ms = None
例如:log.flush.interval.ms=1000
表示每间隔1000毫秒flush一次数据到磁盘

仅仅通过interval来控制消息的磁盘写入时机,是不足的.此参数用于控制"fsync"的时间间隔,如果消息量始终没有达到阀值,但是离上一次磁盘同步的时间间隔达到阀值,也将触发.

 

log.delete.delay.ms =60000

文件在索引中清除后保留的时间一般不需要去修改

 

log.flush.offset.checkpoint.interval.ms =60000

控制上次固化硬盘的时间点,以便于数据恢复一般不需要去修改

 

auto.create.topics.enable =true

是否允许自动创建topic,若是false,就需要通过命令创建topic

 

default.replication.factor =1

一个topic ,默认分区的replication个数 ,不得大于集群中broker的个数

 

num.partitions =1

每个topic的分区个数,若是在topic创建时候没有指定的话会被topic创建时的指定参数覆盖

 

controller.socket.timeout.ms =30000

partition leader与replicas之间通讯时,socket的超时时间

 

controller.message.queue.size=10

partition leader与replicas数据同步时,消息的队列尺寸

 

replica.lag.time.max.ms =10000

replicas响应partition leader的最长等待时间,若是超过这个时间,就将replicas列入ISR(in-sync replicas),并认为它是死的,不会再加入管理中

 

replica.lag.max.messages =4000

如果follower落后与leader太多,将会认为此follower[或者说partition relicas]已经失效
##通常,在follower与leader通讯时,因为网络延迟或者链接断开,总会导致replicas中消息同步滞后
##如果消息之后太多,leader将认为此follower网络延迟较大或者消息吞吐能力有限,将会把此replicas迁移
##到其他follower中.
##在broker数量较少,或者网络不足的环境中,建议提高此值.

 

replica.socket.timeout.ms=30*1000

follower与leader之间的socket超时时间

 

replica.socket.receive.buffer.bytes=64*1024

leader复制时候的socket缓存大小

 

replica.fetch.max.bytes =1024*1024

replicas每次获取数据的最大大小

 

replica.fetch.wait.max.ms =500

replicas同leader之间通信的最大等待时间,失败了会重试

 

replica.fetch.min.bytes =1

fetch的最小数据尺寸,如果leader中尚未同步的数据不足此值,将会阻塞,直到满足条件

 

num.replica.fetchers=1

leader进行复制的线程数,增大这个数值会增加follower的IO

 

replica.high.watermark.checkpoint.interval.ms =5000

每个replica检查是否将最高水位进行固化的频率

 

controlled.shutdown.enable =false

是否允许控制器关闭broker ,若是设置为true,会关闭所有在这个broker上的leader,并转移到其他broker

 

controlled.shutdown.max.retries =3

控制器关闭的尝试次数

 

controlled.shutdown.retry.backoff.ms =5000

每次关闭尝试的时间间隔

 

leader.imbalance.per.broker.percentage =10

leader的不平衡比例,若是超过这个数值,会对分区进行重新的平衡

 

leader.imbalance.check.interval.seconds =300

检查leader是否不平衡的时间间隔

 

offset.metadata.max.bytes

客户端保留offset信息的最大空间大小

 

zookeeper.connect = localhost:2181

zookeeper集群的地址,可以是多个,多个之间用逗号分割hostname1:port1,hostname2:port2,hostname3:port3

 

zookeeper.session.timeout.ms=6000

ZooKeeper的最大超时时间,就是心跳的间隔,若是没有反映,那么认为已经死了,不易过大

 

zookeeper.connection.timeout.ms =6000

ZooKeeper的连接超时时间

 

zookeeper.sync.time.ms =2000

ZooKeeper集群中leader和follower之间的同步时间

 

consumer.properties参数详解

参数

功能描述

使用建议

group.id

Consumer归属的组ID,broker是根据group.id来判断是队列模式还是发布订阅模式,非常重要

 

 consumer.id

消费者的ID,若是没有设置的话,会自增

 

client.id = group id value

一个用于跟踪调查的ID ,最好同group.id相同

 

zookeeper.connect=localhost:2182

对于zookeeper集群的指定,可以是多个 hostname1:port1,hostname2:port2,hostname3:port3 必须和broker使用同样的zk配置

 

zookeeper.session.timeout.ms = 6000

zookeeper的心跳超时时间,查过这个时间就认为是dead消费者

 

zookeeper.connection.timeout.ms = 6000

zookeeper的等待连接时间

 

zookeeper.sync.time.ms = 2000

zookeeper的follower同leader的同步时间

 

auto.offset.reset = largest

当zookeeper中没有初始的offset时候的处理方式 。smallest :重置为最小值 largest:重置为最大值 anything else:抛出异常

 

socket.timeout.ms= 30 * 1000

socket的超时时间,实际的超时时间是:max.fetch.wait + socket.timeout.ms.

 

 socket.receive.buffer.bytes=64 * 1024

socket的接受缓存空间大小

 

fetch.message.max.bytes = 1024 * 1024

从每个分区获取的消息大小限制

 

auto.commit.interval.ms = 60 * 1000

自动提交的时间间隔

 

queued.max.message.chunks = 10

用来处理消费消息的块,每个块可以等同于fetch.message.max.bytes中数值

 

rebalance.max.retries = 4

## 当有新的consumer加入到group时,将会reblance,此后将会有partitions的消费端迁移到新的consumer上,如果一个consumer获得了某个partition的消费权限,那么它将会向zk注册"Partition Owner registry"节点信息,但是有可能此时旧的consumer尚没有释放此节点,
## 此值用于控制,注册节点的重试次数.

 

rebalance.backoff.ms = 2000

每次再平衡的时间间隔

 

refresh.leader.backoff.ms

每次重新选举leader的时间

 

fetch.min.bytes = 1

server发送到消费端的最小数据,若是不满足这个数值则会等待,知道满足数值要求

 

fetch.wait.max.ms = 100

若是不满足最小大小(fetch.min.bytes)的话,等待消费端请求的最长等待时间

 

consumer.timeout.ms = -1

指定时间内没有消息到达就抛出异常,一般不需要改

 

         

 

 

producer.properties参数详解

参数

功能描述

使用建议

metadata.broker.list

消费者获取消息元信息(topics, partitions and replicas)的地址,配置格式是:host1:port1,host2:port2,也可以在外面设置一个vip

 

request.required.acks = 0

##消息的确认模式
 ## 0:不保证消息的到达确认,只管发送,低延迟但是会出现消息的丢失,在某个server失败的情况下,有点像TCP
 ## 1:发送消息,并会等待leader 收到确认后,一定的可靠性
 ## -1:发送消息,等待leader收到确认,并进行复制操作后,才返回,最高的可靠性

 

request.timeout.ms = 10000

消息发送的最长等待时间

 

send.buffer.bytes=100*1024

socket的缓存大小

 

key.serializer.class

key的序列化方式,若是没有设置,同serializer.class

 

partitioner.class=kafka.producer.DefaultPartitioner

分区的策略,默认是取模

 

compression.codec = none

消息的压缩模式,默认是none,可以有gzip和snappy

 

compressed.topics=null

可以针对默写特定的topic进行压缩

 

message.send.max.retries = 3

消息发送失败后的重试次数

 

retry.backoff.ms = 100

每次失败后的间隔时间

 

topic.metadata.refresh.interval.ms = 600 * 1000

生产者定时更新topic元信息的时间间隔 ,若是设置为0,那么会在每个消息发送后都去更新数据

 

client.id=""

用户随意指定,但是不能重复,主要用于跟踪记录消息

 

producer.type=sync

生产者的类型 async:异步执行消息的发送 sync:同步执行消息的发送

 

queue.buffering.max.ms = 5000

异步模式下,那么就会在设置的时间缓存消息,并一次性发送

 

queue.buffering.max.messages = 10000

异步的模式下 最长等待的消息数

 

queue.enqueue.timeout.ms = -1

异步模式下,进入队列的等待时间 若是设置为0,那么要么进入队列,要么直接抛弃

 

batch.num.messages=200

异步模式下,每次发送的最大消息数,前提是触发了queue.buffering.max.messages或是queue.buffering.max.ms的限制

 

serializer.class = kafka.serializer.DefaultEncoder

消息体的系列化处理类 ,转化为字节流进行传输

 

 

 

参考:

https://blog.csdn.net/selfsojourner/article/details/44957135

https://blog.csdn.net/lizhitao/article/details/25667831

Guess you like

Origin www.cnblogs.com/zhy-heaven/p/10994268.html