Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/apache-kafka/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache kafka 卡夫卡日志压缩未启动_Apache Kafka - Fatal编程技术网

Apache kafka 卡夫卡日志压缩未启动

Apache kafka 卡夫卡日志压缩未启动,apache-kafka,Apache Kafka,我有一个主题,描述如下: Topic:test-topic PartitionCount:1 ReplicationFactor:1 Configs:min.cleanable.dirty.ratio=0.01,min.compaction.lag.ms=86400000,cleanup.policy=compact Topic: test-topic Partition: 0 Leader: 1 Replicas: 1 Isr: 1 我的代理具有log.cl

我有一个主题,描述如下:

Topic:test-topic    PartitionCount:1    ReplicationFactor:1 Configs:min.cleanable.dirty.ratio=0.01,min.compaction.lag.ms=86400000,cleanup.policy=compact
    Topic: test-topic   Partition: 0    Leader: 1   Replicas: 1 Isr: 1
我的代理具有log.cleaner.enable=true

本主题包含870778条消息,其中存在大量重复的密钥(有些达到数千个重复)。根据Kafka的说法,Kafka应该在这些条件下部署日志压缩,并使用给定的密钥修剪除最新消息之外的所有消息。如果不是几个月,也不是几个星期之后。我在这里缺少什么来启动日志压缩

代理配置:

# 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.
broker.id=1

############################# Socket Server Settings #############################

# The port the socket server listens on
port=<port>

# 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().
#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.
#advertised.port=<port accessible by clients>

# The number of threads handling network requests
num.network.threads=8

# The number of threads doing disk I/O
num.io.threads=8

# The send buffer (SO_SNDBUF) used by the socket server
socket.send.buffer.bytes=1048576

# The receive buffer (SO_RCVBUF) used by the socket server
socket.receive.buffer.bytes=1048576

# 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=<dir-path>

# 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=30

############################# 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.

# The number of messages to accept before forcing a flush of data to disk
log.flush.interval.messages=20000
inter.broker.protocol.version=0.8.2.0
log.message.format.version=0.8.2.0

# The maximum amount of time a message can sit in a log before we force a flush
log.flush.interval.ms=10000
message.max.bytes=1000000
auto.create.topics.enable=false
log.index.interval.bytes=4096
log.index.size.max.bytes=10485760
log.flush.scheduler.interval.ms=2000
log.roll.hours=24
log.retention.check.interval.ms=300000
log.segment.bytes=1073741824
############################# 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=24

# 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=1073741824

# The maximum size of a log segment file. When this size is reached a new log segment will be created.
log.segment.bytes=536870912

# The interval at which log segments are checked to see if they can be deleted according 
# to the retention policies

# By default the log cleaner is disabled and the log retention policy will default to just delete segments after their retention expires.
# If log.cleaner.enable=true is set the cleaner will be enabled and individual logs can then be marked for log compaction.
log.cleaner.enable=true

default.replication.factor=3
num.replica.fetchers=4
replica.fetch.max.bytes=1048576
replica.fetch.wait.max.ms=2000
replica.high.watermark.checkpoint.interval.ms=5000
replica.socket.timeout.ms=60000
replica.socket.receive.buffer.bytes=65536
replica.lag.time.max.ms=30000
replica.lag.max.messages=12000

controller.socket.timeout.ms=60000
controller.message.queue.size=20

auto.leader.rebalance.enable=true
leader.imbalance.per.broker.percentage=5
leader.imbalance.check.interval.seconds=300

############################# 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.connect=<connection-string>

# Timeout in ms for connecting to zookeeper
zookeeper.connection.timeout.ms=1000000
#zk.sync.time.ms=2000

kafka.metrics.reporters=com.airbnb.kafka.KafkaStatsdMetricsReporter

# enable the reporter, (false)
external.kafka.statsd.reporter.enabled=true

# the host of the StatsD server (localhost)
external.kafka.statsd.host=statsd
# the port of the StatsD server (8995)
external.kafka.statsd.port=<port>

# a prefix for all metrics names (empty)
external.kafka.statsd.metrics.prefix=<connection-string>
<代码>被授予Apache软件基金会(ASF)以下一个或多个 #贡献者许可协议。请参阅随附的通知文件 #本作品提供了有关版权所有权的更多信息。 #ASF根据Apache许可证2.0版将此文件许可给您 #(以下简称“许可证”);除非符合以下要求,否则不得使用此文件 #执照。您可以通过以下方式获得许可证副本: # # http://www.apache.org/licenses/LICENSE-2.0 # #除非适用法律要求或书面同意,软件 #根据许可证进行的分发是按“原样”进行分发的, #无任何明示或暗示的保证或条件。 #请参阅许可证以了解管理权限和权限的特定语言 #许可证下的限制。 #有关更多详细信息和默认值,请参见kafka.server.kafkanconfig #############################服务器基础############################# #代理的id。对于每个代理,必须将其设置为唯一的整数。 broker.id=1 #############################套接字服务器设置############################# #套接字服务器侦听的端口 港口= #代理将绑定到的主机名。如果未设置,服务器将绑定到所有接口 #host.name=localhost #代理将向生产者和消费者公布主机名。如果未设置,则使用 #“host.name”的值(如果已配置)。否则,它将使用从返回的值 #java.net.InetAddress.getCanonicalHostName()。 #advised.host.name= #要发布到ZooKeeper供客户端使用的端口。如果没有设置, #它将发布代理绑定到的同一端口。 #A.港口= #处理网络请求的线程数 num.network.threads=8 #执行磁盘I/O的线程数 num.io.threads=8 #套接字服务器使用的发送缓冲区(sou SNDBUF) socket.send.buffer.bytes=1048576 #套接字服务器使用的接收缓冲区(SO_RCVBUF) socket.receive.buffer.bytes=1048576 #套接字服务器将接受的请求的最大大小(针对OOM的保护) socket.request.max.bytes=104857600 #############################日志基础############################# #以逗号分隔的目录列表,用于存储日志文件 log.dirs= #每个主题的默认日志分区数。更多的分区允许更大的容量 #并行性,但这也会导致跨 #经纪人。 num.partitions=30 #############################日志刷新策略############################# #消息会立即写入文件系统,但默认情况下,我们只需fsync()进行同步 #操作系统缓存很慢。以下配置控制数据到磁盘的刷新。 #这里有几个重要的权衡: # 1. 持久性:如果不使用复制,未刷新的数据可能会丢失。 # 2. 延迟:当确实发生刷新时,非常大的刷新间隔可能会导致延迟峰值,因为将有大量数据要刷新。 # 3. 吞吐量:刷新通常是最昂贵的操作,较小的刷新间隔可能导致过度搜索。 #下面的设置允许用户配置刷新策略,以便在一段时间或之后刷新数据 #每N条消息(或两者都有)。这可以在全局范围内完成,并在每个主题的基础上覆盖。 #强制将数据刷新到磁盘之前要接受的消息数 log.flush.interval.messages=20000 inter.broker.protocol.version=0.8.2.0 log.message.format.version=0.8.2.0 #在我们强制刷新之前,消息在日志中的最长时间 log.flush.interval.ms=10000 message.max.bytes=1000000 auto.create.topics.enable=false log.index.interval.bytes=4096 log.index.size.max.bytes=10485760 log.flush.scheduler.interval.ms=2000 log.roll.hours=24 log.retention.check.interval.ms=300000 log.segment.bytes=1073741824 #############################日志保留策略############################# #以下配置控制日志段的处理。政策可以 #设置为在一段时间后或在给定大小累积后删除段。 #只要满足这些条件中的*任一*项,就会删除一个段。删除总是发生的 #从日志的末尾。 #符合删除条件的日志文件的最短期限 log.retention.hours=24 #基于大小的日志保留策略。只要剩余的部分被删除,就从日志中删除这些部分 #段不会下降到log.retention.bytes以下。 #log.retention.bytes=1073741824 #日志段文件的最大大小。当达到此大小时,将创建一个新的日志段。 log.segment.bytes=536870912 #检查日志段以查看是否可以根据需要删除日志段的间隔 #保留策略 #默认情况下,日志清理器处于禁用状态,日志保留策略将默认为在保留期到期后仅删除段。 #如果设置了log.cleaner.enable=true,则将启用清洁器,然后可以标记单个日志以进行日志压缩。 log.cleaner.enable=true default.replication.factor=3 num.replica.fetchers=4 replica.fetch.max.bytes=1048576 replica.fetch.wait.max.ms=2000 replica.high.watermark.checkpoint.interval.ms=5000 replica.socket.timeout.ms=60000 replica.socket.receive.buffer.bytes=65536 副本延迟时间最大毫秒=30000 replica.lag.max.messages=12000 controller.socket.timeout.ms=60000 controller.message.queue.size=20 auto.leader.rebalance.enable=true leader.Distancement.per.broker.percentage=5 引线.不平衡.检查.间隔.s
log.segment.bytes=1073741824
log.segment.bytes=536870912
1) To activate compaction cleanup policy cleanup.policy=compact should be placed

2) The consumer sees all tombstones as long as the consumer reaches head of a log in a period less than the topic config delete.retention.ms (the default is 24 hours).

3) The number of these threads are configurable through log.cleaner.threads config

4) The cleaner thread then chooses the log with the highest dirty ratio. dirty ratio = the number of bytes in the head / total number of bytes in the log(tail + head)

5) Topic config min.compaction.lag.ms gets used to guarantee a minimum period that must pass before a message can be compacted.

6) To set delay to start compacting records after they are written use topic config log.cleaner.min.compaction.lag.ms. Records won’t get compacted until after this period. The setting gives consumers time to get every record.