3 ---- kafka kafka series on the production and consumption

Copyright: https://blog.csdn.net/xichengqc/article/details/90322245
  1. Creating a theme called the topic131_01
[root@localhost bin]# sh kafka-topics.sh --create --zookeeper 192.168.133.131:2181 --replication-factor 1 --partitions 1 --topic topic131_01
Created topic "topic131_01".

Kafka-logs switch to the directory, you can see the name of the directory topic131_01-0

[root@localhost ~]# cd /home/software/kafka_2.11-1.0.0/kafka-logs

But also you can view all current topics through the command

[root@localhost bin]# sh kafka-topics.sh --list --zookeeper 192.168.133.131:2181
topic131_01
  1. Send a message to this topic
sh kafka-console-producer.sh --broker-list 192.168.133.131:9092 --topic topic131_01
>hello kafka

Enter, view messages sent under kafka-logs directory

[root@localhost topic131_01-0]# tail -f 00000000000000000000.log 
CplHKj®
           ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ"hello kafka
  1. Start consumer
 [root@localhost bin]# sh kafka-console-consumer.sh --zookeeper 192.168.133.131:9092 --topic topic131_01 --from-beginning
Using the ConsoleConsumer with old consumer is deprecated and will be removed in a future major release. Consider using the new consumer by passing [bootstrap-server] instead of [zookeeper]
.hello kafka

The new version of the boot command is:

[root@localhost bin]# sh kafka-console-consumer.sh --bootstrap-server 192.168.143.111:9092 --topic topic131_01 --from-beginning

Guess you like

Origin blog.csdn.net/xichengqc/article/details/90322245