[kafka] Topic Management
1. View the Topic that has been created
Cd / usr/local/kafka./bin/kafka-topics.sh-- list-- zookeeper 10.1.44.186 purl 2181 Magazine 10.1.44.187 Vera 2181 Magi 10.1.44.188 -_ _ consumer_offsets _ _ consumer_offsets _ _ consumer_offsetsconnect-test connect-test connect-testtest0320 test0320 test0320
two。 Create topic
Cd / usr/local/kafka./bin/kafka-topics.sh-- create-- zookeeper 10.1.44.186 create-- zookeeper 10.1.44.187 create 2181-- partitions 3-- replication-factor 2-- physical catalogue on each broker after the creation of the topic test0326#. -test0326-1test0326-1test0326-1test0326-2 test0326-2 test0326-2
3. View the information of Leader in the specified topic
Cd / usr/local/kafka./bin/kafka-topics.sh-- describe-- zookeeper 10.1.44.186 zookeeper 10.1.44.187 describe 2181-- topic test0326Topic: test0326 PartitionCount:3 ReplicationFactor:2 Configs:Topic: test0326 Partition: 0 Replicas: 0 Isr: 0Topic: test0326 Partition: 1 Leader: 1 Replicas: 1 Isr: 1 test0326 Partition: 2 Leader: 2 Replicas: 2 Isr: 2
4. View the offset consumed in the consumer group
(1) use the producer to generate once
(2) use test group to consume once
(3) current consumption offset of test group
Offset = 828, partition=1, key = 4, value = hh Laogao 4
Offset = 829, partition=1, key = 6, value = hh Laogao 6
Offset = 1095, partition=0, key = 1, value = hh Laogao 1
Offset = 1096, partition=0, key = 5, value = hh Laogao 5
Offset = 1097, partition=0, key = 7, value = hh Lao Gao 7
Offset = 1098, partition=0, key = 8, value = hh Laogao 8
Offset = 568, partition=2, key = 0, value = hh 0
Offset = 569,partition=2, key = 2, value = hh Laogao 2
Offset = 570, partition=2, key = 3, value = hh Laogao 3
Offset = 571, partition=2, key = 9, value = hh Laogao 9
Cd / usr/local/kafka./bin/kafka-run-class.sh kafka.tools.ConsumerOffsetChecker-- zookeeper 10.1.44.186 zookeeper 2181 Magazine 10.1.44.187 Freud 2181-- group test-- topic test0320# [2018-03-26 11 Fringe 06VR 17939] WARN WARNING: ConsumerOffsetChecker is deprecated and will be dropped in releases following 0.9.0. Use ConsumerGroupCommand instead. (kafka.tools.ConsumerOffsetChecker$) Group Topic Pid Offset logSize Lag Ownertest test0320 0 1099 1099 0 nonetest test0320 1 830 8300 0 Nonetest test0320 2 572 572 0 none
5.kafka-consumer-offset-checker.sh script
# bin/kafka-consumer-offset-checker.shOption Description-broker-info print broker information-group Consumption group-- help help information-- retry.backoff.ms? Retry back-off to use for failed offset queries. (default: 3000)-socket.timeout.ms? Socket timeout to use when querying for offsets. (default: 6000)-topic comma-separated list of consumer topics (if not present) All subjects)-- zookeeper zookeeper address cd / usr/local/kafkabin/kafka-consumer-offset-checker.sh-- zookeeper 10.1.44.186 usr/local/kafkabin/kafka-consumer-offset-checker.sh 2181 Magi 10.1.44.187 usr/local/kafkabin/kafka-consumer-offset-checker.sh 2181 Magi 10.1.44.188 purl 2181-- topic test0320-- group test-- broker-info [2018-03-26 1115 1440] WARN WARNING: ConsumerOffsetChecker is deprecated and will be dropped in releases following 0.9.0. Use ConsumerGroupCommand instead. (kafka.tools.ConsumerOffsetChecker$) Group Topic Pid Offset logSize Lag Ownertest test0320 0 1115 1115 0 nonetest test0320 1 838 838 0 Nonetest test0320 2 588 588 0 noneBROKER INFO2-> 10.1.44.188 90921-> 10.1.44.187 90920-> 10.1.44.186 9092