server

  1. ############################# Server Basics #############################
  2. # The id of the broker. This must be set to a unique integer for each broker.
  3. broker.id=1
  4. ############################# Socket Server Settings(Socket 服务器设置) #############################
  5. # The address the socket server listens on. It will get the value returned from
  6. # java.net.InetAddress.getCanonicalHostName() if not configured.
  7. # FORMAT:
  8. # listeners = listener_name://host_name:port
  9. # EXAMPLE:
  10. # listeners = PLAINTEXT://your.host.name:9092
  11. # 应对无法消费的 BUG
  12. listeners=PLAINTEXT://172.16.24.140:9092
  13. # Hostname and port the broker will advertise to producers and consumers. If not set,
  14. # it uses the value for "listeners" if configured. Otherwise, it will use the value
  15. # returned from java.net.InetAddress.getCanonicalHostName().
  16. #advertised.listeners=PLAINTEXT://your.host.name:9092
  17. # Maps listener names to security protocols, the default is for them to be the same. See the config documentation for more details
  18. #listener.security.protocol.map=PLAINTEXT:PLAINTEXT,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL
  19. # The number of threads that the server uses for receiving requests from the network and sending responses to the network
  20. # 处理网络请求的最大线程数, 1 - 32
  21. num.network.threads=8
  22. # The number of threads that the server uses for processing requests, which may include disk I/O
  23. # 处理磁盘 I/O 的线程数 1 - 32
  24. num.io.threads=8
  25. # The send buffer (SO_SNDBUF) used by the socket server
  26. # socket 的发送缓冲区(SO_SNDBUF)
  27. socket.send.buffer.bytes=102400
  28. # The receive buffer (SO_RCVBUF) used by the socket server
  29. # socket 的接收缓冲区 (SO_RCVBUF)
  30. socket.receive.buffer.bytes=102400
  31. # The maximum size of a request that the socket server will accept (protection against OOM)
  32. # socket 请求的最大字节数。为了防止内存溢出, message.max.bytes必然要小于
  33. socket.request.max.bytes=104857600
  34. ############################# Log Basics(日志基础设置) #############################
  35. # A comma separated list of directories under which to store log files
  36. log.dirs=/var/log/kafka-logs
  37. # The default number of log partitions per topic. More partitions allow greater
  38. # parallelism for consumption, but this will also result in more files across
  39. # the brokers.
  40. # 每个 topic 的分区个数, 更多的 partition 会产生更多的 segment file, 1 - 1000
  41. num.partitions=1
  42. # The number of threads per data directory to be used for log recovery at startup and flushing at shutdown. 每个数据目录中用于在启动时恢复日志和在关闭时刷新日志的线程数
  43. # This value is recommended to be increased for installations with data dirs located in RAID array. 对于安装 RAID 阵列中的数据 dirs,建议增加此值
  44. # 由于索引文件的数量增加,在一些日志段数量较大的 broker (例如>15K)上,broker 启动期间的日志加载过程可能更长。根据我们的实验,设置 num.recovery.threads.per.data.dir 可能会减少日志加载时间
  45. num.recovery.threads.per.data.dir=1
  46. ############################# Internal Topic Settings(内部 Topic 设置) #############################
  47. # The replication factor for the group metadata internal topics "__consumer_offsets" and "__transaction_state"
  48. # For anything other than development testing, a value greater than 1 is recommended for to ensure availability such as 3.
  49. # topic 复制因子, 在命令行创建是使用命令指定
  50. offsets.topic.replication.factor=1
  51. transaction.state.log.replication.factor=1
  52. transaction.state.log.min.isr=1
  53. ############################# Log Flush Policy(日志刷新策略) #############################
  54. # Messages are immediately written to the filesystem but by default we only fsync() to sync
  55. # the OS cache lazily. The following configurations control the flush of data to disk.
  56. # There are a few important trade-offs here:
  57. # 1. Durability: Unflushed data may be lost if you are not using replication.
  58. # 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.
  59. # 3. Throughput: The flush is generally the most expensive operation, and a small flush interval may lead to excessive seeks.
  60. # The settings below allow one to configure the flush policy to flush data after a period of time or
  61. # every N messages (or both). This can be done globally and overridden on a per-topic basis.
  62. # The number of messages to accept before forcing a flush of data to disk
  63. # 在将数据刷新到磁盘之前要接受的消息数量
  64. #log.flush.interval.messages=10000
  65. # The maximum amount of time a message can sit in a log before we force a flush
  66. # 在强制刷新之前,消息可以在日志中保存的最长时间
  67. #log.flush.interval.ms=1000
  68. ############################# Log Retention Policy(日志保留策略) #############################
  69. # The following configurations control the disposal of log segments. The policy can
  70. # be set to delete segments after a period of time, or after a given size has accumulated.
  71. # A segment will be deleted whenever *either* of these criteria are met. Deletion always happens
  72. # from the end of the log.
  73. # The minimum age of a log file to be eligible for deletion due to age
  74. # 日志保留时间 168 H
  75. log.retention.hours=168
  76. # A size-based retention policy for logs. Segments are pruned from the log unless the remaining
  77. # segments drop below log.retention.bytes. Functions independently of log.retention.hours.
  78. # 日志数据存储的最大字节数。超过这个时间会根据 policy 处理数据。
  79. #log.retention.bytes=1073741824
  80. # The maximum size of a log segment file. When this size is reached a new log segment will be created.
  81. # 单个日志文件的最大大小
  82. log.segment.bytes=1073741824
  83. # The interval at which log segments are checked to see if they can be deleted according
  84. # to the retention policies
  85. # 日志清理程序检查任何日志是否符合删除条件的频率(毫秒)
  86. log.retention.check.interval.ms=300000
  87. ############################# Zookeeper #############################
  88. # Zookeeper connection string (see zookeeper docs for details).
  89. # This is a comma separated host:port pairs, each corresponding to a zk
  90. # server. e.g. "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002".
  91. # You can also append an optional chroot string to the urls to specify the
  92. # root directory for all kafka znodes.
  93. zookeeper.connect=master1:2181,master2:2181,node1:2181
  94. # Timeout in ms for connecting to zookeeper
  95. zookeeper.connection.timeout.ms=10000
  96. ############################# Group Coordinator Settings(组织协调器设置) #############################
  97. # The following configuration specifies the time, in milliseconds, that the GroupCoordinator will delay the initial consumer rebalance.
  98. # The rebalance will be further delayed by the value of group.initial.rebalance.delay.ms as new members join the group, up to a maximum of max.poll.interval.ms.
  99. # The default value for this is 3 seconds.
  100. # We override this to 0 here as it makes for a better out-of-the-box experience for development and testing.
  101. # However, in production environments the default value of 3 seconds is more suitable as this will help to avoid unnecessary, and potentially expensive, rebalances during application startup.
  102. group.initial.rebalance.delay.ms=0