Saturday, April 14, 2018

Simple demo using Kafka



Start ZooKeeper
1
bin/zookeeper-server-start.sh config/zookeeper.properties

Start telnet
1
telnet localhost 2181

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




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

Create the producer
1
 bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test_topic

Create the consumer
1
2
bin/kafka-console-consumer.sh --zookeeper localhost:2181 
--topic test_topic --from-beginning

Output
When we type producer, we would get the message in consumer

Look for messages in the log
1
2
3
4
5
[cloudera@quickstart test_topic-0]$ ls
00000000000000000000.index  00000000000000000000.timeindex
00000000000000000000.log    leader-epoch-checkpoint

[cloudera@quickstart test_topic-0]$ cat *.log

No comments:

Post a Comment