Linux:bin/zkServer.sh starthtml
windows:bin\zkServer.cmdwindows
Linux:bin/kafka-server-start.sh start config/server.propertiesspa
windows:bin\windows\kafka-server-start.bat config\server.propertiesorm
Linux:bin/kafka-topics.sh -list --zookeeper 172.16.0.99:2181,172.16.0.218:2181server
windows:bin\windows\kafka-topics.bat -list --zookeeper 172.16.0.99:2181,172.16.0.218:2181htm
Linux:bin/kafka-topics.sh -zookeeper localhost:2181 --topic test --describeip
windows:bin\windows\kafka-topics.bat --zookeeper localhost:2181 --topic test --describeget
Linux:bin/kafka-topics.sh --zookeeper localhost:2181 --delete --topic "test"kafka
windows:bin\windows\kafka-topics.bat --zookeeper localhost:2181 --delete --topic "test"cmd
注意:集群中一台机器删除了topic,其余机器同步删除相同topic
Linux:bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
windows:bin\windows\kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
注意:
replication-factor:副本个数,通常为小于等于Broker个数。
partitions:分区个数。若是副本个数为1,分区为4,则4个分区会均匀的分布在各个Broker上。若是Broker为2,副本为2,分区为4,则每一个Broker上面都有4个分区。
Linux:bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning
windows:bin\windows\kafka-console-consumer.bat --zookeeper localhost:2181 --topic test --form-beginning
注意:form beginning表示从头拉取。
Linux:bin/kafka-console-producer.sh --broker-list 172.16.0.99:9020,172.16.0.218:9020 --topic test
windows:bin\windows\kafka-console-producer.bat --broker-list 172.16.0.99:9092,172.16.0.218:9080 --topic test
注意:此处是kafka的端口,并且在集群里若是此处填localhost,会报一个链接错误,猜测应该是消息没有到达集群,所以此处将集群的ip都填上。
Linux:bin/kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list 10.162.160.115:9092 --topic s1mmetest --time -1
Linux:bin/kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list 132.232.78.175:9092 --topic s1mmetest --time -2