[Kafka] commonly used commands

Creating Topic

kafka-topics.sh --create --bootstrap-server localhost:9092 --topic abtest  --partitions 2 --replication-factor 1   

View Topic What are

kafka-topics.sh --list --zookeeper localhost:2181

Producers, the data file is written to Kafka producer

kafka-console-producer.sh --broker-list localhost:9092 --topic order_topic < abc.txt

Consumers, from the beginning of the displacement, the consumption data Topic

kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic order_topic  --from-beginning

Reset Offset to the latest Consumer Group of displacement

kafka-consumer-groups.sh --bootstrap-server localhost:9092 --group group_name_1 --reset-offsets --topic order_topic --to-latest --execute

View consumer group Consumer Group displacement

[homework@test ~]$ kafka-consumer-groups.sh --bootstrap-server  host1:9092,host2:9092  --describe --group groupname_1

TOPIC                 PARTITION  CURRENT-OFFSET  LOG-END-OFFSET  LAG             CONSUMER-ID     HOST            CLIENT-ID

order                 5          20781271        20781556        285             -               -               -
order                 1          10553765        10554032        267             -               -               -
order                 2          10634508        10634808        300             -               -               -
order                 7          10375128        10375355        227             -               -               -
order                 6          10435147        10435467        320             -               -               -
order                 0          10640342        10640643        301             -               -               -
order                 3          13762141        13762478        337             -               -               -
order                 8          11176468        11176707        239             -               -               -
order                 4          10443088        10443320        232             -               -               -

Guess you like

Origin blog.51cto.com/10120275/2436999