-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/TattiQ/kafka
- Loading branch information
Showing
1 changed file
with
40 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,40 @@ | ||
# kafka | ||
pykafka client related stuff | ||
# Kafka in Docker | ||
## Deploy instructions. | ||
|
||
Search for any kafka docker: | ||
``` | ||
docker search kafka | ||
``` | ||
|
||
Start the zookeeper container, give it a name, bind the container port 2181 to the host OS port so that we can access that port from the our host OS if needed: | ||
``` | ||
docker run -d -p 2181:2181 --name zookeeper jplock/zookeeper | ||
``` | ||
|
||
Start the Kafka Docker, name it: kafka, link it to the above Zookeeper container: | ||
``` | ||
docker run -d --name kafka --link zookeeper:zookeeper ches/kafka | ||
``` | ||
|
||
Get the IP addresses of the Zookeeper and the Kafka broker first. Note that these IP addresses are assigned for Docker container automatically when we started them: | ||
|
||
``` | ||
ZK_IP=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' zookeeper) | ||
KAFKA_IP=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' kafka) | ||
``` | ||
|
||
We will issue the below command to create a topic “test” with 1 partition and replication factor 1: | ||
|
||
``` | ||
docker run --rm ches/kafka \ | ||
> kafka-topics.sh --create --topic test --replication-factor 1 --partitions 1 --zookeeper $ZK_IP:2181 | ||
Created topic "test". | ||
``` | ||
|
||
Issue below command to produce message to the “test” topic (The terminal will wait for our input.): | ||
``` | ||
docker run --rm --interactive ches/kafka kafka-console-producer.sh --topic test0 --broker-list $KAFKA_IP:9092 | ||
02120152 | ||
``` | ||
|
||
|