Broker configuration basics in Kafka - Commands & Configuration
broker.id=1 listeners=PLAINTEXT://:9092 log.dirs=/tmp/kafka-logs num.network.threads=3 num.io.threads=8 socket.send.buffer.bytes=102400 socket.receive.buffer.bytes=102400 socket.request.max.bytes=104857600 log.retention.hours=168 log.segment.bytes=1073741824 log.retention.check.interval.ms=300000 zookeeper.connect=localhost:2181
broker.id: Unique ID for this broker in the cluster.
listeners: Network address and port where the broker listens for client connections.
log.dirs: Directory where Kafka stores message logs.
num.network.threads and num.io.threads: Threads for handling network and disk I/O.
socket.*: Network buffer sizes for efficient data transfer.
log.retention.hours: How long to keep logs before deletion.
log.segment.bytes: Size of log segments before rolling over.
log.retention.check.interval.ms: How often Kafka checks for expired logs.
zookeeper.connect: Address of ZooKeeper managing the cluster metadata.
kafka-server-start.sh server.properties
netstat -tuln | grep 9092
ls /tmp/kafka-logsIf you remember nothing else from this pattern, remember: the broker configuration file controls how the Kafka broker connects, stores data, and communicates, so setting it correctly is essential for a healthy Kafka cluster.
Practice
Solution
Step 1: Understand the role of broker configuration
Broker configuration files contain settings that control how Kafka brokers behave, such as storage and network handling.Step 2: Identify the correct description
Only To set key=value pairs that control broker behavior correctly describes the purpose as setting key=value pairs for broker behavior.Final Answer:
To set key=value pairs that control broker behavior -> Option AQuick Check:
Broker config = key=value pairs [OK]
- Confusing broker config with client code
- Thinking config stores user data
- Mixing OS settings with Kafka broker config
Solution
Step 1: Recall Kafka config syntax
Kafka uses key=value pairs with dots to separate words, like broker.id=1.Step 2: Compare options
Only broker.id=1 uses the correct dot notation and equal sign syntax.Final Answer:
broker.id=1 -> Option CQuick Check:
Correct syntax uses dot and equal sign [OK]
- Using underscores instead of dots
- Using colon instead of equal sign
- CamelCase keys instead of lowercase with dots
log.dirs=/tmp/kafka-logs num.network.threads=3 num.io.threads=8
What does
num.network.threads=3 control?Solution
Step 1: Understand the meaning of num.network.threads
This setting controls how many threads the broker uses to handle network requests from clients.Step 2: Match options with setting
Number of threads handling network requests correctly states it controls threads handling network requests; others describe unrelated functions.Final Answer:
Number of threads handling network requests -> Option DQuick Check:
num.network.threads = network threads count [OK]
- Confusing network threads with IO threads
- Thinking it controls log writing threads
- Mixing client connections with message processing
log.retention.hours 168
What is wrong with this line?
Solution
Step 1: Check syntax for key-value pairs
Kafka config requires an equal sign (=) between key and value, not just a space.Step 2: Identify the error in the line
The line uses a space instead of '=', so it is a syntax error.Final Answer:
Missing equal sign between key and value -> Option AQuick Check:
Config lines need key=value format [OK]
- Assuming space works as separator
- Confusing retention hours with milliseconds
- Thinking the key name is wrong
/data/kafka1 and /data/kafka2. Which is the correct way to set log.dirs in the broker config?Solution
Step 1: Understand log.dirs format
Kafka expects multiple directories separated by commas without spaces or brackets.Step 2: Evaluate each option
log.dirs=/data/kafka1,/data/kafka2 uses commas correctly; B uses semicolon (wrong), C uses space (wrong), D uses brackets (wrong).Final Answer:
log.dirs=/data/kafka1,/data/kafka2 -> Option BQuick Check:
Multiple dirs separated by commas [OK]
- Using semicolons or spaces instead of commas
- Adding brackets around paths
- Including spaces between paths
Ready to prove it?
Pass the test and this pattern moves unknown
