kafka 问题

Last updated on May 14, 2026 am

🧙 Questions

☄️ Ideas

启动kafka内存不足
sudo vim /opt/kafka/bin/kafka-server-start.sh
export KAFKA_HEAP_OPTS="-Xmx256M -Xms128M"
kafka中断
Caused by: org.apache.kafka.common.errors.RecordTooLargeException: The message is 1649687 bytes when serialized which is larger than 1048576, which is the value of the max.request.size configuration.
vim server.properties
# 默认33554432
buffer.memory=200000000 

# 默认1048576
max.request.size=200000000  

# 默认值1048588
message.max.bytes=200000000 

# 默认值1048576
max.partition.fetch.bytes=200000000 
replica.fetch.max.bytes=32768000 

# 拉取数据的最大等待时间(默认 500ms)
fetch.wait.max.ms=10000

# 消费者 session 超时时间(默认 45s)
session.timeout.ms=60000

# 请求超时时间(默认 30s)
request.timeout.ms=60000
kafka存储爆了

/data/appdata/kafka/battery_basic_msg-0 某个topic爆了

# 设置保留3天
bin/kafka-configs.sh --bootstrap-server localhost:9092 \
  --entity-type topics --entity-name battery_basic_msg \
  --alter --add-config 'retention.ms=259200000'

# 查看配置是否生效
bin/kafka-configs.sh --bootstrap-server localhost:9092 \
  --entity-type topics --entity-name battery_basic_msg \
  --describe

# 改成500MB大小,设置小文件等待5分钟,5分钟后自动清理文件,前提kafka是活的
bin/kafka-configs.sh --bootstrap-server localhost:9092 \
  --entity-type topics --entity-name battery_basic_msg \
  --alter --add-config 'segment.bytes=536870912' 

# 查看配置是否生效
bin/kafka-configs.sh --bootstrap-server localhost:9092 \
  --entity-type topics --entity-name battery_basic_msg \
  --describe

# 删除该配置,恢复默认值1GB
bin/kafka-configs.sh --bootstrap-server localhost:9092 \
  --entity-type topics --entity-name battery_basic_msg \
  --alter --delete-config segment.bytes

kafka 问题
https://ispong.isxcode.com/hadoop/kafka/kafka 问题/
Author
ispong
Posted on
June 30, 2022
Licensed under