1, cluster management
Reception starts broker
bin/kafka-server-start.sh <path>/server.properties
Ctrl + C Close
Start broker background
bin/kafka-server-start.sh -daemon <path>/server.properties
Close broker
bin/kafka-server-stop.sh
2, Topic management
Creating topic
bin/kafka-topics.sh --create --zookeeper localhost:2181 --partitions 3 --replication-factor 3 --topic topicname
Delete topic
bin/kafka-topics.sh --delete --zookeeper localhost:2181 --topic topicname
Queries topic list
bin/kafka-topics.sh --zookeeper localhost:2181 --list
Queries topic details
bin/kafka-topics.sh --zookeeper localhost:2181 --describe --topic topicname
Modify topic
bin/kafka-topics.sh --alter --zookeeper localhost:2181 --partitions 6 --topic topicname
3, Consumer-Groups Management
Queries consumer group
bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --list
Queries consumer group details
bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group groupname
Reset consumer group displacement
最早处
bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --group groupname --reset-offsets --all-topics --to-earliest --execute
最新处
bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --group groupname --reset-offsets --all-topics --to-latest --execute
某个位置
bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --group groupname --reset-offsets --all-topics --to-offset 2000 --execute
调整到某个时间之后得最早位移
bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --group groupname --reset-offsets --all-topics --to-datetime 2019-09-15T00:00:00.000
Delete consumer group
bin/kafka-consumer-groups.sh --zookeeper localhost:2181 --delete --group groupname
4, scripting tools
producer script
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic topicname
参数含义:
--compression-codec lz4 压缩类型
--request-required-acks all acks的值
--timeout 3000 linger.ms的值
--message-send-max-retries 10 retries的值
--max-partition-memory-bytes batch.size值
consumer script
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic topicname --from-beginning
指定groupid
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic topicname --from-beginning
--consumer-property group.id=old-consumer-group
指定分区
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic topicname --from-beginning
--partition 0
kafka-run-class script
kafka-run-class.sh kafka.tools.ConsoleConsumer 就是 kafka-console-consumer.sh
kafka-run-class.sh kafka.tools.ConsoleProducer 就是 kafka-console-producer.sh
Gets the current number of messages topic
kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list localhost:9092 --topic topicname --time -1
--time -1 represents the maximum displacement of the first displacement represented --time -2
Query _consumer_offsets
bin/kafka-simple-consumer-shell.sh --topic _consumer_offsets --partition 12 --broker-list localhost:9092 --formatter "kafka.coorfinator.GroupMetadataManager\$OffsetsMessageFormatter"
5、MirrorMaker
Cross-room disaster recovery tool
bin/kafka-mirror-maker.sh --consumer.config consumer.properties --producer.config producer.properties --whitelist topicA|topicB
More real-time calculation, Flink, Kafka and other related technologies Bowen, welcome attention to calculate real-time streaming