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