kafka的server配置文件解析

# Server Basics 服务基础
# The id of the broker. This must be set to a unique integer for each broker.
#独立的id标识
broker.id=0

Socket Server Settings 网络接口设置

listeners=PLAINTEXT://:9092
# 通告集群中其他节点使用的地址
advertised.listeners=PLAINTEXT://your.host.name:9092
# 使用的安全协议
listener.security.protocol.map=PLAINTEXT:PLAINTEXT,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL

# The number of threads that the server uses for receiving requests from the network and sending responses to the network
# 用于接收并发送响应的网络线程数
num.network.threads=3

# The number of threads that the server uses for processing requests, which may include disk I/O
num.io.threads=8

# The send buffer (SO_SNDBUF) used by the socket server
#服务器用于接收的缓冲区大小,默认100M
socket.send.buffer.bytes=102400

# The receive buffer (SO_RCVBUF) used by the socket server
# 服务器用于接收的缓冲区大小,默认100M
socket.receive.buffer.bytes=102400

# The maximum size of a request that the socket server will accept (protection against OOM)
# 服务器能够接收的最大请求大小,默认100G
socket.request.max.bytes=104857600

Log Basics 数据基础设置

# A comma seperated list of directories under which to store log files
# 数据存储目录
log.dirs=/tmp/kafka-logs

# The default number of log partitions per topic. More partitions allow greater
# parallelism for consumption, but this will also result in more files across
# the brokers.
# 默认的partition数
num.partitions=1

# The number of threads per data directory to be used for log recovery at startup and flushing at shutdown.
# This value is recommended to be increased for installations with data dirs located in RAID array.
# 用于在服务启动时恢复,或者在服务关闭时刷新的每个数据目录的线程数。
# 默认情况下,每个日志目录只使用一个线程。因为这些线程只是在服务器启动和关闭时会用到,所
# 以完全可以设置大量的线程来达到并行操作的目的。特别是对于包含大量分区的服务器来说,一旦
# 发生崩溃,在进行恢复时使用并行操作可能会省下数小时的时间。设置此参数时需要注意,所配置
# 的数字对应的是 log.dirs 指定的单个日志目录。也就是说,如果 
# num.recovery.threads.per.data.dir 被设为 8,并且 log.dir 指定了 3 
# 个路径,那么总共需要 24 个线程。
num.recovery.threads.per.data.dir=1

Internal Topic Settings 内部主题设置

# The replication factor for the group metadata internal topics "__consumer_offsets" and "__transaction_state"
# For anything other than development testing, a value greater than 1 is recommended for to ensure availability such as 3.
# 内部topics的副本因子配置
# 建议生产环境使用大于1的配置
offsets.topic.replication.factor=1
transaction.state.log.replication.factor=1
transaction.state.log.min.isr=1

Log Flush Policy 数据刷新规则

# Messages are immediately written to the filesystem but by default we only fsync() to sync
# the OS cache lazily. The following configurations control the flush of data to disk.
# There are a few important trade-offs here:
#    持久性: 在不使用副本时,不刷新可能会丢失大量的数据
#    1. Durability: Unflushed data may be lost if you are not using replication.
#    延时性: 一个很大的刷新间隔可能会导致在大量数据被刷新时出现延时波峰
#    2. Latency: Very large flush intervals may lead to latency spikes when the flush does occur as there will be a lot of data to flush.
     吞吐量: 刷新是最昂贵的操作,一个小的刷新周期会导致过多的搜索
#    3. Throughput: The flush is generally the most expensive operation, and a small flush interval may lead to exceessive seeks.
# The settings below allow one to configure the flush policy to flush data after a period of time or
# every N messages (or both). This can be done globally and overridden on a per-topic basis.
kafka支持周期时间或者一定数量的消息后进行刷新。这些操作支持全局并且覆盖每一个topic
# The number of messages to accept before forcing a flush of data to disk
# 刷新的消息量
#log.flush.interval.messages=10000

# The maximum amount of time a message can sit in a log before we force a flush
# 刷新的时间周期
#log.flush.interval.ms=1000

Log Retention Policy 数据保留的规则

支持周期或者是给定大小的删除条件。只要满足给定的条件任意一个,就会发生删除。删除是从最末尾开始的
# The minimum age of a log file to be eligible for deletion due to age
# 保存的过期时间
log.retention.hours=168

# A size-based retention policy for logs. Segments are pruned from the log unless the remaining
# segments drop below log.retention.bytes. Functions independently of log.retention.hours.
# 删除超过指定大小的段,除非这个段降低到小于指定大小(默认大小1TB)
#log.retention.bytes=1073741824

# The maximum size of a log segment file. When this size is reached a new log segment will be created.
# 每个段的大小,超过大小就会创建新的段,默认大小:1TB
log.segment.bytes=1073741824

# The interval at which log segments are checked to see if they can be deleted according
# to the retention policies
# 检查周期
log.retention.check.interval.ms=300000

zk配置

# 可以添加目录,以指定zk的目录信息
zookeeper.connect=localhost:2181

# Timeout in ms for connecting to zookeeper
zookeeper.connection.timeout.ms=6000

group coordinator settings 组配置


# 设置group开启重平衡的延时时间,时间内允许更多的consumer加入group,避免不必要的JoinGroup与SyncGroup之间的切换。但是会带来延时增加,生产上建议设置为3s 
group.initial.rebalance.delay.ms=0

生产配置

broker.id={{ myid }}
listeners=PLAINTEXT://{{ ansible_bond0['ipv4']['address'] }}:9092
# 如下两个参数影响kafka内部生产者把消息从一个broker到另一个broker的时间
# 实际经验来看,适当增加num.network.threads有利于提升请求处理的效率
num.network.threads=8
# 这个参数建议至少是磁盘的数量
num.io.threads=8
#fetcher默认值是1,如果集群由3个broker,那么follower broker启动的线程数为1*3
num.replica.fetchers=3
socket.send.buffer.bytes=102400
socket.receive.buffer.bytes=102400
socket.request.max.bytes=104857600
log.dirs={{ kafka_log_dir }}
num.partitions=3
default.replication.factor=2
offsets.topic.replication.factor=3
transaction.state.log.replication.factor=3
transaction.state.log.min.isr=2
log.retention.hours=168
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000
zookeeper.connect={{ zk_connect_info }}
zookeeper.connection.timeout.ms=6000
group.initial.rebalance.delay.ms=0
delete.topic.enable=true
auto.create.topics.enable=false

num.recovery.threads.per.data.dir=8   
  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值