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
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test

List kafka Topics
1
bin/kafka-topics.sh --list --zookeeper localhost:2181
Create 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 

Create the consumer
1
bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning
Output
When we type in producer console, 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