# 192.168.2.128
Kafka
# 192.168.2.129
Kafka
# 192.168.2.130
Redis
Zookeeper
Kafka
deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse
$ wget -qO- https://get.docker.com/ | sh
配置不用 sudo
sudo usermod -aG docker $USER
$ docker pull wurstmeister/zookeeper
$ docker pull wurstmeister/kafka
$ docker run -d --name zookeeper -p 2181:2181 -t wurstmeister/zookeeper
$ docker run -d --name kafka -p 9092:9092 \
-e KAFKA_BROKER_ID=0 \
-e KAFKA_ZOOKEEPER_CONNECT=192.168.2.130:2181 \
-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://192.168.2.130:9092 \
-e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 988f4a6ca13c(镜像ID)
其他两台 Kafka 也连接到 130 的 Zookeeper
kafka01 128
$ docker run -d --name kafka01 -p 9092:9092 \
-e KAFKA_BROKER_ID=1 \
-e KAFKA_ZOOKEEPER_CONNECT=192.168.2.130:2181 \
-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://192.168.2.128:9092 \
-e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 988f4a6ca13c
kafka02 129
$ docker run -d --name kafka02 -p 9092:9092 \
-e KAFKA_BROKER_ID=2 \
-e KAFKA_ZOOKEEPER_CONNECT=192.168.2.130:2181 \
-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://192.168.2.129:9092 \
-e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 988f4a6ca13c
$ docker exec -it bb189e36e49a /bin/bash
[zk: localhost:2181(CONNECTED) 3] ls /brokers/ids
[2, 1, 0]
这边的这个 id 就是我们刚才设置的 KAFKA_BROKER_ID