Skip to content

Commit 49375de

Browse files
committed
Upgraded to Kafka 1.1.0
1 parent 14d3c44 commit 49375de

File tree

16 files changed

+100
-76
lines changed

16 files changed

+100
-76
lines changed
Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
version: '2'
22
services:
3-
zookeeper:
4-
image: zookeeper:3.4.9
5-
kafka:
6-
image: wurstmeister/kafka:0.10.1.1
7-
environment:
8-
HOSTNAME_COMMAND: "echo $HOSTNAME"
9-
KAFKA_ADVERTISED_PORT: 9092
10-
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
11-
depends_on:
12-
- zookeeper
3+
zookeeper:
4+
image: wurstmeister/zookeeper:3.4.6
5+
ports:
6+
- 2181:2181
7+
kafka:
8+
image: wurstmeister/kafka:1.1.0
9+
environment:
10+
KAFKA_LISTENERS: PLAINTEXT://kafka:9092
11+
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
12+
ports:
13+
- 9092:9092

labs/01-Verify-Installation/hello-world-kafka.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ In this lab, you will install Kafka with Docker and verify it is working by crea
1313

1414
One of the easiest way to get started with Kafka is through the use of [Docker](https://www.docker.com). Docker allows the deployment of applications inside software containers which are self-contained execution environments with their own isolated CPU, memory, and network resources. [Install Docker by following the directions appropriate for your operating system.](https://www.docker.com/products/overview) Make sure that you can run both the `docker` and `docker-compose` command from the terminal.
1515

16-
## Alias
16+
## [OPTIONAL] Alias
1717

1818
Because we use docker and docker-compose, the commands to run the kafka CLI are absurdly long.
1919

@@ -28,9 +28,9 @@ You may want to alias these commands. In Linux and Mac, you can simply create al
2828
E.g., say you run bash, you can open the `~/.bash_profile` file with your favorite editor and enter something like this:
2929

3030
```
31-
alias ktopics='docker-compose exec kafka /opt/kafka_2.11-0.10.1.1/bin/kafka-topics.sh'
32-
alias kconsole-producer='docker-compose exec kafka /opt/kafka_2.11-0.10.1.1/bin/kafka-console-producer.sh'
33-
alias kconsole-consumer='docker-compose exec kafka /opt/kafka_2.11-0.10.1.1/bin/kafka-console-consumer.sh'
31+
alias ktopics='docker-compose exec kafka /opt/kafka/bin/kafka-topics.sh'
32+
alias kconsole-producer='docker-compose exec kafka /opt/kafka/bin/kafka-console-producer.sh'
33+
alias kconsole-consumer='docker-compose exec kafka /opt/kafka/bin/kafka-console-consumer.sh'
3434
```
3535

3636
When you start new shells, you can now simply run:
@@ -72,28 +72,28 @@ You are now running inside the container and all the commands should work (and a
7272
3. Open an additional terminal window in the lesson directory, `lelabs/01-Verify-Installation`. We are going to create a topic called `helloworld` with a single partition and one replica:
7373

7474
```
75-
$ docker-compose exec kafka /opt/kafka_2.11-0.10.1.1/bin/kafka-topics.sh --create --zookeeper zookeeper:2181 --replication-factor 1 --partitions 1 --topic helloworld
75+
$ docker-compose exec kafka /opt/kafka/bin/kafka-topics.sh --create --zookeeper zookeeper:2181 --replication-factor 1 --partitions 1 --topic helloworld
7676
```
7777

7878
4. You can now see the topic that was just created with the `--list` flag:
7979

8080
```
81-
$ docker-compose exec kafka /opt/kafka_2.11-0.10.1.1/bin/kafka-topics.sh --list --zookeeper zookeeper:2181
81+
$ docker-compose exec kafka /opt/kafka/bin/kafka-topics.sh --list --zookeeper zookeeper:2181
8282
helloworld
8383
```
8484

8585
5. Normally you would use the Kafka API from within your application to produce messages but Kafka comes with a command line _producer_ client that can be used for testing purposes. Each line from standard input will be treated as a separate message. Type a few messages and leave the process running.
8686

8787
```
88-
$ docker-compose exec kafka /opt/kafka_2.11-0.10.1.1/bin/kafka-console-producer.sh --broker-list kafka:9092 --topic helloworld
88+
$ docker-compose exec kafka /opt/kafka/bin/kafka-console-producer.sh --broker-list kafka:9092 --topic helloworld
8989
Hello world!
9090
Welcome to Kafka.
9191
```
9292

9393
6. Open another terminal window in the lesson directory. In this window, we can use Kafka's command line _consumer_ that will output the messages to standard out.
9494

9595
```
96-
$ docker-compose exec kafka /opt/kafka_2.11-0.10.1.1/bin/kafka-console-consumer.sh --bootstrap-server kafka:9092 --topic helloworld --from-beginning
96+
$ docker-compose exec kafka /opt/kafka/bin/kafka-console-consumer.sh --bootstrap-server kafka:9092 --topic helloworld --from-beginning
9797
Hello world!
9898
Welcome to Kafka.
9999
```

labs/02-Publish-And-Subscribe/consumer/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<dependency>
1313
<groupId>org.apache.kafka</groupId>
1414
<artifactId>kafka-clients</artifactId>
15-
<version>0.10.1.1</version>
15+
<version>1.1.0</version>
1616
</dependency>
1717
<dependency>
1818
<groupId>com.google.guava</groupId>
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
version: '2'
22
services:
33
zookeeper:
4-
image: zookeeper:3.4.9
4+
image: wurstmeister/zookeeper:3.4.6
55
ports:
66
- 2181:2181
77
kafka:
8-
image: wurstmeister/kafka:0.10.1.1
8+
image: wurstmeister/kafka:1.1.0
99
ports:
1010
- 9092:9092
1111
- 7203:7203
1212
environment:
1313
KAFKA_ADVERTISED_HOST_NAME: [INSERT IP ADDRESS HERE]
14-
KAFKA_ADVERTISED_PORT: 9092
14+
# KAFKA_ADVERTISED_HOST_NAME: localhost
1515
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
1616
depends_on:
1717
- zookeeper

labs/02-Publish-And-Subscribe/producer.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ All the directory references in this lab is relative to where you expended the l
2424
version: '2'
2525
services:
2626
zookeeper:
27-
image: zookeeper:3.4.9
27+
image: wurstmeister/zookeeper:3.4.6
2828
ports:
2929
- 2181:2181
3030
kafka:
31-
image: wurstmeister/kafka:0.10.1.1
31+
image: wurstmeister/kafka:1.1.0
3232
ports:
3333
- 9092:9092
3434
- 7203:7203
3535
environment:
3636
KAFKA_ADVERTISED_HOST_NAME: [INSERT IP ADDRESS HERE]
37-
KAFKA_ADVERTISED_PORT: 9092
37+
# KAFKA_ADVERTISED_HOST_NAME: localhost
3838
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
3939
depends_on:
4040
- zookeeper
@@ -56,9 +56,9 @@ All the directory references in this lab is relative to where you expended the l
5656
inet6 fe80::cc8a:c5ff:fe43:b670%awdl0 prefixlen 64 scopeid 0x8
5757
inet6 fe80::7df6:ec93:ffea:367a%utun0 prefixlen 64 scopeid 0xa
5858
```
59-
6059
In this case, the IP address to use is `10.0.1.4`. Make sure you *do not* use `127.0.0.1` because that will not work correctly.
6160

61+
6262
On Windows, you can use the following command:
6363

6464
```
@@ -80,6 +80,10 @@ All the directory references in this lab is relative to where you expended the l
8080
8181
Save the `docker-compose.yml` file after making this modification.
8282

83+
> We have noticed on some configurations of Windows and Linux that the use of `KAFKA_ADVERTISED_HOST_NAME` does not work properly (the Kafka clients can't connect).
84+
> We've not found the source of this problem, but in many of the cases we've seen, the use of `localhost` instead of the host IP may work.
85+
> Note though, that the use of `localhost` prevents you from running multiple Kafka brokers on the same machine.
86+
8387
1. Start the Kafka and Zookeeper processes using Docker Compose:
8488

8589
```
@@ -89,14 +93,14 @@ All the directory references in this lab is relative to where you expended the l
8993
1. Open an additional terminal window in the lesson directory, `docker/`. We are going to create two topics that will be used in the Producer program. Run the following commands:
9094

9195
```
92-
$ docker-compose exec kafka /opt/kafka_2.11-0.10.1.1/bin/kafka-topics.sh --create --zookeeper zookeeper:2181 --replication-factor 1 --partitions 1 --topic user-events
93-
$ docker-compose exec kafka /opt/kafka_2.11-0.10.1.1/bin/kafka-topics.sh --create --zookeeper zookeeper:2181 --replication-factor 1 --partitions 1 --topic global-events
96+
$ docker-compose exec kafka /opt/kafka/bin/kafka-topics.sh --create --zookeeper zookeeper:2181 --replication-factor 1 --partitions 1 --topic user-events
97+
$ docker-compose exec kafka /opt/kafka/bin/kafka-topics.sh --create --zookeeper zookeeper:2181 --replication-factor 1 --partitions 1 --topic global-events
9498
```
9599

96100
1. List the topics to double check they were created without any issues.
97101

98102
```
99-
$ docker-compose exec kafka /opt/kafka_2.11-0.10.1.1/bin/kafka-topics.sh --list --zookeeper zookeeper:2181
103+
$ docker-compose exec kafka /opt/kafka/bin/kafka-topics.sh --list --zookeeper zookeeper:2181
100104
global-events
101105
user-events
102106
```
@@ -107,7 +111,7 @@ All the directory references in this lab is relative to where you expended the l
107111
<dependency>
108112
<groupId>org.apache.kafka</groupId>
109113
<artifactId>kafka-clients</artifactId>
110-
<version>0.10.1.1</version>
114+
<version>1.1.0</version>
111115
</dependency>
112116
<dependency>
113117
<groupId>com.google.guava</groupId>

labs/02-Publish-And-Subscribe/producer/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<dependency>
1313
<groupId>org.apache.kafka</groupId>
1414
<artifactId>kafka-clients</artifactId>
15-
<version>0.10.1.1</version>
15+
<version>1.1.0</version>
1616
</dependency>
1717
<dependency>
1818
<groupId>com.google.guava</groupId>

labs/04-Implement-Topics-And-Partitions/device-monitor/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<dependency>
1313
<groupId>org.apache.kafka</groupId>
1414
<artifactId>kafka-clients</artifactId>
15-
<version>0.10.1.1</version>
15+
<version>1.1.0</version>
1616
</dependency>
1717
<dependency>
1818
<groupId>com.google.guava</groupId>

labs/04-Implement-Topics-And-Partitions/docker/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ services:
1111
- 7203:7203
1212
environment:
1313
KAFKA_ADVERTISED_HOST_NAME: [INSERT IP ADDRESS HERE]
14+
# KAFKA_ADVERTISED_HOST_NAME: localhost
1415
KAFKA_ADVERTISED_PORT: 9092
1516
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
1617
depends_on:

labs/04-Implement-Topics-And-Partitions/heartbeat-simulator/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<dependency>
1313
<groupId>org.apache.kafka</groupId>
1414
<artifactId>kafka-clients</artifactId>
15-
<version>0.10.1.1</version>
15+
<version>1.1.0</version>
1616
</dependency>
1717
<dependency>
1818
<groupId>com.google.guava</groupId>

labs/04-Implement-Topics-And-Partitions/topics-and-partitions.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ $ docker-compose up
4343
Next we'll simply create the topics. Open a new terminal in the `docker` directory.
4444

4545
```
46-
$ docker-compose exec kafka /opt/kafka_2.11-0.10.1.1/bin/kafka-topics.sh --create --zookeeper zookeeper:2181 --replication-factor 1 --partitions 1 --topic device-heartbeat
47-
$ docker-compose exec kafka /opt/kafka_2.11-0.10.1.1/bin/kafka-topics.sh --create --zookeeper zookeeper:2181 --replication-factor 1 --partitions 1 --topic device-event
46+
$ docker-compose exec kafka /opt/kafka/bin/kafka-topics.sh --create --zookeeper zookeeper:2181 --replication-factor 1 --partitions 1 --topic device-heartbeat
47+
$ docker-compose exec kafka /opt/kafka/bin/kafka-topics.sh --create --zookeeper zookeeper:2181 --replication-factor 1 --partitions 1 --topic device-event
4848
```
4949

5050
## Build and run the device simulator
@@ -87,7 +87,7 @@ To see the messages, let's run our usual console consumer. In a new terminal `cd
8787

8888
```
8989
$ cd docker
90-
$ docker-compose exec kafka /opt/kafka_2.11-0.10.1.1/bin/kafka-console-consumer.sh --bootstrap-server kafka:9092 --topic device-heartbeat
90+
$ docker-compose exec kafka /opt/kafka/bin/kafka-console-consumer.sh --bootstrap-server kafka:9092 --topic device-heartbeat
9191
```
9292

9393
After a few seconds you should start to see heartbeat messages being produced. E.g.:
@@ -151,7 +151,7 @@ In a new shell, go to the `docker` directory.
151151

152152
```
153153
$ cd docker
154-
$ docker-compose exec kafka /opt/kafka_2.11-0.10.1.1/bin/kafka-console-consumer.sh --bootstrap-server kafka:9092 --topic device-event
154+
$ docker-compose exec kafka /opt/kafka/bin/kafka-console-consumer.sh --bootstrap-server kafka:9092 --topic device-event
155155
```
156156

157157
It may take some time before you see online or offline messages (see the device simulator and you'll see the randomness of the heartbeat production).

0 commit comments

Comments
 (0)