启动zookeeper:
[root@baozi kafka_2.10-0.8.2.1]# bin/kafka-server-start.sh config/zookeeper.properties &后台启动kafka:
[root@baozi kafka_2.10-0.8.2.1]# bin/kafka-server-start.sh config/server.properties >/dev/null 2>&1 &
查看所有topic列表:
[root@baozi kafka_2.10-0.8.2.1]# bin/kafka-topics.sh --list --zookeeper 192.168.1.200:2181
创建topic:
[root@baozi kafka_2.10-0.8.2.1]# bin/kafka-topics.sh --create --zookeeper 192.168.1.200:2181 --replication-factor 1 --partitions 3 --topic test1
describe命令:
[root@baozi kafka_2.10-0.8.2.1]# bin/kafka-topics.sh --describe --zookeeper 192.168.1.200:2181 --topic test1
查看所有topic分区情况:
创建topic ->test2
bin/kafka-topics.sh --create --zookeeper 192.168.1.200:2181 --replication-factor 1 --partitions 3 --topic test2
删除主题topic:
[root@baozi kafka_2.10-0.8.2.1]# bin/kafka-run-class.sh kafka.admin.TopicCommand --delete --topic test1 --zookeeper 192.168.1.200:2181
查看所有主题:
[root@baozi kafka_2.10-0.8.2.1]# bin/kafka-topics.sh --list --zookeeper 192.168.1.200:2181
进入生产者状态:
[root@baozi kafka_2.10-0.8.2.1]# bin/kafka-console-producer.sh --broker-list 192.168.1.200:9092 --topic test2
进入消费者:
[root@baozi kafka_2.10-0.8.2.1]# bin/kafka-console-consumer.sh --zookeeper 192.168.1.200:2181 --topic test2 --from-beginning
[root@baozi ~]# jps
2793 ConsoleConsumer
2134 Kafka
2843 Jps
2028 QuorumPeerMain
2759 ConsoleProducer
[root@baozi ~]#
多broker部署:
会有两个kafka进程:
[root@baozi kafka_2.10-0.8.2.1]# jps
2134 Kafka
3014 Jps
2028 QuorumPeerMain
2961 Kafka
[root@baozi kafka_2.10-0.8.2.1]#
关闭kafka:
关闭broker:
[root@baozi kafka_2.10-0.8.2.1]# bin/kafka-server-stop.sh config/server.properties &
[root@baozi kafka_2.10-0.8.2.1]# bin/kafka-server-stop.sh config/server1.properties &
关闭zookeeper:
[root@baozi kafka_2.10-0.8.2.1]# bin/zookeeper-server-stop.sh config/zookeeper.properties >/dev/null 2>&1 &
[root@baozi kafka_2.10-0.8.2.1]# jps
3751 Jps
[root@baozi kafka_2.10-0.8.2.1]#