kafka配置⽂件详解:consumer.properties
consumer作为kafak核⼼组件之⼀,学习和分析它是很有必要的。consumer配置⽂件在kafak的config⽬录下,配置好它在以后的学习和⼯作中都可以起到事半功倍的效果。
#(必需)zookeeper连接服务器地址(集可写多个)
# timeout in ms for connecting to zookeeper
#zookeeper的session的过期时间
#指定多久消费者更新offset到zookeeper中
zookeeper.sync.time.ms=2000
#consumer group id
#(必需)consumer组id
group.id=test-consumer-group
#consumer timeout
#消费者超时
#consumer.timeout.ms=5000
#⾃动向zookeeper提交offset信息
#⾃动更新时间
automit.interval.ms=1000
#当前consumer的标识
#consumer.id=xxx
#消费者客户端编号,⽤于区分不同客户端,默认客户端程序⾃动产⽣
#client.id=xxx
#最⼤取多少块缓存到消费者(默认10)
#ssage.chunks=50
#当有新的consumer加⼊到group时,将会reblance.
#ies=5
#获取消息的最⼤尺⼨,broker不会向consumer输出⼤于此值得chunk
#fetch.min.bytes=655360
补充:consumer.properties详细配置说明
描述
属性默认
group.id Consumer的组ID,相同goup.id的consumer属于同⼀个组。
consumer.id null 如果不设置会⾃动⽣成。socket.timeout.ms 30 *1000
⽹络请求的socket 超时时间。实际超时时间由max.fetch.wait + socket.timeout.ms 确定。ive.buffer.bytes 64 *
1024
The socket receive buffer for network ssage.max.bytes 1024 *
1024查询topic-partition 时允许的最⼤消息⼤⼩。consumer 会为每个partition 缓存此⼤⼩的消息到内存,因此,这个参数可以控制consumer 的内存使⽤量。这个值应该⾄少⽐server 允许的最⼤消息⼤⼩⼤,以免producer 发
送的消息⼤于consumer 允许的消息。
大文件发送
automit.interval.ms 60 *
1000
Consumer 提交offset 值到zookeeper 的周期。ssage.chunks 2⽤来被consumer 消费的message chunks 数量, 每个chunk 可以缓存ssage.max.bytes ⼤⼩的数据
量。
ies 4When a new consumer joins a consumer group the set of consumers attempt to “rebalance” the load to assign partitions to each consumer. If the set of consumers changes while this assignment is taking place the rebalance will fail and retry. This setting controls the maximum number of attempts before giving up.fetch.min.bytes 1The minimum amount of data the server should return for a fetch request. If insufficient data is available the request will wait for that much data to accumulate before answering the request.
fetch.wait.max.ms 100The maximum amount of time the server will block before answering the fetch
request if there isn’t
sufficient data to immediately satisfy fetch.min.bytes.
rebalance.backoff.ms 2000Backoff time between retries during rebalance.
refresh.leader.backoff.ms 200Backoff time to wait before trying to determine the leader of a partition that has just lost its leader.
set largest What to do when there is no initial offset in ZooKeeper or if an offset is out of range ;smallest :
automatically reset the offset to the smallest offset; largest : automatically reset the offset to the largest offset;anything else: throw exception to the consumer
consumer.timeout.ms -1若在指定时间内没有消息消费,consumer 将会抛出异常。
pics true Whether messages from internal topics (such as offsets) should be exposed to the consumer.
zookeeper.session.timeout.ms 6000ZooKeeper session timeout. If the consumer fails to heartbeat to ZooKeeper for this period of time it is
considered dead and a rebalance will occur.
zookeeper.sync.time.ms 2000How far a ZK follower can be behind a ZK leader 属性
默认
描述