1. 修改config 下的 server.properties文件
vi server.properties
配置zookeeper集群
zookeeper.connect=node8:2181,node9:2181,node10:2181
Kafka 启动命令 启动的时候读取配置文件
kafka-server-start.sh /opt/sxt/kafka/config/server.properties
2.创建topic
kafka-topics.sh –zookeeper node8:2181,node9:2181,node10:2181 –create –replication-factor 2 –partitions 3 –topic test
(参数说明:
–replication-factor:指定每个分区的复制因子个数,默认1个
–partitions:指定当前创建的kafka分区数量,默认为1个
–topic:指定新建topic的名称)
3.查看
kafka-topics.sh –zookeeper node8:2181,node9:2181,node10:2181 –list
创建生产者
kafka-console-producer.sh –broker-list node8:9092,node9:9092,node10:9092 –topic test
创建消费者
kafka-console-consumer.sh –zookeeper node8:2181,node9:2181,node10:2181 –from-beginning –topic test