Apache Kafka Installation
Apache Kafka Installation
Kafka uses ZooKeeper so you need to first start a ZooKeeper server if you don't already have one. You can use the convenience script packaged with
kafka to get a quick-and-dirty single-node ZooKeeper instance.
Run the producer and then type a few messages into the console to send to the server.
If you have each of the above commands running in a different terminal then you should now be able to type messages into the producer terminal and
see them appear in the consumer terminal.
All of the command line tools have additional options; running the command with no arguments will display usage information documenting them in
more detail.
config/server-1.properties:
broker.id=1
port=9093
log.dir=/tmp/kafka-logs-1
config/server-2.properties:
broker.id=2
port=9094
log.dir=/tmp/kafka-logs-2
The broker.id property is the unique and permanent name of each node in the cluster. We have to override the port and log directory only because
we are running these all on the same machine and we want to keep the brokers from all trying to register on the same port or overwrite each others
data.
We already have Zookeeper and our single node started, so we just need to start the two new nodes:
"leader" is the node responsible for all reads and writes for the given partition. Each node will be the leader for a randomly selected portion
of the partitions.
"replicas" is the list of nodes that replicate the log for this partition regardless of whether they are the leader or even if they are currently
alive.
"isr" is the set of "in-sync" replicas. This is the subset of the replicas list that is currently alive and caught-up to the leader.
Note that in my example node 1 is the leader for the only partition of the topic.
We can run the same command on the original topic we created to see where it is: