kafka stand-alone test (kafka_2.11-2.1.0)

1. Download and unzip kakfa

Address http://kafka.apache.org/downloads.html
decompression kafka_2.11-2.1.0.tgz

2, kafka cluster requires zookeeper

Download and extract the zookeeper http://apache.fayea.com/zookeeper/

3, edit kafka, profile

After entering decompression kafka directory, file modification server.propertis
provided listeners = PLAINTEXT: //192.168.26.130: 9092 (current machine ip)
other parameters default values

4, start kafka

First start zookeeper, zookeeper enter the bin directory and execute ./zkService.sh start
start kafka kafka into the bin directory, execute ./kafka-server-start.sh ../config/server.properties 
.

5, see the zookeeper and kafka Launch OK

Creating a Topic: 
./kafka-topics.sh --zookeeper localhost: 2181 --create --topic Test4 --partitions 1 --replication-factor 1 
represents test4 1 partition, a copy of the
view List Topic: 
./kafka --zookeeper localhost -topics.sh: 2181 --list ; test4 above to view the newly created
boot producer opened a new terminal: 
bin / kafka-console-producer.sh --broker-List 192.168.1.104:9092 - topic test4
input message: lmx
start consumer opens a new terminal: 
./kafka-console-consumer.sh --bootstrap-Server 192.168.26.130:9092 --topic Beginning Test4 --from-
test: 
Producer input terminal hello kafka, see if consumer terminal interface to the message

6, kafka related commands

1.console window:

producer:

./kafka-console-producer.sh --broker-list  localhost:9092  --topic my_test_topic

consumer:

./kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic my_test_topic --from-beginning

2. Check consumption:

List all consumer group:

./kafka-consumer-groups.sh --bootstrap-server localhost:9092 --list


View Group consumption:

./kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group my_group_02
 

./kafka-consumer-groups.sh --zookeeper localhost:2181 --describe --group my_group_02

View viable consumer group

./kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group my_group_02 --members

View group survival consumer spending partition

 ./kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group my_group_02 --members --verbose

3. Check the log file in the message content:

Server.properties path where the configuration file is the log file configuration items log.dirs

To the bin directory execute:

./kafka-run-class.sh kafka.tools.DumpLogSegments --files target log file --print-data-log
 

Published 13 original articles · won praise 1 · views 7824

Guess you like

Origin blog.csdn.net/weixin_40482816/article/details/85609357