start zookeeper
zookeeper-server-start.sh config/zookeeper.properties
start kafa
kafka-server-start.sh config/server.properties
Delete a topic,
kafka-topics.sh --zookeeper 127.0.0.1:2181 --topic second-topic --delete
List topics
kafka-topics.sh --zookeeper 127.0.0.1:2181 --list
create topic
kafka-topics.sh --zookeeper 127.0.0.1:2181 --topic second-topic --create --partitions 6 --replication-factor 1
describe a topic
kafka-topics.sh --zookeeper 127.0.0.1:2181 --topic first_topic --describe
produce a message from the console
kafka-console-producer.sh --broker-list 127.0.0.1:9092 --topic first_topic
kafka-console-producer.sh --broker-list 127.0.0.1:9092 --topic first_topic --producer-property acks=all
Consumer:
kafka-console-consumer.sh --bootstrap-server 127.0.0.1:9092 --topic first_topic
kafka-console-consumer.sh --bootstrap-server 127.0.0.1:9092 --topic first_topic --from-beginning
kafka-console-consumer.sh --bootstrap-server 127.0.0.1:9092 --topic first_topic --group my-first-application
Consumer groups
kafka-consumer-groups.sh --bootstrap-server localhost:9092 --list
kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group my-third-application
kafka-consumer-groups.sh --bootstrap-server localhost:9092 --group my-first-application --reset-offsets --shift-by -2 --execute --topic first_topic
kafka-consumer-groups.sh --bootstrap-server localhost:9092 --group my-first-application --reset-offsets --to-earliest --execute --topic first_topic
网友评论