\nbin\nconfig\nlibs\nLICENSE\nlicenses\nNOTICE\nsite-docs\n<\/code><\/pre>\n\n\n\nRunning Kafka with Kafta Raft (KRaft)<\/h3>\n\n\n\n
In this guide, we will configure Kafka with KRaft without Zookeeper.<\/p>\n\n\n\n
Beginning from v2.8.0, Kafka now supports and uses KRaft as the new Raft consensus algorithm. KRaft is designed to provide strong consistency and fault-tolerance in distributed systems. It allows Kafka to achieve replication and synchronization of metadata across the Kafka brokers in a reliable and efficient manner without relying on Zookeeper.<\/p>\n\n\n\n
As much as Zookeeper is still being supported, it is planned to be completely phased in Kafka v4.0 releases.<\/p>\n\n\n\n
Setup KRaft for Kafka Cluster<\/h4>\n\n\n\n
The KRaft configuration files are under, \/opt\/kafka\/config\/kraft\/<\/code><\/strong>;<\/p>\n\n\n\nls -1 \/opt\/kafka\/config\/kraft\/<\/code><\/pre>\n\n\n\n\nbroker.properties\ncontroller.properties\nserver.properties\n<\/code><\/pre>\n\n\n\nWe are using a single-node Kafka cluster in this guide. Thus we will proceed with the most of the settings set to default<\/strong>, except the updates of the logs directory paths below.<\/p>\n\n\n\nUpdate Logs Directory<\/h4>\n\n\n\n
By default, Kafka sets \/tmp\/kraft-combined-logs<\/strong><\/code> as the default logs directory. I am gonna change this to \/opt\/kafka\/logs<\/code><\/strong>. You can keep it if you want.<\/p>\n\n\n\nmkdir \/opt\/kafka\/logs<\/code><\/pre>\n\n\n\nsed -i '\/^log.dirs\/s|\/tmp\/kraft-combined-logs|\/opt\/kafka\/logs|' \\\n\/opt\/kafka\/config\/kraft\/server.properties<\/code><\/pre>\n\n\n\nGenerate Kafka Cluster ID<\/h4>\n\n\n\n
In KRaft mode, a cluster ID that is used to uniquely identify a cluster is required.<\/p>\n\n\n\n
The cluster ID can be generated using the command below;<\/p>\n\n\n\n
\/opt\/kafka\/bin\/kafka-storage.sh random-uuid<\/code><\/pre>\n\n\n\nThe command prints a random UUID like URaeRekUQAyy8wLMNX2Q-w<\/code><\/strong>.<\/p>\n\n\n\nNext, using the cluster ID generated above, format log directories. This is so as ensure uniqueness is maintained and each Kafka broker can have a unique directory for storing its log data, especially if you had multi-node cluster.<\/p>\n\n\n\n
The logs directory can be formatted using the command below, with the ID generated above;<\/p>\n\n\n\n
\/opt\/kafka\/bin\/kafka-storage.sh format -t <uuid> -c \/opt\/kafka\/config\/kraft\/server.properties<\/code><\/pre>\n\n\n\nReplace the UUID as follows;<\/p>\n\n\n\n
\/opt\/kafka\/bin\/kafka-storage.sh format -t URaeRekUQAyy8wLMNX2Q-w \\\n-c \/opt\/kafka\/config\/kraft\/server.properties<\/code><\/pre>\n\n\n\nOr you can can simply use one command;<\/p>\n\n\n\n
\/opt\/kafka\/bin\/kafka-storage.sh format \\\n-t `\/opt\/kafka\/bin\/kafka-storage.sh random-uuid` \\\n-c \/opt\/kafka\/config\/kraft\/server.properties<\/code><\/pre>\n\n\n\nYou will such an output as;<\/p>\n\n\n\n
Formatting \/opt\/kafka\/logs with metadata.version 3.5-IV2.<\/code><\/pre>\n\n\n\nSimilarly, some configuration files are generated and stored under the logs directory;<\/p>\n\n\n\n
ls -1 \/opt\/kafka\/logs\/<\/code><\/pre>\n\n\n\nbootstrap.checkpoint\nmeta.properties<\/code><\/pre>\n\n\n\nTo ensure optimal performance and stability of Kafka, you need to configure the heap size appropriately. This refers to the memory allocated to the Java Virtual Machine (JVM) running Kafka.<\/p>\n\n\n\n
This is set to 1G by default;<\/p>\n\n\n\n
grep KAFKA_HEAP_OPTS= \/opt\/kafka\/bin\/kafka-server-start.sh<\/code><\/pre>\n\n\n\nSample output;<\/p>\n\n\n\n
export KAFKA_HEAP_OPTS=\"-Xmx1G -Xms1G\"<\/code><\/pre>\n\n\n\nDepending on the size of the RAM allocated to your server, update this accordingly. Ensure that the allocated heap size is sufficient to handle the expected message traffic and the size of the data being processed.<\/p>\n\n\n\n
One of the other settings, log.retention.hours<\/code><\/strong> (default 7 days), that may indirectly affected memory utilization is how long does Kafka store the event data. This will primarily affect the storage.<\/p>\n\n\n\nYou can use other parameters such as log.retention.minutes<\/code>, log.retention.ms<\/code>, or log.retention.bytes<\/code>.<\/p>\n\n\n\nAs such, you can update the value of this in the broker configuration file, \/opt\/kafka\/config\/kraft\/server.properties<\/code><\/strong>.<\/p>\n\n\n\nvim \/opt\/kafka\/config\/kraft\/server.properties<\/code><\/pre>\n\n\n\nUse any of the parameters above to define time or size of logs in bytes.<\/p>\n\n\n\n
For example, to keep data for 8 hours, enter the line below in the server.properties<\/strong>.<\/p>\n\n\n\nlog.retention.hours=8<\/code><\/pre>\n\n\n\nSave and exit the file.<\/p>\n\n\n\n
For reference, this is how our config is like;<\/p>\n\n\n\n
cat \/opt\/kafka\/config\/kraft\/server.properties<\/code><\/pre>\n\n\n\n\n# Licensed to the Apache Software Foundation (ASF) under one or more\n# contributor license agreements. See the NOTICE file distributed with\n# this work for additional information regarding copyright ownership.\n# The ASF licenses this file to You under the Apache License, Version 2.0\n# (the \"License\"); you may not use this file except in compliance with\n# the License. You may obtain a copy of the License at\n#\n# http:\/\/www.apache.org\/licenses\/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n#\n# This configuration file is intended for use in KRaft mode, where\n# Apache ZooKeeper is not present. See config\/kraft\/README.md for details.\n#\n\n############################# Server Basics #############################\n\n# The role of this server. Setting this puts us in KRaft mode\nprocess.roles=broker,controller\n\n# The node id associated with this instance's roles\nnode.id=1\n\n# The connect string for the controller quorum\ncontroller.quorum.voters=1@localhost:9093\n\n############################# Socket Server Settings #############################\n\n# The address the socket server listens on.\n# Combined nodes (i.e. those with `process.roles=broker,controller`) must list the controller listener here at a minimum.\n# If the broker listener is not defined, the default listener will use a host name that is equal to the value of java.net.InetAddress.getCanonicalHostName(),\n# with PLAINTEXT listener name, and port 9092.\n# FORMAT:\n# listeners = listener_name:\/\/host_name:port\n# EXAMPLE:\n# listeners = PLAINTEXT:\/\/your.host.name:9092\nlisteners=PLAINTEXT:\/\/:9092,CONTROLLER:\/\/:9093\n\n# Name of listener used for communication between brokers.\ninter.broker.listener.name=PLAINTEXT\n\n# Listener name, hostname and port the broker will advertise to clients.\n# If not set, it uses the value for \"listeners\".\nadvertised.listeners=PLAINTEXT:\/\/:9092\n\n# A comma-separated list of the names of the listeners used by the controller.\n# If no explicit mapping set in `listener.security.protocol.map`, default will be using PLAINTEXT protocol\n# This is required if running in KRaft mode.\ncontroller.listener.names=CONTROLLER\n\n# Maps listener names to security protocols, the default is for them to be the same. See the config documentation for more details\nlistener.security.protocol.map=CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL\n\n# The number of threads that the server uses for receiving requests from the network and sending responses to the network\nnum.network.threads=3\n\n# The number of threads that the server uses for processing requests, which may include disk I\/O\nnum.io.threads=8\n\n# The send buffer (SO_SNDBUF) used by the socket server\nsocket.send.buffer.bytes=102400\n\n# The receive buffer (SO_RCVBUF) used by the socket server\nsocket.receive.buffer.bytes=102400\n\n# The maximum size of a request that the socket server will accept (protection against OOM)\nsocket.request.max.bytes=104857600\n\n\n############################# Log Basics #############################\n\n# A comma separated list of directories under which to store log files\nlog.dirs=\/opt\/kafka\/logs\n\n# The default number of log partitions per topic. More partitions allow greater\n# parallelism for consumption, but this will also result in more files across\n# the brokers.\nnum.partitions=1\n\n# The number of threads per data directory to be used for log recovery at startup and flushing at shutdown.\n# This value is recommended to be increased for installations with data dirs located in RAID array.\nnum.recovery.threads.per.data.dir=1\n\n############################# Internal Topic Settings #############################\n# The replication factor for the group metadata internal topics \"__consumer_offsets\" and \"__transaction_state\"\n# For anything other than development testing, a value greater than 1 is recommended to ensure availability such as 3.\noffsets.topic.replication.factor=1\ntransaction.state.log.replication.factor=1\ntransaction.state.log.min.isr=1\n\n############################# Log Flush Policy #############################\n\n# Messages are immediately written to the filesystem but by default we only fsync() to sync\n# the OS cache lazily. The following configurations control the flush of data to disk.\n# There are a few important trade-offs here:\n# 1. Durability: Unflushed data may be lost if you are not using replication.\n# 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.\n# 3. Throughput: The flush is generally the most expensive operation, and a small flush interval may lead to excessive seeks.\n# The settings below allow one to configure the flush policy to flush data after a period of time or\n# every N messages (or both). This can be done globally and overridden on a per-topic basis.\n\n# The number of messages to accept before forcing a flush of data to disk\n#log.flush.interval.messages=10000\n\n# The maximum amount of time a message can sit in a log before we force a flush\n#log.flush.interval.ms=1000\n\n############################# Log Retention Policy #############################\n\n# The following configurations control the disposal of log segments. The policy can\n# be set to delete segments after a period of time, or after a given size has accumulated.\n# A segment will be deleted whenever *either* of these criteria are met. Deletion always happens\n# from the end of the log.\n\n# The minimum age of a log file to be eligible for deletion due to age\nlog.retention.hours=168\n\n# A size-based retention policy for logs. Segments are pruned from the log unless the remaining\n# segments drop below log.retention.bytes. Functions independently of log.retention.hours.\n#log.retention.bytes=1073741824\n\n# The maximum size of a log segment file. When this size is reached a new log segment will be created.\nlog.segment.bytes=1073741824\n\n# The interval at which log segments are checked to see if they can be deleted according\n# to the retention policies\nlog.retention.check.interval.ms=300000\n<\/code><\/pre>\n\n\n\nStart Kafka Broker<\/h3>\n\n\n\n
You can now start your Kafka broker.<\/p>\n\n\n\n
Starting Kafka Broker in the Foreground<\/h4>\n\n\n\n
You can start Kafka broker on command line using the command below. In this method, the broker runs as a foreground process.<\/p>\n\n\n\n
\/opt\/kafka\/bin\/kafka-server-start.sh \/opt\/kafka\/config\/kraft\/server.properties<\/code><\/pre>\n\n\n\nSample output;<\/p>\n\n\n\n
\n[2023-07-14 17:56:02,942] INFO Registered kafka:type=kafka.Log4jController MBean (kafka.utils.Log4jControllerRegistration$)\n[2023-07-14 17:56:03,195] INFO Setting -D jdk.tls.rejectClientInitiatedRenegotiation=true to disable client-initiated TLS renegotiation (org.apache.zookeeper.common.X509Util)\n[2023-07-14 17:56:03,321] INFO Registered signal handlers for TERM, INT, HUP (org.apache.kafka.common.utils.LoggingSignalHandler)\n[2023-07-14 17:56:03,323] INFO [ControllerServer id=1] Starting controller (kafka.server.ControllerServer)\n[2023-07-14 17:56:03,662] INFO Updated connection-accept-rate max connection creation rate to 2147483647 (kafka.network.ConnectionQuotas)\n[2023-07-14 17:56:03,697] INFO [SocketServer listenerType=CONTROLLER, nodeId=1] Created data-plane acceptor and processors for endpoint : ListenerName(CONTROLLER) (kafka.network.SocketServer)\n[2023-07-14 17:56:03,699] INFO [SharedServer id=1] Starting SharedServer (kafka.server.SharedServer)\n[2023-07-14 17:56:03,799] INFO [LogLoader partition=__cluster_metadata-0, dir=\/opt\/kafka\/logs] Loading producer state till offset 0 with message format version 2 (kafka.log.UnifiedLog$)\n[2023-07-14 17:56:03,801] INFO [LogLoader partition=__cluster_metadata-0, dir=\/opt\/kafka\/logs] Reloading from producer snapshot and rebuilding producer state from offset 0 (kafka.log.UnifiedLog$)\n[2023-07-14 17:56:03,801] INFO [LogLoader partition=__cluster_metadata-0, dir=\/opt\/kafka\/logs] Producer state recovery took 0ms for snapshot load and 0ms for segment recovery from offset 0 (kafka.log.UnifiedLog$)\n[2023-07-14 17:56:03,836] INFO Initialized snapshots with IDs SortedSet() from \/opt\/kafka\/logs\/__cluster_metadata-0 (kafka.raft.KafkaMetadataLog$)\n[2023-07-14 17:56:03,858] INFO [raft-expiration-reaper]: Starting (kafka.raft.TimingWheelExpirationService$ExpiredOperationReaper)\n[2023-07-14 17:56:03,984] INFO [RaftManager id=1] Completed transition to Unattached(epoch=0, voters=[1], electionTimeoutMs=1000) from null (org.apache.kafka.raft.QuorumState)\n[2023-07-14 17:56:04,001] INFO [RaftManager id=1] Completed transition to CandidateState(localId=1, epoch=1, retries=1, voteStates={1=GRANTED}, highWatermark=Optional.empty, electionTimeoutMs=1569) from Unattached(epoch=0, voters=[1], electionTimeoutMs=1000) (org.apache.kafka.raft.QuorumState)\n[2023-07-14 17:56:04,015] INFO [RaftManager id=1] Completed transition to Leader(localId=1, epoch=1, epochStartOffset=0, highWatermark=Optional.empty, voterStates={1=ReplicaState(nodeId=1, endOffset=Optional.empty, lastFetchTimestamp=-1, lastCaughtUpTimestamp=-1, hasAcknowledgedLeader=true)}) from CandidateState(localId=1, epoch=1, retries=1, voteStates={1=GRANTED}, highWatermark=Optional.empty, electionTimeoutMs=1569) (org.apache.kafka.raft.QuorumState)\n[2023-07-14 17:56:04,054] INFO [kafka-1-raft-outbound-request-thread]: Starting (kafka.raft.RaftSendThread)\n[2023-07-14 17:56:04,057] INFO [kafka-1-raft-io-thread]: Starting (kafka.raft.KafkaRaftManager$RaftIoThread)\n[2023-07-14 17:56:04,067] INFO [ControllerServer id=1] Waiting for controller quorum voters future (kafka.server.ControllerServer)\n[2023-07-14 17:56:04,067] INFO [ControllerServer id=1] Finished waiting for controller quorum voters future (kafka.server.ControllerServer)\n[2023-07-14 17:56:04,072] INFO [MetadataLoader id=1] initializeNewPublishers: the loader is still catching up because we still don't know the high water mark yet. (org.apache.kafka.image.loader.MetadataLoader)\n[2023-07-14 17:56:04,098] INFO [RaftManager id=1] High watermark set to LogOffsetMetadata(offset=1, metadata=Optional[(segmentBaseOffset=0,relativePositionInSegment=91)]) for the first time for epoch 1 based on indexOfHw 0 and voters [ReplicaState(nodeId=1, endOffset=Optional[LogOffsetMetadata(offset=1, metadata=Optional[(segmentBaseOffset=0,relativePositionInSegment=91)])], lastFetchTimestamp=-1, lastCaughtUpTimestamp=-1, hasAcknowledgedLeader=true)] (org.apache.kafka.raft.LeaderState)\n[2023-07-14 17:56:04,115] INFO [controller-1-ThrottledChannelReaper-Fetch]: Starting (kafka.server.ClientQuotaManager$ThrottledChannelReaper)\n[2023-07-14 17:56:04,118] INFO [controller-1-ThrottledChannelReaper-Produce]: Starting (kafka.server.ClientQuotaManager$ThrottledChannelReaper)\n[2023-07-14 17:56:04,119] INFO [RaftManager id=1] Registered the listener org.apache.kafka.image.loader.MetadataLoader@1406781066 (org.apache.kafka.raft.KafkaRaftClient)\n[2023-07-14 17:56:04,119] INFO [RaftManager id=1] Registered the listener org.apache.kafka.controller.QuorumController$QuorumMetaLogListener@429592426 (org.apache.kafka.raft.KafkaRaftClient)\n[2023-07-14 17:56:04,122] INFO [controller-1-ThrottledChannelReaper-ControllerMutation]: Starting (kafka.server.ClientQuotaManager$ThrottledChannelReaper)\n[2023-07-14 17:56:04,126] INFO [controller-1-ThrottledChannelReaper-Request]: Starting (kafka.server.ClientQuotaManager$ThrottledChannelReaper)\n[2023-07-14 17:56:04,131] INFO [MetadataLoader id=1] handleCommit: The loader is still catching up because we have loaded up to offset -1, but the high water mark is 1 (org.apache.kafka.image.loader.MetadataLoader)\n[2023-07-14 17:56:04,152] INFO [ExpirationReaper-1-AlterAcls]: Starting (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)\n[2023-07-14 17:56:04,161] INFO [SocketServer listenerType=CONTROLLER, nodeId=1] Enabling request processing. (kafka.network.SocketServer)\n[2023-07-14 17:56:04,164] INFO Awaiting socket connections on 0.0.0.0:9093. (kafka.network.DataPlaneAcceptor)\n[2023-07-14 17:56:04,168] INFO [MetadataLoader id=1] handleCommit: The loader finished catching up to the current high water mark of 3 (org.apache.kafka.image.loader.MetadataLoader)\n[2023-07-14 17:56:04,175] INFO [MetadataLoader id=1] InitializeNewPublishers: initializing SnapshotGenerator with a snapshot at offset 2 (org.apache.kafka.image.loader.MetadataLoader)\n[2023-07-14 17:56:04,183] INFO [ControllerServer id=1] Waiting for all of the authorizer futures to be completed (kafka.server.ControllerServer)\n[2023-07-14 17:56:04,183] INFO [ControllerServer id=1] Finished waiting for all of the authorizer futures to be completed (kafka.server.ControllerServer)\n[2023-07-14 17:56:04,183] INFO [ControllerServer id=1] Waiting for all of the SocketServer Acceptors to be started (kafka.server.ControllerServer)\n[2023-07-14 17:56:04,183] INFO [ControllerServer id=1] Finished waiting for all of the SocketServer Acceptors to be started (kafka.server.ControllerServer)\n[2023-07-14 17:56:04,187] INFO [MetadataLoader id=1] InitializeNewPublishers: initializing DynamicConfigPublisher controller id=1 with a snapshot at offset 2 (org.apache.kafka.image.loader.MetadataLoader)\n[2023-07-14 17:56:04,188] INFO [MetadataLoader id=1] InitializeNewPublishers: initializing DynamicClientQuotaPublisher controller id=1 with a snapshot at offset 2 (org.apache.kafka.image.loader.MetadataLoader)\n[2023-07-14 17:56:04,189] INFO [MetadataLoader id=1] InitializeNewPublishers: initializing ScramPublisher controller id=1 with a snapshot at offset 2 (org.apache.kafka.image.loader.MetadataLoader)\n[2023-07-14 17:56:04,190] INFO [MetadataLoader id=1] InitializeNewPublishers: initializing ControllerMetadataMetricsPublisher with a snapshot at offset 2 (org.apache.kafka.image.loader.MetadataLoader)\n[2023-07-14 17:56:04,191] INFO [ControllerServer id=1] Waiting for the controller metadata publishers to be installed (kafka.server.ControllerServer)\n[2023-07-14 17:56:04,191] INFO [ControllerServer id=1] Finished waiting for the controller metadata publishers to be installed (kafka.server.ControllerServer)\n[2023-07-14 17:56:04,192] INFO [BrokerServer id=1] Transition from SHUTDOWN to STARTING (kafka.server.BrokerServer)\n[2023-07-14 17:56:04,192] INFO [BrokerServer id=1] Starting broker (kafka.server.BrokerServer)\n[2023-07-14 17:56:04,220] INFO [broker-1-ThrottledChannelReaper-Fetch]: Starting (kafka.server.ClientQuotaManager$ThrottledChannelReaper)\n[2023-07-14 17:56:04,221] INFO [broker-1-ThrottledChannelReaper-Produce]: Starting (kafka.server.ClientQuotaManager$ThrottledChannelReaper)\n[2023-07-14 17:56:04,221] INFO [broker-1-ThrottledChannelReaper-Request]: Starting (kafka.server.ClientQuotaManager$ThrottledChannelReaper)\n[2023-07-14 17:56:04,229] INFO [broker-1-ThrottledChannelReaper-ControllerMutation]: Starting (kafka.server.ClientQuotaManager$ThrottledChannelReaper)\n[2023-07-14 17:56:04,242] INFO [BrokerServer id=1] Waiting for controller quorum voters future (kafka.server.BrokerServer)\n[2023-07-14 17:56:04,243] INFO [BrokerServer id=1] Finished waiting for controller quorum voters future (kafka.server.BrokerServer)\n[2023-07-14 17:56:04,269] INFO [broker-1-to-controller-forwarding-channel-manager]: Starting (kafka.server.BrokerToControllerRequestThread)\n[2023-07-14 17:56:04,278] INFO [broker-1-to-controller-forwarding-channel-manager]: Recorded new controller, from now on will use node localhost:9093 (id: 1 rack: null) (kafka.server.BrokerToControllerRequestThread)\n[2023-07-14 17:56:04,324] INFO Updated connection-accept-rate max connection creation rate to 2147483647 (kafka.network.ConnectionQuotas)\n[2023-07-14 17:56:04,336] INFO [SocketServer listenerType=BROKER, nodeId=1] Created data-plane acceptor and processors for endpoint : ListenerName(PLAINTEXT) (kafka.network.SocketServer)\n[2023-07-14 17:56:04,349] INFO [broker-1-to-controller-alter-partition-channel-manager]: Starting (kafka.server.BrokerToControllerRequestThread)\n[2023-07-14 17:56:04,350] INFO [broker-1-to-controller-alter-partition-channel-manager]: Recorded new controller, from now on will use node localhost:9093 (id: 1 rack: null) (kafka.server.BrokerToControllerRequestThread)\n[2023-07-14 17:56:04,356] INFO [ExpirationReaper-1-Produce]: Starting (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)\n[2023-07-14 17:56:04,358] INFO [ExpirationReaper-1-Fetch]: Starting (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)\n[2023-07-14 17:56:04,363] INFO [ExpirationReaper-1-DeleteRecords]: Starting (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)\n[2023-07-14 17:56:04,370] INFO [ExpirationReaper-1-ElectLeader]: Starting (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)\n[2023-07-14 17:56:04,391] INFO [ExpirationReaper-1-Heartbeat]: Starting (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)\n[2023-07-14 17:56:04,393] INFO [ExpirationReaper-1-Rebalance]: Starting (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)\n[2023-07-14 17:56:04,424] INFO [broker-1-to-controller-heartbeat-channel-manager]: Starting (kafka.server.BrokerToControllerRequestThread)\n[2023-07-14 17:56:04,424] INFO [broker-1-to-controller-heartbeat-channel-manager]: Recorded new controller, from now on will use node localhost:9093 (id: 1 rack: null) (kafka.server.BrokerToControllerRequestThread)\n[2023-07-14 17:56:04,426] INFO [BrokerLifecycleManager id=1] Incarnation TQ2qRl0eQ_iLD0w_Cq9TkA of broker 1 in cluster URaeRekUQAyy8wLMNX2Q-w is now STARTING. (kafka.server.BrokerLifecycleManager)\n[2023-07-14 17:56:04,490] INFO [ExpirationReaper-1-AlterAcls]: Starting (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)\n[2023-07-14 17:56:04,572] INFO [BrokerServer id=1] Waiting for the broker metadata publishers to be installed (kafka.server.BrokerServer)\n[2023-07-14 17:56:04,572] INFO [MetadataLoader id=1] InitializeNewPublishers: initializing BrokerMetadataPublisher with a snapshot at offset 2 (org.apache.kafka.image.loader.MetadataLoader)\n[2023-07-14 17:56:04,577] INFO [BrokerMetadataPublisher id=1] Publishing initial metadata at offset OffsetAndEpoch(offset=2, epoch=1) with metadata.version 3.5-IV2. (kafka.server.metadata.BrokerMetadataPublisher)\n[2023-07-14 17:56:04,578] INFO Loading logs from log dirs ArraySeq(\/opt\/kafka\/logs) (kafka.log.LogManager)\n[2023-07-14 17:56:04,582] INFO No logs found to be loaded in \/opt\/kafka\/logs (kafka.log.LogManager)\n[2023-07-14 17:56:04,588] INFO Loaded 0 logs in 10ms (kafka.log.LogManager)\n[2023-07-14 17:56:04,590] INFO [BrokerServer id=1] Finished waiting for the broker metadata publishers to be installed (kafka.server.BrokerServer)\n[2023-07-14 17:56:04,591] INFO [BrokerServer id=1] Waiting for the controller to acknowledge that we are caught up (kafka.server.BrokerServer)\n[2023-07-14 17:56:04,592] INFO [BrokerLifecycleManager id=1] Successfully registered broker 1 with broker epoch 3 (kafka.server.BrokerLifecycleManager)\n[2023-07-14 17:56:04,599] INFO Starting log cleanup with a period of 300000 ms. (kafka.log.LogManager)\n[2023-07-14 17:56:04,600] INFO Starting log flusher with a default period of 9223372036854775807 ms. (kafka.log.LogManager)\n[2023-07-14 17:56:04,704] INFO [kafka-log-cleaner-thread-0]: Starting (kafka.log.LogCleaner$CleanerThread)\n[2023-07-14 17:56:04,717] INFO [LogDirFailureHandler]: Starting (kafka.server.ReplicaManager$LogDirFailureHandler)\n[2023-07-14 17:56:04,717] INFO [GroupCoordinator 1]: Starting up. (kafka.coordinator.group.GroupCoordinator)\n[2023-07-14 17:56:04,720] INFO [GroupCoordinator 1]: Startup complete. (kafka.coordinator.group.GroupCoordinator)\n[2023-07-14 17:56:04,721] INFO [TransactionCoordinator id=1] Starting up. (kafka.coordinator.transaction.TransactionCoordinator)\n[2023-07-14 17:56:04,724] INFO [TxnMarkerSenderThread-1]: Starting (kafka.coordinator.transaction.TransactionMarkerChannelManager)\n[2023-07-14 17:56:04,724] INFO [TransactionCoordinator id=1] Startup complete. (kafka.coordinator.transaction.TransactionCoordinator)\n[2023-07-14 17:56:04,725] INFO [BrokerMetadataPublisher id=1] Updating metadata.version to 11 at offset OffsetAndEpoch(offset=2, epoch=1). (kafka.server.metadata.BrokerMetadataPublisher)\n[2023-07-14 17:56:04,749] INFO [BrokerLifecycleManager id=1] The broker has caught up. Transitioning from STARTING to RECOVERY. (kafka.server.BrokerLifecycleManager)\n[2023-07-14 17:56:04,750] INFO [BrokerServer id=1] Finished waiting for the controller to acknowledge that we are caught up (kafka.server.BrokerServer)\n[2023-07-14 17:56:04,750] INFO [BrokerServer id=1] Waiting for the initial broker metadata update to be published (kafka.server.BrokerServer)\n[2023-07-14 17:56:04,750] INFO [BrokerServer id=1] Finished waiting for the initial broker metadata update to be published (kafka.server.BrokerServer)\n[2023-07-14 17:56:04,752] INFO KafkaConfig values: \n\tadvertised.listeners = PLAINTEXT:\/\/localhost:9092\n\talter.config.policy.class.name = null\n\talter.log.dirs.replication.quota.window.num = 11\n\talter.log.dirs.replication.quota.window.size.seconds = 1\n\tauthorizer.class.name = \n\tauto.create.topics.enable = true\n\tauto.include.jmx.reporter = true\n\tauto.leader.rebalance.enable = true\n\tbackground.threads = 10\n\tbroker.heartbeat.interval.ms = 2000\n\tbroker.id = 1\n\tbroker.id.generation.enable = true\n\tbroker.rack = null\n\tbroker.session.timeout.ms = 9000\n\tclient.quota.callback.class = null\n\tcompression.type = producer\n\tconnection.failed.authentication.delay.ms = 100\n\tconnections.max.idle.ms = 600000\n\tconnections.max.reauth.ms = 0\n\tcontrol.plane.listener.name = null\n\tcontrolled.shutdown.enable = true\n\tcontrolled.shutdown.max.retries = 3\n\tcontrolled.shutdown.retry.backoff.ms = 5000\n\tcontroller.listener.names = CONTROLLER\n\tcontroller.quorum.append.linger.ms = 25\n\tcontroller.quorum.election.backoff.max.ms = 1000\n\tcontroller.quorum.election.timeout.ms = 1000\n\tcontroller.quorum.fetch.timeout.ms = 2000\n\tcontroller.quorum.request.timeout.ms = 2000\n\tcontroller.quorum.retry.backoff.ms = 20\n\tcontroller.quorum.voters = [1@localhost:9093]\n\tcontroller.quota.window.num = 11\n\tcontroller.quota.window.size.seconds = 1\n\tcontroller.socket.timeout.ms = 30000\n\tcreate.topic.policy.class.name = null\n\tdefault.replication.factor = 1\n\tdelegation.token.expiry.check.interval.ms = 3600000\n\tdelegation.token.expiry.time.ms = 86400000\n\tdelegation.token.master.key = null\n\tdelegation.token.max.lifetime.ms = 604800000\n\tdelegation.token.secret.key = null\n\tdelete.records.purgatory.purge.interval.requests = 1\n\tdelete.topic.enable = true\n\tearly.start.listeners = null\n\tfetch.max.bytes = 57671680\n\tfetch.purgatory.purge.interval.requests = 1000\n\tgroup.consumer.assignors = []\n\tgroup.consumer.heartbeat.interval.ms = 5000\n\tgroup.consumer.max.heartbeat.interval.ms = 15000\n\tgroup.consumer.max.session.timeout.ms = 60000\n\tgroup.consumer.max.size = 2147483647\n\tgroup.consumer.min.heartbeat.interval.ms = 5000\n\tgroup.consumer.min.session.timeout.ms = 45000\n\tgroup.consumer.session.timeout.ms = 45000\n\tgroup.coordinator.new.enable = false\n\tgroup.coordinator.threads = 1\n\tgroup.initial.rebalance.delay.ms = 3000\n\tgroup.max.session.timeout.ms = 1800000\n\tgroup.max.size = 2147483647\n\tgroup.min.session.timeout.ms = 6000\n\tinitial.broker.registration.timeout.ms = 60000\n\tinter.broker.listener.name = PLAINTEXT\n\tinter.broker.protocol.version = 3.5-IV2\n\tkafka.metrics.polling.interval.secs = 10\n\tkafka.metrics.reporters = []\n\tleader.imbalance.check.interval.seconds = 300\n\tleader.imbalance.per.broker.percentage = 10\n\tlistener.security.protocol.map = CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL\n\tlisteners = PLAINTEXT:\/\/:9092,CONTROLLER:\/\/:9093\n\tlog.cleaner.backoff.ms = 15000\n\tlog.cleaner.dedupe.buffer.size = 134217728\n\tlog.cleaner.delete.retention.ms = 86400000\n\tlog.cleaner.enable = true\n\tlog.cleaner.io.buffer.load.factor = 0.9\n\tlog.cleaner.io.buffer.size = 524288\n\tlog.cleaner.io.max.bytes.per.second = 1.7976931348623157E308\n\tlog.cleaner.max.compaction.lag.ms = 9223372036854775807\n\tlog.cleaner.min.cleanable.ratio = 0.5\n\tlog.cleaner.min.compaction.lag.ms = 0\n\tlog.cleaner.threads = 1\n\tlog.cleanup.policy = [delete]\n\tlog.dir = \/tmp\/kafka-logs\n\tlog.dirs = \/opt\/kafka\/logs\n\tlog.flush.interval.messages = 9223372036854775807\n\tlog.flush.interval.ms = null\n\tlog.flush.offset.checkpoint.interval.ms = 60000\n\tlog.flush.scheduler.interval.ms = 9223372036854775807\n\tlog.flush.start.offset.checkpoint.interval.ms = 60000\n\tlog.index.interval.bytes = 4096\n\tlog.index.size.max.bytes = 10485760\n\tlog.message.downconversion.enable = true\n\tlog.message.format.version = 3.0-IV1\n\tlog.message.timestamp.difference.max.ms = 9223372036854775807\n\tlog.message.timestamp.type = CreateTime\n\tlog.preallocate = false\n\tlog.retention.bytes = -1\n\tlog.retention.check.interval.ms = 300000\n\tlog.retention.hours = 168\n\tlog.retention.minutes = null\n\tlog.retention.ms = null\n\tlog.roll.hours = 168\n\tlog.roll.jitter.hours = 0\n\tlog.roll.jitter.ms = null\n\tlog.roll.ms = null\n\tlog.segment.bytes = 1073741824\n\tlog.segment.delete.delay.ms = 60000\n\tmax.connection.creation.rate = 2147483647\n\tmax.connections = 2147483647\n\tmax.connections.per.ip = 2147483647\n\tmax.connections.per.ip.overrides = \n\tmax.incremental.fetch.session.cache.slots = 1000\n\tmessage.max.bytes = 1048588\n\tmetadata.log.dir = null\n\tmetadata.log.max.record.bytes.between.snapshots = 20971520\n\tmetadata.log.max.snapshot.interval.ms = 3600000\n\tmetadata.log.segment.bytes = 1073741824\n\tmetadata.log.segment.min.bytes = 8388608\n\tmetadata.log.segment.ms = 604800000\n\tmetadata.max.idle.interval.ms = 500\n\tmetadata.max.retention.bytes = 104857600\n\tmetadata.max.retention.ms = 604800000\n\tmetric.reporters = []\n\tmetrics.num.samples = 2\n\tmetrics.recording.level = INFO\n\tmetrics.sample.window.ms = 30000\n\tmin.insync.replicas = 1\n\tnode.id = 1\n\tnum.io.threads = 8\n\tnum.network.threads = 3\n\tnum.partitions = 1\n\tnum.recovery.threads.per.data.dir = 1\n\tnum.replica.alter.log.dirs.threads = null\n\tnum.replica.fetchers = 1\n\toffset.metadata.max.bytes = 4096\n\toffsets.commit.required.acks = -1\n\toffsets.commit.timeout.ms = 5000\n\toffsets.load.buffer.size = 5242880\n\toffsets.retention.check.interval.ms = 600000\n\toffsets.retention.minutes = 10080\n\toffsets.topic.compression.codec = 0\n\toffsets.topic.num.partitions = 50\n\toffsets.topic.replication.factor = 1\n\toffsets.topic.segment.bytes = 104857600\n\tpassword.encoder.cipher.algorithm = AES\/CBC\/PKCS5Padding\n\tpassword.encoder.iterations = 4096\n\tpassword.encoder.key.length = 128\n\tpassword.encoder.keyfactory.algorithm = null\n\tpassword.encoder.old.secret = null\n\tpassword.encoder.secret = null\n\tprincipal.builder.class = class org.apache.kafka.common.security.authenticator.DefaultKafkaPrincipalBuilder\n\tprocess.roles = [broker, controller]\n\tproducer.id.expiration.check.interval.ms = 600000\n\tproducer.id.expiration.ms = 86400000\n\tproducer.purgatory.purge.interval.requests = 1000\n\tqueued.max.request.bytes = -1\n\tqueued.max.requests = 500\n\tquota.window.num = 11\n\tquota.window.size.seconds = 1\n\tremote.log.index.file.cache.total.size.bytes = 1073741824\n\tremote.log.manager.task.interval.ms = 30000\n\tremote.log.manager.task.retry.backoff.max.ms = 30000\n\tremote.log.manager.task.retry.backoff.ms = 500\n\tremote.log.manager.task.retry.jitter = 0.2\n\tremote.log.manager.thread.pool.size = 10\n\tremote.log.metadata.manager.class.name = null\n\tremote.log.metadata.manager.class.path = null\n\tremote.log.metadata.manager.impl.prefix = null\n\tremote.log.metadata.manager.listener.name = null\n\tremote.log.reader.max.pending.tasks = 100\n\tremote.log.reader.threads = 10\n\tremote.log.storage.manager.class.name = null\n\tremote.log.storage.manager.class.path = null\n\tremote.log.storage.manager.impl.prefix = null\n\tremote.log.storage.system.enable = false\n\treplica.fetch.backoff.ms = 1000\n\treplica.fetch.max.bytes = 1048576\n\treplica.fetch.min.bytes = 1\n\treplica.fetch.response.max.bytes = 10485760\n\treplica.fetch.wait.max.ms = 500\n\treplica.high.watermark.checkpoint.interval.ms = 5000\n\treplica.lag.time.max.ms = 30000\n\treplica.selector.class = null\n\treplica.socket.receive.buffer.bytes = 65536\n\treplica.socket.timeout.ms = 30000\n\treplication.quota.window.num = 11\n\treplication.quota.window.size.seconds = 1\n\trequest.timeout.ms = 30000\n\treserved.broker.max.id = 1000\n\tsasl.client.callback.handler.class = null\n\tsasl.enabled.mechanisms = [GSSAPI]\n\tsasl.jaas.config = null\n\tsasl.kerberos.kinit.cmd = \/usr\/bin\/kinit\n\tsasl.kerberos.min.time.before.relogin = 60000\n\tsasl.kerberos.principal.to.local.rules = [DEFAULT]\n\tsasl.kerberos.service.name = null\n\tsasl.kerberos.ticket.renew.jitter = 0.05\n\tsasl.kerberos.ticket.renew.window.factor = 0.8\n\tsasl.login.callback.handler.class = null\n\tsasl.login.class = null\n\tsasl.login.connect.timeout.ms = null\n\tsasl.login.read.timeout.ms = null\n\tsasl.login.refresh.buffer.seconds = 300\n\tsasl.login.refresh.min.period.seconds = 60\n\tsasl.login.refresh.window.factor = 0.8\n\tsasl.login.refresh.window.jitter = 0.05\n\tsasl.login.retry.backoff.max.ms = 10000\n\tsasl.login.retry.backoff.ms = 100\n\tsasl.mechanism.controller.protocol = GSSAPI\n\tsasl.mechanism.inter.broker.protocol = GSSAPI\n\tsasl.oauthbearer.clock.skew.seconds = 30\n\tsasl.oauthbearer.expected.audience = null\n\tsasl.oauthbearer.expected.issuer = null\n\tsasl.oauthbearer.jwks.endpoint.refresh.ms = 3600000\n\tsasl.oauthbearer.jwks.endpoint.retry.backoff.max.ms = 10000\n\tsasl.oauthbearer.jwks.endpoint.retry.backoff.ms = 100\n\tsasl.oauthbearer.jwks.endpoint.url = null\n\tsasl.oauthbearer.scope.claim.name = scope\n\tsasl.oauthbearer.sub.claim.name = sub\n\tsasl.oauthbearer.token.endpoint.url = null\n\tsasl.server.callback.handler.class = null\n\tsasl.server.max.receive.size = 524288\n\tsecurity.inter.broker.protocol = PLAINTEXT\n\tsecurity.providers = null\n\tserver.max.startup.time.ms = 9223372036854775807\n\tsocket.connection.setup.timeout.max.ms = 30000\n\tsocket.connection.setup.timeout.ms = 10000\n\tsocket.listen.backlog.size = 50\n\tsocket.receive.buffer.bytes = 102400\n\tsocket.request.max.bytes = 104857600\n\tsocket.send.buffer.bytes = 102400\n\tssl.cipher.suites = []\n\tssl.client.auth = none\n\tssl.enabled.protocols = [TLSv1.2, TLSv1.3]\n\tssl.endpoint.identification.algorithm = https\n\tssl.engine.factory.class = null\n\tssl.key.password = null\n\tssl.keymanager.algorithm = SunX509\n\tssl.keystore.certificate.chain = null\n\tssl.keystore.key = null\n\tssl.keystore.location = null\n\tssl.keystore.password = null\n\tssl.keystore.type = JKS\n\tssl.principal.mapping.rules = DEFAULT\n\tssl.protocol = TLSv1.3\n\tssl.provider = null\n\tssl.secure.random.implementation = null\n\tssl.trustmanager.algorithm = PKIX\n\tssl.truststore.certificates = null\n\tssl.truststore.location = null\n\tssl.truststore.password = null\n\tssl.truststore.type = JKS\n\ttransaction.abort.timed.out.transaction.cleanup.interval.ms = 10000\n\ttransaction.max.timeout.ms = 900000\n\ttransaction.remove.expired.transaction.cleanup.interval.ms = 3600000\n\ttransaction.state.log.load.buffer.size = 5242880\n\ttransaction.state.log.min.isr = 1\n\ttransaction.state.log.num.partitions = 50\n\ttransaction.state.log.replication.factor = 1\n\ttransaction.state.log.segment.bytes = 104857600\n\ttransactional.id.expiration.ms = 604800000\n\tunclean.leader.election.enable = false\n\tunstable.api.versions.enable = false\n\tzookeeper.clientCnxnSocket = null\n\tzookeeper.connect = null\n\tzookeeper.connection.timeout.ms = null\n\tzookeeper.max.in.flight.requests = 10\n\tzookeeper.metadata.migration.enable = false\n\tzookeeper.session.timeout.ms = 18000\n\tzookeeper.set.acl = false\n\tzookeeper.ssl.cipher.suites = null\n\tzookeeper.ssl.client.enable = false\n\tzookeeper.ssl.crl.enable = false\n\tzookeeper.ssl.enabled.protocols = null\n\tzookeeper.ssl.endpoint.identification.algorithm = HTTPS\n\tzookeeper.ssl.keystore.location = null\n\tzookeeper.ssl.keystore.password = null\n\tzookeeper.ssl.keystore.type = null\n\tzookeeper.ssl.ocsp.enable = false\n\tzookeeper.ssl.protocol = TLSv1.2\n\tzookeeper.ssl.truststore.location = null\n\tzookeeper.ssl.truststore.password = null\n\tzookeeper.ssl.truststore.type = null\n (kafka.server.KafkaConfig)\n[2023-07-14 17:56:04,757] INFO [BrokerServer id=1] Waiting for the broker to be unfenced (kafka.server.BrokerServer)\n[2023-07-14 17:56:04,791] INFO [BrokerLifecycleManager id=1] The broker has been unfenced. Transitioning from RECOVERY to RUNNING. (kafka.server.BrokerLifecycleManager)\n[2023-07-14 17:56:04,792] INFO [BrokerServer id=1] Finished waiting for the broker to be unfenced (kafka.server.BrokerServer)\n[2023-07-14 17:56:04,792] INFO [SocketServer listenerType=BROKER, nodeId=1] Enabling request processing. (kafka.network.SocketServer)\n[2023-07-14 17:56:04,792] INFO Awaiting socket connections on 0.0.0.0:9092. (kafka.network.DataPlaneAcceptor)\n[2023-07-14 17:56:04,793] INFO [BrokerServer id=1] Waiting for all of the authorizer futures to be completed (kafka.server.BrokerServer)\n[2023-07-14 17:56:04,793] INFO [BrokerServer id=1] Finished waiting for all of the authorizer futures to be completed (kafka.server.BrokerServer)\n[2023-07-14 17:56:04,793] INFO [BrokerServer id=1] Waiting for all of the SocketServer Acceptors to be started (kafka.server.BrokerServer)\n[2023-07-14 17:56:04,794] INFO [BrokerServer id=1] Finished waiting for all of the SocketServer Acceptors to be started (kafka.server.BrokerServer)\n[2023-07-14 17:56:04,794] INFO [BrokerServer id=1] Transition from STARTING to STARTED (kafka.server.BrokerServer)\n[2023-07-14 17:56:04,794] INFO Kafka version: 3.5.0 (org.apache.kafka.common.utils.AppInfoParser)\n[2023-07-14 17:56:04,795] INFO Kafka commitId: c97b88d5db4de28d (org.apache.kafka.common.utils.AppInfoParser)\n[2023-07-14 17:56:04,795] INFO Kafka startTimeMs: 1689371764794 (org.apache.kafka.common.utils.AppInfoParser)\n[2023-07-14 17:56:04,796] INFO [KafkaRaftServer nodeId=1] Kafka Server started (kafka.server.KafkaRaftServer)\n<\/code><\/pre>\n\n\n\nYou can open another terminal and check the ports for Kafka control plane (9093\/tcp) and client (9092\/tcp).<\/p>\n\n\n\n
ss -altnp | grep :90<\/code><\/pre>\n\n\n\n\nLISTEN 0 50 *:9092 *:* users:((\"java\",pid=5127,fd=151)) \nLISTEN 0 50 *:9093 *:* users:((\"java\",pid=5127,fd=131))\n<\/code><\/pre>\n\n\n\nPress Ctrl+c<\/strong> to stop the foreground process or simply execute this command on a seperate terminal;<\/p>\n\n\n\n\/opt\/kafka\/bin\/kafka-server-stop.sh \/opt\/kafka\/config\/kraft\/server.properties<\/code><\/pre>\n\n\n\nOr just;<\/p>\n\n\n\n
\/opt\/kafka\/bin\/kafka-server-stop.sh<\/code><\/pre>\n\n\n\nRunning Kafka Broker as systemd Service<\/h4>\n\n\n\n
You can create Kafka broker systemd service to easily manage the process.<\/p>\n\n\n\n
vim \/etc\/systemd\/system\/kafka.service<\/code><\/pre>\n\n\n\n\n[Unit]\nDescription=Apache Kafka\nRequires=network.target\nAfter=network.target\n\n[Service]\nType=simple\nExecStart=\/opt\/kafka\/bin\/kafka-server-start.sh \/opt\/kafka\/config\/kraft\/server.properties\nExecStop=\/opt\/kafka\/bin\/kafka-server-stop.sh\nRestart=on-failure\n\n[Install]\nWantedBy=default.target\n<\/code><\/pre>\n\n\n\nSave and exit the file.<\/p>\n\n\n\n
Reload systemd;<\/p>\n\n\n\n
systemctl daemon-reload<\/code><\/pre>\n\n\n\nStart Kafka broker service;<\/p>\n\n\n\n
systemctl start kafka<\/code><\/pre>\n\n\n\n\n\u25cf kafka.service - Apache Kafka\n Loaded: loaded (\/etc\/systemd\/system\/kafka.service; disabled; preset: enabled)\n Active: active (running) since Fri 2023-07-14 18:20:10 EDT; 5s ago\n Main PID: 7812 (java)\n Tasks: 90 (limit: 4642)\n Memory: 324.1M\n CPU: 4.520s\n CGroup: \/system.slice\/kafka.service\n \u2514\u25007812 java -Xmx1G -Xms1G -server -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupancyPercent=35 -XX:+ExplicitGCInvokesConcurrent -XX:MaxInlineLevel=15 -Djava.awt.headless=true \"-Xlog:g>\n\nJul 14 18:20:13 debian kafka-server-start.sh[7812]: [2023-07-14 18:20:13,083] INFO Awaiting socket connections on 0.0.0.0:9092. (kafka.network.DataPlaneAcceptor)\nJul 14 18:20:13 debian kafka-server-start.sh[7812]: [2023-07-14 18:20:13,093] INFO [BrokerServer id=1] Waiting for all of the authorizer futures to be completed (kafka.server.BrokerServer)\nJul 14 18:20:13 debian kafka-server-start.sh[7812]: [2023-07-14 18:20:13,093] INFO [BrokerServer id=1] Finished waiting for all of the authorizer futures to be completed (kafka.server.BrokerServer)\nJul 14 18:20:13 debian kafka-server-start.sh[7812]: [2023-07-14 18:20:13,093] INFO [BrokerServer id=1] Waiting for all of the SocketServer Acceptors to be started (kafka.server.BrokerServer)\nJul 14 18:20:13 debian kafka-server-start.sh[7812]: [2023-07-14 18:20:13,093] INFO [BrokerServer id=1] Finished waiting for all of the SocketServer Acceptors to be started (kafka.server.BrokerServer)\nJul 14 18:20:13 debian kafka-server-start.sh[7812]: [2023-07-14 18:20:13,093] INFO [BrokerServer id=1] Transition from STARTING to STARTED (kafka.server.BrokerServer)\nJul 14 18:20:13 debian kafka-server-start.sh[7812]: [2023-07-14 18:20:13,093] INFO Kafka version: 3.5.0 (org.apache.kafka.common.utils.AppInfoParser)\nJul 14 18:20:13 debian kafka-server-start.sh[7812]: [2023-07-14 18:20:13,094] INFO Kafka commitId: c97b88d5db4de28d (org.apache.kafka.common.utils.AppInfoParser)\nJul 14 18:20:13 debian kafka-server-start.sh[7812]: [2023-07-14 18:20:13,094] INFO Kafka startTimeMs: 1689373213093 (org.apache.kafka.common.utils.AppInfoParser)\nJul 14 18:20:13 debian kafka-server-start.sh[7812]: [2023-07-14 18:20:13,094] INFO [KafkaRaftServer nodeId=1] Kafka Server started (kafka.server.KafkaRaftServer)\n<\/code><\/pre>\n\n\n\nEnable Kafka broker service to run on system boot;<\/p>\n\n\n\n
systemctl enable kafka<\/code><\/pre>\n\n\n\nYou can view logs using systemd journald journalctl command;<\/p>\n\n\n\n
journalctl -f -u kafka<\/code><\/pre>\n\n\n\n\nJul 14 18:20:13 debian kafka-server-start.sh[7812]: [2023-07-14 18:20:13,083] INFO Awaiting socket connections on 0.0.0.0:9092. (kafka.network.DataPlaneAcceptor)\nJul 14 18:20:13 debian kafka-server-start.sh[7812]: [2023-07-14 18:20:13,093] INFO [BrokerServer id=1] Waiting for all of the authorizer futures to be completed (kafka.server.BrokerServer)\nJul 14 18:20:13 debian kafka-server-start.sh[7812]: [2023-07-14 18:20:13,093] INFO [BrokerServer id=1] Finished waiting for all of the authorizer futures to be completed (kafka.server.BrokerServer)\nJul 14 18:20:13 debian kafka-server-start.sh[7812]: [2023-07-14 18:20:13,093] INFO [BrokerServer id=1] Waiting for all of the SocketServer Acceptors to be started (kafka.server.BrokerServer)\nJul 14 18:20:13 debian kafka-server-start.sh[7812]: [2023-07-14 18:20:13,093] INFO [BrokerServer id=1] Finished waiting for all of the SocketServer Acceptors to be started (kafka.server.BrokerServer)\nJul 14 18:20:13 debian kafka-server-start.sh[7812]: [2023-07-14 18:20:13,093] INFO [BrokerServer id=1] Transition from STARTING to STARTED (kafka.server.BrokerServer)\nJul 14 18:20:13 debian kafka-server-start.sh[7812]: [2023-07-14 18:20:13,093] INFO Kafka version: 3.5.0 (org.apache.kafka.common.utils.AppInfoParser)\nJul 14 18:20:13 debian kafka-server-start.sh[7812]: [2023-07-14 18:20:13,094] INFO Kafka commitId: c97b88d5db4de28d (org.apache.kafka.common.utils.AppInfoParser)\nJul 14 18:20:13 debian kafka-server-start.sh[7812]: [2023-07-14 18:20:13,094] INFO Kafka startTimeMs: 1689373213093 (org.apache.kafka.common.utils.AppInfoParser)\nJul 14 18:20:13 debian kafka-server-start.sh[7812]: [2023-07-14 18:20:13,094] INFO [KafkaRaftServer nodeId=1] Kafka Server started (kafka.server.KafkaRaftServer)\n<\/code><\/pre>\n\n\n\nCreate topics, Send and Receive messages on Kafka Topic<\/h3>\n\n\n\n
You can now configure your producers to publish records (messages) to Kafka topics and consumers to subscribe to one or more topics and read records from them.<\/p>\n\n\n\n
Manually Create a Topic<\/h4>\n\n\n\n
For example, let’s create a test topic on the Kafka server\/broker;<\/p>\n\n\n\n
\/opt\/kafka\/bin\/kafka-topics.sh --create --topic kafka-topic-test --bootstrap-server localhost:9092<\/code><\/pre>\n\n\n\nList Kafka Topics<\/h4>\n\n\n\n
You can list topics using the command;<\/p>\n\n\n\n
\/opt\/kafka\/bin\/kafka-topics.sh --list --bootstrap-server localhost:9092<\/code><\/pre>\n\n\n\nExample output;<\/p>\n\n\n\n
kafka-topic-test<\/code><\/pre>\n\n\n\nManually write (Produce) and read (Consume) data to the topic on Kafka server<\/h4>\n\n\n\n
To verify that you can write and read data from Kafka topics, let’s write\/produce to out test topic above;<\/p>\n\n\n\n
\/opt\/kafka\/bin\/kafka-console-producer.sh --bootstrap-server localhost:9092 \\\n--topic kafka-topic-test<\/code><\/pre>\n\n\n\nWhen it runs, you will get such a prompt;<\/p>\n\n\n\n
><\/code><\/pre>\n\n\n\nType your message and press ENTER;<\/p>\n\n\n\n
>Hello Kafka, this is a test message\n><\/code><\/pre>\n\n\n\nYou can cancel the command by using ctrl+c<\/strong> and consume\/read data from this topic.<\/p>\n\n\n\nYou can consume message in realtime if the topic is being written actively;<\/p>\n\n\n\n
\/opt\/kafka\/bin\/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic kafka-topic-test<\/code><\/pre>\n\n\n\nBut you can also read all the messages from those that have already written to those currently being written;<\/p>\n\n\n\n
\/opt\/kafka\/bin\/kafka-console-consumer.sh --bootstrap-server localhost:9092 \\\n--topic kafka-topic-test --from-beginning<\/code><\/pre>\n\n\n\nYou should see our message above;<\/p>\n\n\n\n
\/opt\/kafka\/bin\/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic kafka-topic-test --from-beginning\nHello Kafka, this is a test message\n<\/strong><\/code><\/pre>\n\n\n\nDelete Kafka Topics<\/h4>\n\n\n\n
So, how does on delete Kafka topics?<\/p>\n\n\n\n
To delete one by one;<\/p>\n\n\n\n
\/opt\/kafka\/bin\/kafka-topics.sh --bootstrap-server localhost:9092 --delete --topic <name-of-topic><\/code><\/pre>\n\n\n\nTo delete all Kafka topics;<\/p>\n\n\n\n
for i in `\/opt\/kafka\/bin\/kafka-topics.sh --list --bootstrap-server localhost:9092`;do \/opt\/kafka\/bin\/kafka-topics.sh --bootstrap-server localhost:9092 --delete --topic $i; done<\/code><\/pre>\n\n\n\nSetup Three Node Cluster<\/h3>\n\n\n\n
You can setup a cluster by following the guide below;<\/p>\n\n\n\n
Setup a Three-Node Kafka KRaft Cluster for Scalable Data Streaming<\/a><\/p>\n\n\n\nManage Kafka Cluster from UI<\/h3>\n\n\n\n
You can manager your cluster using Kadeck;<\/p>\n\n\n\n
Install Kadeck Apache Kafka UI Tool on Debian\/Ubuntu<\/a><\/p>\n\n\n\nThat closes our guide on how to install Apache Kafka on Debian 12<\/p>\n\n\n\n
Read more<\/a> on the documentation page.<\/p>\n\n\n\nMore Tutorials<\/h3>\n\n\n\n
Install Logstash 8 on Ubuntu\/Debian<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"This guide provides a step by step tutorial on how to easily install Apache Kafka on Debian 12. Apache Kafka is open-source distributed event streaming<\/p>\n","protected":false},"author":10,"featured_media":17873,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[121,72],"tags":[7053,7052,7056,7054,7055],"class_list":["post-17851","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","category-monitoring","tag-debian-12-kafka","tag-install-apache-kafka-on-debian-12","tag-install-kafka-debian","tag-kafka-with-kraft-debian-12","tag-kafka-without-zookeeper","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50","resize-featured-image"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/17851"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=17851"}],"version-history":[{"count":19,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/17851\/revisions"}],"predecessor-version":[{"id":20810,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/17851\/revisions\/20810"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/17873"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=17851"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=17851"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=17851"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}