启动服务器
> bin\windows\kafka- server- start.bat config\server.properties
创建一个topic
> bin\windows\kafka- topics.bat - - create - - zookeeper localhost: 2181 - - replication- factor 1 - - partitions 1 - - topic test
查看topic
> bin\windows\kafka- topics.bat - - list - - zookeeper localhost: 2181
启动一个生产者
> bin\windows\kafka- console- producer.bat - - broker- list localhost: 9092 - - topic test
启动一个消费者
> bin\windows\kafka- console- consumer.bat - - bootstrap- server localhost: 9092 - - topic test - - from- beginning
设置多代理集群
> copy config/server.properties config/server- 1.properties
> copy config/server.properties config/server- 2.properties
config/server-1.properties :
broker.id=1
listeners=PLAINTEXT: //: 9093
log.dir=/tmp/kafka- logs- 1
config/server-2.properties :
broker.id=2
listeners=PLAINTEXT: //: 9094
log.dir=/tmp/kafka- logs- 2
启动新节点
> bin\windows\kafka- server- start.bat config/server- 1.properties
> bin\windows\kafka- server- start.bat config/server- 2.properties
创建副本为3,分区为1的新topic
> bin\windows\kafka- topics.bat - - create - - zookeeper localhost: 2181 - - replication- factor 3 - - partitions 1 - - topic my- replicated- topic
查看代理状态
> bin\windows\kafka- topics.bat - - describe - - zookeeper localhost: 2181 - - topic my- replicated- topic
> Topic: my- replicated- topic PartitionCount: 1 ReplicationFactor: 3 Configs:
> Topic: my- replicated- topic Partition: 0 Leader: 1 Replicas: 1 , 2 , 0 Isr: 1 , 2 , 0
获取节点processid,杀死对应进程
> wmic process where "caption = 'java.exe' and commandline like '%server- 1.properties%'" get processid
> ProcessId
> 6016
> taskkill /pid 6016 /f