Kafka stand-alone construction

download

wget http://mirror.bit.edu.cn/apache/kafka/1.0.0/kafka_2.11-1.0.0.tgz

unzip and cd into it

tar -zvxf kafka_2.11-1.0.0.tgz -C /usr/local/
cd /usr/local/kafka_2.11-1.0.0/

Modify the configuration file

 vim config/server.properties 

Modifications:

broker.id=1
log.dirs=data/kafka-logs

Functional Verification

Start zookeeper:

Start a single-node Zookeeper instance using the script in the installation package:

bin/zookeeper-server-start.sh -daemon config/zookeeper.properties

Start the Kafka service

Use kafka-server-start.sh to start the kafka service:

bin/kafka-server-start.sh config/server.properties

Create Topic

Topic test created with kafka-topics.sh but with a single copy of the partition

bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test

View Topics

bin/kafka-topics.sh --list --zookeeper localhost:2181

generate message

Send messages using kafka-console-producer.sh

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

Consuming messages

Use kafka-console-consumer.sh to receive messages and print them in terminal

bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning

delete topic

bin/kafka-topics.sh --delete --zookeeper localhost:2181 --topic test

View description Topic information

bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic test

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324418715&siteId=291194637