Measuring open road seventy-three: Message Queue only achieve environmental structures kafka

 

A: install java environment to ensure that java can call the correct

 

kafka Download: http://kafka.apache.org/downloads

Download and unzip kafka:

Two new folders for storing log data of zookeeper and kafka

Change setting:

1, the new zookeeper_data \ zookeeper folder to store the data of zookeeper

Edit config--zookeeper.properties of dataDir for the file you just created folder, clientPort default port number of the zookeeper

 

2, create a new folder for storing log data of kafka

Edit config--server.properties of log.dirs for the file you just created folder

Each start a kafka, broker.id must be unique, can not be repeated

Port number for the zookeeper

kafka the default port number is 9092

 

Message queue of step (basis having promoter sequence):

1, start zookeeper (running in the outer bin directory):
Linux / mac: bin / zookeeper-server-start.sh config / zookeeper.properties
Windows: bin \ Windiws \ ZooKeeper-Server-the start.bat config \ zookeeper.properties

 

2, start kafka (running in the outer bin directory):
Linux / mac: bin / kafka-server-start.sh config / the server.properties
Windows: bin \ Windows \ Kafka used to live-Server-the start.bat config \ the server.properties

 

3、创建topic,如名为test(在bin目录的外层运行)
linux/mac: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

kafka也会有对应日志

zookeeper也有对应日志

 

4、列出topic (在bin目录的外层运行)
linux/mac:bin/kafka-topics.sh --list --zookeeper localhost:2181
windows:bin\windows\kafka-topics.bat --list --zookeeper localhost:2181

 

5、启动生产者发送消息 (在bin目录的外层运行)
linux/mac:bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
windows:bin\windows\kafka-console-producer.bat --broker-list localhost:9092 --topic test

 

6、启动消费者接收消息(可开多个),运行后会自动刷新消息 (在bin目录的外层运行)
linux/mac:bin/kafka-console-consumer.bat.sh --bootstrap-server localhost:9092 --topic test --from-beginning
windows:bin\windows\kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic test --from-beginning

 

Guess you like

Origin www.cnblogs.com/zhongyehai/p/11267172.html