进入zk根目录; 启动zk服务器
/opt/module/zookeeper-3.4.10/bin/zkServer.sh start
后台启动
kafka-server-start.sh -daemon /opt/module/kafka3.0.0/config/server.properties
同步启动
kafka-server-start.sh /opt/module/kafka3.0.0/config/server.properties
1)开启生产者
- kafka-console-producer.sh --bootstrap-server centos201:9092,centos202:9092,centos203:9092 --topic hello0416
- kafka-console-producer.sh --broker-list centos201:9092,centos202:9092,centos203:9092 --topic hello0415
2)基于zookeeper开启消费者
kafka-console-consumer.sh --bootstrap-server centos201:9092,centos202:9092,centos203:9092 --topic hello041
但当我们在开启消费者线程时,加上参数 --from-beginning 时
可以消费或收到201之前写的数据;只不过消息无序了;
kafka-console-consumer.sh --topic first --zookeeper centos201:2181 --from-beginning
3)基于 bootstrap-server 开启消费者
kafka-console-consumer.sh --topic hello0416 --bootstrap-server centos201:9092
4)rsync 把机器1的文件夹下的文件 同步到 机器2
[root@localhost module]# rsync -azv /opt/module/zookeeper-3.4.10/ root@192.168.163.202:/opt/module/zookeeper-3.4.10/
5)关闭防火墙
systemctl stop firewalld.service
1) 查看topic
kafka-topics.sh --bootstrap-server centos201:9092 --list
2)创建topic
kafka-topics.sh --bootstrap-server centos201:9092 --create --topic hello12 --partitions 3 --replication-factor 2
3)删除topic
kafka-topics.sh --bootstrap-server centos201:9092 --delete --topic first
4)查看topic 描述
kafka-topics.sh --bootstrap-server centos201:9092 --describe --topic hello10
【注意】不要搞错了
centos201:2181 针对 zookeeper集群;
centos201:9092 针对kafka集群;
https://potoyang.gitbook.io/spring-in-action-v5/di-8-zhang-fa-song-yi-bu-xiao-xi/8.3-shi-yong-kafka-fa-song-xiao-xi/8.3.3-bian-xie-kafka-jian-ting-qi
https://www.jianshu.com/c/0c9d83802b0c