启动zookeeper
bin/zookeeper-server-start.sh config/zookeeper.properties &
启动kafka
bin/kafka-server-start.sh config/server.properties &
停止kafka
bin/kafka-server-stop.sh
停止zookeeper
bin/zookeeper-server-stop.sh
创建topic
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
展示topic
bin/kafka-topics.sh --list --zookeeper localhost:2181
描述topic
bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic my-replicated-topic
生产者:
bin/kafka-console-producer.sh --broker-list 130.51.23.95:9092 --topic my-replicated-topic
消费者:
bin/kafka-console-consumer.sh --zookeeper 130.51.23.95:2181 --topic test --from-beginnin
bin/kafka-topics.sh --zookeeper node01:2181 --create --topic t_cdr --partitions 30 --replication-factor 2
注: partitions指定topic分区数,replication-factor指定topic每个分区的副本数
bin/kafka-topics.sh --zookeeper node01:2181 --list
bin/kafka-topics.sh --zookeeper node01:2181 --describe --topic t_cdr
bin/kafka-console-producer.sh --broker-list node86:9092 --topic t_cdr
bin/kafka-console-consumer.sh --zookeeper node01:2181 --topic t_cdr --from-beginning
bin/kafka-run-class.sh kafka.tools.GetOffsetShell --topic hive-mdatabase-hostsltable --time -1 --broker-list node86:9092 --partitions 0
注: time为-1时表示最大值,time为-2时表示最小值
为topic t_cdr 增加10个分区
bin/kafka-topics.sh --zookeeper node01:2181 --alter --topic t_cdr --partitions 10
bin/kafka-run-class.sh kafka.admin.DeleteTopicCommand --zookeeper node01:2181 --topic t_cdr
原文:https://www.cnblogs.com/studyNotesSL/p/11420173.html