Win10 Configuration Installation Kafka

premise

jdk

zookeeper

zookeeper installation configuration see another blog post: https://blog.csdn.net/sndayYU/article/details/90718238

download

URL: http://kafka.apache.org/downloads
Download: kafka_2.12-2.2.0.tgz
Here Insert Picture Description

installation

1. Extract to "D: \ programGreen \ kafka_2.12-2.2.0"
Here Insert Picture Description

Stand-alone

Configuration

2. Modify Profile "config / server.properties" following two parameter values; and D create a directory on the disc "D: / programData / kafka / logs"

log.dirs=/programData/kafka/logs
zookeeper.connect=localhost:2181,localhost:2182,localhost:2183

run

1. Start zookeeper three servers, run: zkServer1.cmd under "D \ programGreen \ zookeeper-3.4.9 \ bin", zkServer2.cmd, zkServer3.cmd.
2. Start kafka

C:\Windows\system32>d:

D:\>cd D:\programGreen\kafka_2.12-2.2.0

D:\programGreen\kafka_2.12-2.2.0>.\bin\windows\kafka-server-start.bat .\config\server.properties

3. Create a theme, and sends a message by the client

C:\Windows\system32>d:

D:\>cd D:\programGreen\kafka_2.12-2.2.0

D:\programGreen\kafka_2.12-2.2.0>bin\windows\kafka-topics.bat --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic test

D:\programGreen\kafka_2.12-2.2.0>.\bin\windows\kafka-console-producer.bat --broker-list localhost:9092 --topic test
>This is a message
>This is another message
>

4. Start the consumer, the client can see the news. In this case, the message in the client's input will be passed to the consumer side.

C:\Windows\system32>d:

D:\>cd D:\programGreen\kafka_2.12-2.2.0

D:\programGreen\kafka_2.12-2.2.0>.\bin\windows\kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic test --from-beginning
This is a message
This is another message

Clusters

Configuration

1. Referring first standalone configuration
2. "D: \ programGreen \ kafka_2.12-2.2.0 \ config" server.properties replication in 3 parts: server-0.properties, server-1.properties, server-2 . Properties, and modify its inner part, as follows

# server-0.properties
broker.id=0
listeners=PLAINTEXT://:9092
log.dirs=/programData/kafka/logs-0
# server-1.properties
broker.id=1
listeners=PLAINTEXT://:9093
log.dirs=/programData/kafka/logs-1
# server-2.properties
broker.id=2
listeners=PLAINTEXT://:9094
log.dirs=/programData/kafka/logs-2

run

1. Start node 3

C:\Windows\system32>d:
D:\>cd D:\programGreen\kafka_2.12-2.2.0
D:\programGreen\kafka_2.12-2.2.0>.\bin\windows\kafka-server-start.bat .\config\server-0.properties &
C:\Windows\system32>d:
D:\>cd D:\programGreen\kafka_2.12-2.2.0
D:\programGreen\kafka_2.12-2.2.0>.\bin\windows\kafka-server-start.bat .\config\server-1.properties &
C:\Windows\system32>d:
D:\>cd D:\programGreen\kafka_2.12-2.2.0
D:\programGreen\kafka_2.12-2.2.0>.\bin\windows\kafka-server-start.bat .\config\server-2.properties &

2. Create a new theme for the replication factor of 3, and run "describe topics" command to see what is being done which brokers

C:\Windows\system32>d:
D:\>cd D:\programGreen\kafka_2.12-2.2.0
D:\programGreen\kafka_2.12-2.2.0>.\bin\windows\kafka-topics.bat --create --bootstrap-server localhost:9092 --replication-factor 3 --partitions 1 --topic my-replicated-topic
D:\programGreen\kafka_2.12-2.2.0>.\bin\windows\kafka-topics.bat --describe --bootstrap-server localhost:9092 --topic my-replicated-topic
Topic:my-replicated-topic       PartitionCount:1        ReplicationFactor:3     Configs:segment.bytes=1073741824
        Topic: my-replicated-topic      Partition: 0    Leader: 0       Replicas: 0,1,2 Isr: 0,1,2
D:\programGreen\kafka_2.12-2.2.0>

3. Publish news

C:\Windows\system32>d:
D:\>cd D:\programGreen\kafka_2.12-2.2.0
D:\programGreen\kafka_2.12-2.2.0>.\bin\kafka-console-producer.bat --broker-list localhost:9092 --topic my-replicated-topic
'.\bin\kafka-console-producer.bat' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
D:\programGreen\kafka_2.12-2.2.0>.\bin\windows\kafka-console-producer.bat --broker-list localhost:9092 --topic my-replicated-topic
>Hello mytest!
>

4. Start the consumer side, receive messages, you can see the consumer side can receive the "Hello mytest!"

D:\programGreen\kafka_2.12-2.2.0>.\bin\windows\kafka-console-consumer.bat --bootstrap-server localhost:9092 --from-beginning --topic my-replicated-topic

5. Compatibility Test
After installing the official documentation to get rid of the main kafka, consumers will receive the message, but I have not tested the -? ? ? ? ?

C:\Windows\system32>wmic process where "caption = 'java.exe' and commandline like '%server-1.properties%'" get processid
ProcessId
20948
C:\Windows\system32>taskkill /pid 20948 /f
成功: 已终止 PID 为 20948 的进程。
C:\Windows\system32>

appendix

Official Documents

http://kafka.apache.org/quickstart

Guess you like

Origin blog.csdn.net/sndayYU/article/details/90718786