kafka、zookeeper相关命令

查看防火墙状态
firewall-cmd --state

开放端口
firewall-cmd --zone=public --add-port=2181/tcp --permanent
firewall-cmd --zone=public --add-port=9092/tcp --permanent
firewall-cmd --reload
firewall-cmd --zone=public --list-ports

开启关闭防火墙
systemctl start firewalld.service
systemctl stop firewalld.service

关闭防火墙开机启动
systemctl disable firewalld.service
开启防火墙开机启动
systemctl enable firewalld.service

启动
./zkServer.sh start
bin/kafka-server-start.sh config/server.properties &

后台启动
bin/zookeeper-server-start.sh -daemon config/zookeeper.properties
bin/kafka-server-start.sh -daemon config/server.properties

停止
bin/kafka-server-stop.sh  config/server.properties
./zkServer.sh stop


创建topic
bin/kafka-topics.sh --create --zookeeper 192.168.137.128:2181 --topic topic-test1 --replication-factor 1 --partitions 3 
查看topic
./kafka-topics.sh --list --zookeeper 192.168.137.128:2181
./kafka-topics.sh --describe --zookeeper 192.168.137.128:2181 --topic topic-test1
启动消息生产者
./kafka-console-producer.sh --broker-list 192.168.137.128:9092 --topic topic-test1
启动消息消费者
./kafka-console-consumer.sh --bootstrap-server 192.168.137.128:9092 --from-beginning --topic topic-test1
删除topic
kafka-topics.sh --zookeeper 192.168.137.128:2181  --delete --topic topic-test1

  

posted @ 2020-07-07 16:36  面向bug编程  阅读(162)  评论(0编辑  收藏  举报