正文
一、前提条件
192.168.1.1
192.168.1.2
192.168.1.3
二、安装过程
1.3台主机都执行如下命令
mkdir -p /data/kafka/logs mkdir -p /data/zookeeper/logs mkdir -p /data/zookeeper/data chown 777 -R /data/kafka/logs chown 777 -R /data/zookeeper/data chown 777 -R /data/zookeeper/logs touch /data/zookeeper/data/myid # 注意 每个节点的myid值是不一样的 需要在不同的节点上执行下面操作 #节点1 配置 echo "1" > /data/zookeeper/data/myid #节点2 配置 echo "2" > /data/zookeeper/data/myid #节点3 配置 echo "3" > /data/zookeeper/data/myid
2.三台主机配置conf/zookeeper.properties
解释:myid与zookeeper配置的1,2,3是相对应的
dataDir=/data/zookeeper/data dataLogDir=/data/zookeeper/logs clientPort=2181 maxClientCnxns=2000 initLimit=5 syncLimit=2 server.1=192.168.1.1:2888:3888 server.2=192.168.1.2:2888:3888 server.3=192.168.1.3:2888:3888
3.三台主机配置conf/server.properties
192.168.1.1 配置
log.dirs=/data/kafka/logs listeners=PLAINTEXT://:9092 advertised.listeners=PLAINTEXT://192.168.1.1:9092 zookeeper.connect=192.168.1.1:2181,192.168.1.2:2181,192.168.1.3:2181
192.168.1.2 配置
log.dirs=/data/kafka/logs listeners=PLAINTEXT://:9092 advertised.listeners=PLAINTEXT://192.168.1.2:9092 zookeeper.connect=192.168.1.1:2181,192.168.1.2:2181,192.168.1.3:2181
192.168.1.3 配置
log.dirs=/data/kafka/logs listeners=PLAINTEXT://:9092 advertised.listeners=PLAINTEXT://192.168.1.3:9092 zookeeper.connect=192.168.1.1:2181,192.168.1.2:2181,192.168.1.3:2181
4.启动zookeeper
1. cd /usr/local/kafka 2. 3. ./bin/zookeeper-server-start.sh config/zookeeper.properties
5.启动kafka
1. cd /usr/local/kafka 2. 3. ./bin/kafka-server-start.sh config/server.properties
6.查看端口占用
netstat -ntlp