1、启停:
./kafka-server-start.sh -daemon ../config/server.properties
./kafka-server-stop.sh -daemon ../config/server.properties
2、创建topic
bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 3 --partitions 6 --topic test1
bin/kafka-topics.sh --create --zookeeper 9.147.22.10:2181/kafka --replication-factor 1 --partitions 1 --topic test1
3、查询topic
bin/kafka-topics.sh --list --zookeeper localhost:2181
bin/kafka-topics.sh --list --bootstrap-server localhost:9092
bin/kafka-topics.sh --bootstrap-server localhost:9092 --topic test1 --describe
4、删除topic
bin/kafka-topics.sh --delete --zookeeper 9.147.22.10:2181/kafka --replication-factor 1 --partitions 3 --topic tp1
bin/kafka-topics.sh --delete --bootstrap-server localhost:9092 --topic test1
5、增加分区
./kafka-topics.sh --alter --topic=test1 --zookeeper 9.147.22.10:2181/kafka --partitions 64
生产和消费:
1、生产者
bin/kafka-console-producer.sh --bootstrap-server localhost:9099 --topic test1
2、消费者
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic filebeatkafka2 --property print.timestamp=true --from-beginning --partition 3