config.properties
server.properties
server.1=172.28.92.39:2888:3888
server.2=172.28.92.37:2888:3888
server.3=172.28.92.38:2888:3888
server
start
./bin/zookeeper-server-start.sh -daemon ./config/zookeeper.properties
stop
./bin/kafka-server-start.sh -daemon ./config/server.properties
分区
修改分区
./bin/kafka-topics.sh --zookeeper 127.0.0.1:2181 --alter --partitions 3 --topic monitor-log
消费
手动消费
./bin/kafka-console-consumer.sh --bootstrap-server 172.28.92.37:9092,172.28.92.38:9092,172.28.92.39:9092 --topic monitorlog --from-beginning
./bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic log.test
./bin/kafka-console-consumer.sh --bootstrap-server 172.20.61.203:6667,172.20.61.204:6667,172.20.61.205:6667 --topic monitor-log
查看group消费情况
./bin/kafka-consumer-groups.sh --bootstrap-server 172.28.92.39:9092 --describe --group 1
./bin/kafka-consumer-groups.sh --zookeeper 127.0.0.1:2181 --describe --group 1
topic
create
bin/kafka-topics.sh --create --bootstrap-server 172.28.92.37:9092 --replication-factor 1 --partitions 1 --topic monitor-alerts
delete
bin/kafka-topics.sh --bootstrap-server 172.28.92.37:9092 --delete --topic monitorlog
list
./bin/kafka-topics.sh --zookeeper localhost:2181 --list
describe
./bin/kafka-topics.sh --zookeeper 127.0.0.1:2181 --describe --topic monitor-log
delete topic
./bin/kafka-topics.sh --zookeeper 127.0.0.1:2181 --delete --topic xxxxx
config
查看所有topic的config
./bin/kafka-configs.sh --zookeeper 127.0.0.1:2181 --describe --entity-type topics
查看配置
./bin/kafka-configs.sh --zookeeper localhost:2181 --describe --entity-type topics --entity-name monitor-alerts
设置retention
./bin/kafka-configs.sh --zookeeper localhost:2181 --alter --entity-type topics --entity-name monitor-alerts --add-config retention.ms=86400000
DumpLogSegments
~/kafka_2.12-2.3.0/bin/kafka-run-class.sh kafka.tools.DumpLogSegments --files=/data/kafka/logs/monitor-log-1/00000000000336375351.log --print-data-log > 00000000000336375351.log
~/kafka_2.12-2.3.0/bin/kafka-run-class.sh kafka.tools.DumpLogSegments --files=/data/kafka/logs/monitor-log-1/00000000000336375351.index --print-data-log > 00000000000336375351.index
~/kafka_2.12-2.3.0/bin/kafka-run-class.sh kafka.tools.DumpLogSegments --files=/data/kafka/logs/monitor-log-1/00000000000336375351.timeindex --print-data-log > 00000000000336375351.timeindex
consumer
bin/kafka-console-consumer.sh --bootstrap-server 172.28.92.37:9092,172.28.92.38:9092,172.28.92.39:9092 --topic monitor-alerts --from-beginning
offset
bin/kafka-run-class.sh kafka.tools.GetOffsetShell --topic hive-mdatabase-hostsltable --time -1 --broker-list 172.20.61.203:6667 --partitions 0