前言
其實每個版本都有些許改動,只不過改動大小而已,但是網上的教程都真的太老了,其實更新一下也費不了多少時間
0.9.0
# Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # see kafka.server.KafkaConfig for additional details and defaults ############################# 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 # The port the socket server listens on # 監聽端口 #port=9092 # Hostname the broker will bind to. If not set, the server will bind to all interfaces # 節點需要綁定的主機名稱。如果沒有設置,服務器會綁定到所有接口 #host.name=localhost # Hostname the broker will advertise to producers and consumers. If not set, it uses the # value for "host.name" if configured. Otherwise, it will use the value returned from # java.net.InetAddress.getCanonicalHostName(). # 節點的主機名會通知給生產者和消費者。如果沒有設置,它將會使用"host.name"的值(前提是設置了host.name)。 # 否則他會使用java.net.InetAddress.getCanonicalHostName()的返回值 #advertised.host.name=<hostname routable by clients> # The port to publish to ZooKeeper for clients to use. If this is not set, # it will publish the same port that the broker binds to. # 這個端口將暴露給Zookeeper以供客戶端來使用。如果沒有設置,將會暴露節點綁定的端口 #advertised.port=<port accessible by clients> # The number of threads handling network requests # 接受網絡請求的線程數 num.network.threads=3 # The number of threads doing disk I/O、 # 進行磁盤IO的線程數 num.io.threads=8 # The send buffer (SO_SNDBUF) used by the socket server # 套接字服務器使用的發送緩沖區大小 socket.send.buffer.bytes=102400 # The receive buffer (SO_RCVBUF) used by the socket server # 套接字服務器使用的接收緩沖區大小 socket.receive.buffer.bytes=102400 # The maximum size of a request that the socket server will accept (protection against OOM) # 單個請求最大能接收的數據量 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. # 每個主題的日志分區的默認數量。更多的分區允許更大的並行操作,但是它會導致節點產生更多的文件 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. # 每個數據目錄中的線程數,用於在啟動時日志恢復,並在關閉時刷新。 num.recovery.threads.per.data.dir=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. # 消息直接被寫入文件系統,但是默認情況下我們僅僅調用fsync()以延遲的同步系統緩存 # 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. # 1. 持久性:如果不使用復制,未刷新的數據可能會丟失。 # 2. 延遲:非常大的刷新間隔可能會在刷新時導致延遲,因為將會有大量數據刷新。 # 3. 吞吐量:刷新通常是最昂貴的操作,而一個小的刷新間隔可能會導致過多的搜索。 # 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. # 下面的設置允許你去配置刷新策略,每隔一段時間刷新或者一次N個消息(或者兩個都配置)。這可以在全局范圍內完成,並在每個主題的基礎上重寫。 # 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 following configurations control the disposal of log segments. The policy can # be set to delete segments after a period of time, or after a given size has accumulated. # 以下的配置控制了日志段的處理。策略可以配置為每隔一段時間刪除片段或者到達一定大小之后。 # A segment will be deleted whenever *either* of these criteria are met. Deletion always happens # from the end of the log. # 當滿足這些條件時,將會刪除一個片段。刪除總是發生在日志的末尾。 # The minimum age of a log file to be eligible for deletion # 一個日志的最小存活時間,可以被刪除 log.retention.hours=168 # A size-based retention policy for logs. Segments are pruned from the log as long as the remaining # segments don't drop below log.retention.bytes. # 一個基於大小的日志保留策略。段將被從日志中刪除只要剩下的部分段不低於log.retention.bytes。 #log.retention.bytes=1073741824 # The maximum size of a log segment file. When this size is reached a new log segment will be created. # 每一個日志段大小的最大值。當到達這個大小時,會生成一個新的片段。 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 ############################# Zookeeper ############################# # Zookeeper connection string (see zookeeper docs for details). # Zookeeper連接字符串(具體見Zookeeper文檔) # This is a comma separated host:port pairs, each corresponding to a zk # 這是一個以逗號為分割的部分,每一個都匹配一個Zookeeper # server. e.g. "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002". # You can also append an optional chroot string to the urls to specify the # root directory for all kafka znodes. # 您還可以將一個可選的chroot字符串附加到url,以指定所有kafka znode的根目錄。 zookeeper.connect=localhost:2181 # Timeout in ms for connecting to zookeeper # 連接到Zookeeper的超時時間 zookeeper.connection.timeout.ms=6000
0.10.1
# Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # see kafka.server.KafkaConfig for additional details and defaults ############################# Server Basics ############################# # The id of the broker. This must be set to a unique integer for each broker. # 節點的ID,必須與其它節點不同 broker.id=0 # Switch to enable topic deletion or not, default value is false # 選擇啟用刪除主題功能,默認false #delete.topic.enable=true ############################# Socket Server Settings ############################# # The address the socket server listens on. It will get the value returned from # java.net.InetAddress.getCanonicalHostName() if not configured. # 套接字服務器堅挺的地址。如果沒有配置,就使用java.net.InetAddress.getCanonicalHostName()的返回值 # FORMAT:格式: # listeners = security_protocol://host_name:port # EXAMPLE:例子: # listeners = PLAINTEXT://your.host.name:9092 #listeners=PLAINTEXT://:9092 # Hostname and port the broker will advertise to producers and consumers. If not set, # it uses the value for "listeners" if configured. Otherwise, it will use the value # returned from java.net.InetAddress.getCanonicalHostName(). # 節點的主機名會通知給生產者和消費者。如果沒有設置,如果配置了"listeners"就使用"listeners"的值。 # 否則就使用java.net.InetAddress.getCanonicalHostName()的返回值 #advertised.listeners=PLAINTEXT://your.host.name:9092 # The number of threads handling network requests # 接受網絡請求的線程數 num.network.threads=3 # The number of threads doing disk I/O # 進行磁盤IO的線程數 num.io.threads=8 # The send buffer (SO_SNDBUF) used by the socket server # 套接字服務器使用的發送緩沖區大小 socket.send.buffer.bytes=102400 # The receive buffer (SO_RCVBUF) used by the socket server # 套接字服務器使用的接收緩沖區大小 socket.receive.buffer.bytes=102400 # The maximum size of a request that the socket server will accept (protection against OOM) # 單個請求最大能接收的數據量 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. # 每個主題的日志分區的默認數量。更多的分區允許更大的並行操作,但是它會導致節點產生更多的文件 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. # 每個數據目錄中的線程數,用於在啟動時日志恢復,並在關閉時刷新。 num.recovery.threads.per.data.dir=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. # 消息直接被寫入文件系統,但是默認情況下我們僅僅調用fsync()以延遲的同步系統緩存 # 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. # 1. 持久性:如果不使用復制,未刷新的數據可能會丟失。 # 2. 延遲:非常大的刷新間隔可能會在刷新時導致延遲,因為將會有大量數據刷新。 # 3. 吞吐量:刷新通常是最昂貴的操作,而一個小的刷新間隔可能會導致過多的搜索。 # 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. # 下面的設置允許你去配置刷新策略,每隔一段時間刷新或者一次N個消息(或者兩個都配置)。這可以在全局范圍內完成,並在每個主題的基礎上重寫。 # 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 following configurations control the disposal of log segments. The policy can # be set to delete segments after a period of time, or after a given size has accumulated. # 以下的配置控制了日志段的處理。策略可以配置為每隔一段時間刪除片段或者到達一定大小之后。 # A segment will be deleted whenever *either* of these criteria are met. Deletion always happens # from the end of the log. # 當滿足這些條件時,將會刪除一個片段。刪除總是發生在日志的末尾。 # The minimum age of a log file to be eligible for deletion # 一個日志的最小存活時間,可以被刪除 log.retention.hours=168 # A size-based retention policy for logs. Segments are pruned from the log as long as the remaining # segments don't drop below log.retention.bytes. # 一個基於大小的日志保留策略。段將被從日志中刪除只要剩下的部分段不低於log.retention.bytes。 #log.retention.bytes=1073741824 # The maximum size of a log segment file. When this size is reached a new log segment will be created. # 每一個日志段大小的最大值。當到達這個大小時,會生成一個新的片段。 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 ############################# Zookeeper ############################# # Zookeeper connection string (see zookeeper docs for details). # Zookeeper連接字符串(具體見Zookeeper文檔) # This is a comma separated host:port pairs, each corresponding to a zk # 這是一個以逗號為分割的部分,每一個都匹配一個Zookeeper # server. e.g. "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002". # You can also append an optional chroot string to the urls to specify the # root directory for all kafka znodes. # 您還可以將一個可選的chroot字符串附加到url,以指定所有kafka znode的根目錄。 zookeeper.connect=localhost:2181 # Timeout in ms for connecting to zookeeper # 連接到Zookeeper的超時時間 zookeeper.connection.timeout.ms=6000
0.11.0
# Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # see kafka.server.KafkaConfig for additional details and defaults ############################# Server Basics ############################# # The id of the broker. This must be set to a unique integer for each broker. # 節點的ID,必須與其它節點不同 broker.id=0 # Switch to enable topic deletion or not, default value is false # 選擇啟用刪除主題功能,默認false #delete.topic.enable=true ############################# Socket Server Settings ############################# # The address the socket server listens on. It will get the value returned from # java.net.InetAddress.getCanonicalHostName() if not configured. # 套接字服務器堅挺的地址。如果沒有配置,就使用java.net.InetAddress.getCanonicalHostName()的返回值 # FORMAT: # listeners = listener_name://host_name:port # EXAMPLE: # listeners = PLAINTEXT://your.host.name:9092 #listeners=PLAINTEXT://:9092 # Hostname and port the broker will advertise to producers and consumers. If not set, # it uses the value for "listeners" if configured. Otherwise, it will use the value # returned from java.net.InetAddress.getCanonicalHostName(). # 節點的主機名會通知給生產者和消費者。如果沒有設置,如果配置了"listeners"就使用"listeners"的值。 # 否則就使用java.net.InetAddress.getCanonicalHostName()的返回值 #advertised.listeners=PLAINTEXT://your.host.name:9092 # Maps listener names to security protocols, the default is for them to be the same. See the config documentation for more details # 將偵聽器的名稱映射到安全協議,默認情況下它們是相同的。有關詳細信息,請參閱配置文檔 #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 # 服務器用來處理請求的線程數,可能包括磁盤IO num.io.threads=8 # The send buffer (SO_SNDBUF) used by the socket server # 套接字服務器使用的發送緩沖區大小 socket.send.buffer.bytes=102400 # The receive buffer (SO_RCVBUF) used by the socket server # 套接字服務器使用的接收緩沖區大小 socket.receive.buffer.bytes=102400 # The maximum size of a request that the socket server will accept (protection against OOM) # 單個請求最大能接收的數據量 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. # 每個主題的日志分區的默認數量。更多的分區允許更大的並行操作,但是它會導致節點產生更多的文件 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. # 每個數據目錄中的線程數,用於在啟動時日志恢復,並在關閉時刷新。 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. # 對於除了開發測試之外的其他任何東西,group元數據內部主題的復制因子“__consumer_offsets”和“__transaction_state”,建議值大於1,以確保可用性(如3)。 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. # 消息直接被寫入文件系統,但是默認情況下我們僅僅調用fsync()以延遲的同步系統緩存 # 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. # 1. 持久性:如果不使用復制,未刷新的數據可能會丟失。 # 2. 延遲:非常大的刷新間隔可能會在刷新時導致延遲,因為將會有大量數據刷新。 # 3. 吞吐量:刷新通常是最昂貴的操作,而一個小的刷新間隔可能會導致過多的搜索。 # 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. # 下面的設置允許你去配置刷新策略,每隔一段時間刷新或者一次N個消息(或者兩個都配置)。這可以在全局范圍內完成,並在每個主題的基礎上重寫。 # 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 following configurations control the disposal of log segments. The policy can # be set to delete segments after a period of time, or after a given size has accumulated. # 以下的配置控制了日志段的處理。策略可以配置為每隔一段時間刪除片段或者到達一定大小之后。 # A segment will be deleted whenever *either* of these criteria are met. Deletion always happens # from the end of the log. # 當滿足這些條件時,將會刪除一個片段。刪除總是發生在日志的末尾。 # The minimum age of a log file to be eligible for deletion # 一個日志的最小存活時間,可以被刪除 log.retention.hours=168 # A size-based retention policy for logs. Segments are pruned from the log as long as the remaining # segments don't drop below log.retention.bytes. # 一個基於大小的日志保留策略。段將被從日志中刪除只要剩下的部分段不低於log.retention.bytes。 #log.retention.bytes=1073741824 # The maximum size of a log segment file. When this size is reached a new log segment will be created. # 每一個日志段大小的最大值。當到達這個大小時,會生成一個新的片段。 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 ############################# Zookeeper ############################# # Zookeeper connection string (see zookeeper docs for details). # Zookeeper連接字符串(具體見Zookeeper文檔) # This is a comma separated host:port pairs, each corresponding to a zk # 這是一個以逗號為分割的部分,每一個都匹配一個Zookeeper # server. e.g. "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002". # You can also append an optional chroot string to the urls to specify the # root directory for all kafka znodes. # 您還可以將一個可選的chroot字符串附加到url,以指定所有kafka znode的根目錄。 zookeeper.connect=localhost:2181 # Timeout in ms for connecting to zookeeper # 連接到Zookeeper的超時時間 zookeeper.connection.timeout.ms=6000 ############################# Group Coordinator Settings ############################# # The following configuration specifies the time, in milliseconds, that the GroupCoordinator will delay the initial consumer rebalance. # 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. # The default value for this is 3 seconds. # We override this to 0 here as it makes for a better out-of-the-box experience for development and testing. # 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. group.initial.rebalance.delay.ms=0
小結
可以看出,目前最新版本的配置文件沒有了
#port=9092 #host.name=localhost #advertised.host.name=<hostname routable by clients> #advertised.port=<port accessible by clients>
取而代之的是
#listeners=PLAINTEXT://:9092 #advertised.listeners=PLAINTEXT://your.host.name:9092
並且新增了一些配置,以及有些地方注釋的說明更詳細。
=====================2020.4.15更新=====================
1.1.1、2.0.0、2.1.1、2.2.0、2.3.0、2.4.1
# Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # see kafka.server.KafkaConfig for additional details and defaults ############################# 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 ############################# # The address the socket server listens on. It will get the value returned from # java.net.InetAddress.getCanonicalHostName() if not configured. # FORMAT: # listeners = listener_name://host_name:port # EXAMPLE: # listeners = PLAINTEXT://your.host.name:9092 # 套接字服務器監聽的地址。如果沒有配置,就使用java.net.InetAddress.getCanonicalHostName()的返回值 #listeners=PLAINTEXT://:9092 # Hostname and port the broker will advertise to producers and consumers. If not set, # it uses the value for "listeners" if configured. Otherwise, it will use the value # returned from java.net.InetAddress.getCanonicalHostName(). #advertised.listeners=PLAINTEXT://your.host.name:9092 # Maps listener names to security protocols, the default is for them to be the same. See the config documentation for more details #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 # 進行磁盤IO的線程數 num.io.threads=8 # The send buffer (SO_SNDBUF) used by the socket server # 套接字服務器使用的發送緩沖區大小 socket.send.buffer.bytes=102400 # The receive buffer (SO_RCVBUF) used by the socket server # 套接字服務器使用的接收緩沖區大小 socket.receive.buffer.bytes=102400 # The maximum size of a request that the socket server will accept (protection against OOM) # 單個請求最大能接收的數據量 socket.request.max.bytes=104857600 ############################# Log Basics ############################# # A comma separated 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. # 每個主題的日志分區的默認數量。更多的分區允許更大的並行操作,但是它會導致節點產生更多的文件 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. # 每個數據目錄中的線程數,用於在啟動時日志恢復,並在關閉時刷新。 num.recovery.threads.per.data.dir=1 ############################# Internal Topic Settings ############################# # The replication factor for the group metadata internal topics "__consumer_offsets" and "__transaction_state" # 內部主題“_consumer_offsets”和“_transaction_state”的復制因子 # For anything other than development testing, a value greater than 1 is recommended for to ensure availability such as 3. # 對於開發測試以外的任何情況,建議使用大於1的值來確保可用性,比如3。 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. # 消息直接被寫入文件系統,但是默認情況下我們僅僅調用fsync()以延遲的同步系統緩存 # 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 excessive seeks. # 1. 持久性:如果不使用復制,未刷新的數據可能會丟失。 # 2. 延遲:非常大的刷新間隔可能會在刷新時導致延遲,因為將會有大量數據刷新。 # 3. 吞吐量:刷新通常是最昂貴的操作,而一個小的刷新間隔可能會導致過多的搜索。 # 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. # 下面的設置允許你去配置刷新策略,每隔一段時間刷新或者一次N個消息(或者兩個都配置)。這可以在全局范圍內完成,並在每個主題的基礎上重寫。 # 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 following configurations control the disposal of log segments. The policy can # be set to delete segments after a period of time, or after a given size has accumulated. # 以下的配置控制了日志段的處理。策略可以配置為每隔一段時間刪除片段或者到達一定大小之后。 # A segment will be deleted whenever *either* of these criteria are met. Deletion always happens # from the end of the log. # 當滿足這些條件時,將會刪除一個片段。刪除總是發生在日志的末尾。 # 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. # 一個基於大小的日志保留策略。只要剩下的部分不低於log.retention.bytes,段將從日志中刪除。 #log.retention.bytes=1073741824 # The maximum size of a log segment file. When this size is reached a new log segment will be created. # 每一個日志段大小的最大值。當到達這個大小時,會生成一個新的片段。 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 ############################# Zookeeper ############################# # Zookeeper connection string (see zookeeper docs for details). # This is a comma separated host:port pairs, each corresponding to a zk # server. e.g. "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002". # You can also append an optional chroot string to the urls to specify the # root directory for all kafka znodes. # 配置zookeeper地址,多個以逗號分隔,還可以在最后指定kafka存儲的namespace:eg:"127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002/kafka" zookeeper.connect=localhost:2181 # Timeout in ms for connecting to zookeeper # 連接到Zookeeper的超時時間 zookeeper.connection.timeout.ms=6000 ############################# Group Coordinator Settings ############################# # The following configuration specifies the time, in milliseconds, that the GroupCoordinator will delay the initial consumer rebalance. # 指定GroupCoordinator延遲初始消費者再平衡的時間(以毫秒為單位) # 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. # The default value for this is 3 seconds. # 默認值是3秒 # We override this to 0 here as it makes for a better out-of-the-box experience for development and testing. # 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. # 在生產環境中,3秒的默認值更合適 group.initial.rebalance.delay.ms=0
更多詳細配置見官網:http://kafka.apache.org/documentation/#configuration
生產端配置
# Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # see org.apache.kafka.clients.producer.ProducerConfig for more details ############################# Producer Basics ############################# # list of brokers used for bootstrapping knowledge about the rest of the cluster # format: host1:port1,host2:port2 ... bootstrap.servers=localhost:9092 # 指定數據壓縮格式:none、gzip、snappy、lz4、zstd compression.type=none # name of the partitioner class for partitioning events; default partition spreads data randomly # 分區策略,默認隨機 #partitioner.class= # the maximum amount of time the client will wait for the response of a request # 客戶端等待請求響應的最大時間,即在向 producer 發送 ack 之前,broker允許等待的最大時間 #request.timeout.ms= # how long `KafkaProducer.send` and `KafkaProducer.partitionsFor` will block for # `KafkaProducer.send` and `KafkaProducer.partitionsFor`阻塞的時間 #max.block.ms= # the producer will wait for up to the given delay to allow other records to be sent so that the sends can be batched together # 生產者將等待一個延遲,以便和其他的消息組合成一個批次發出,減少發送的請求數 #linger.ms= # the maximum size of a request in bytes # 請求的最大字節數 #max.request.size= # the default batch size in bytes when batching multiple records sent to a partition # 在批處理消息發送到一個分區的多個記錄時的批處理大小,默認16k #batch.size= # the total bytes of memory the producer can use to buffer records waiting to be sent to the server # 生產者可以用來緩存消息的緩沖區大小 #buffer.memory= # 以下是默認配置文件沒有的:更多 http://kafka.apache.org/documentation/#producerconfigs # 在請求完成之前,生產者要求leader已收到確認消息的數量。 # 0:生產者不會等待服務器的ack響應,不保證服務器收到消息,返回的偏移量總是-1 # 1:leader將消息寫入本地日志,但不會管其他follower是否寫入。 # all:leader和所有的follower都成功同步消息才會返回ack,保證消息不會丟失。all等價於-1. acks=