版本1:
启动zookeeper:
bin/zookeeper-server-start.sh config/zookeeper.properties
启动kafka:
bin/kafka-server-start.sh config/server.properties
创建主题:
bin/kafka-topics.sh --create --zookeeper linux-star:2181 --replication-factor 1 --partitions 1 --topic test
删除主题:
bin/kafka-topics.sh --create --zookeeper hadoop102:2181 --replication-factor 1 --partitions 1 --topic test
查看主题:
bin/kafka-topics.sh --list --zookeeper linux-star:2181
启动生产者:
bin/kafka-console-producer.sh --broker-list linux-star:9092 --topic test
启动消费者:
1.从当前接收消息
bin/kafka-console-consumer.sh --bootstrap-server linux-star:9092 --topic test
2.从起始接收消息(历史消息)
bin/kafka-console-consumer.sh --bootstrap-server linux-star:9092 --topic test --from-beginning
版本2:
启动zookeeper:
bin/zookeeper-server-start.sh config/zookeeper.properties
启动kafka:
bin/kafka-server-start.sh config/server.properties
创建主题:
bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic test
查看主题:
bin/kafka-topics.sh --list --bootstrap-server localhost:9092
启动生产者:
bin/kafka-console-producer.sh --bootstrap-server localhost:9092 --topic test
启动消费者:
1.从当前接收消息
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test
2.从起始接收消息(历史消息)
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning