1、解压缩。创建软连接。
tar kafka_2.12-1.1.1.tgz
ln -s kafka_2.12-1.1.1 kafka
2、修改Kafka配置文件。
(1)zookeeper.properties
# 指定Zookeeper 数据目录 dataDir=/home/hadoop/data/zookeeper/zkdata # 指定Zookeeper 端口号 clientPort=2181
(2)consumer.properties
# 配置 Zookeeper集群 zookeeper.connect=hadoop01:2181,hadoop02:2181,hadoop03:2181
(3)producer.properties
# Kafka集群配置 bootstrap.servers=hadoop01:9092,hadoop02:9092,hadoop03:9092
(4)server.properties
# 指定 Zookeeper集群 zookeeper.connect=hadoop01:2181,hadoop02:2181,hadoop03:2181
3、Kafka安装目录分发集群节点。
scp -r kafka_2.12-1.1.1 hadoop@hadoop02:/home/hadoop/app
scp -r kafka_2.12-1.1.1 hadoop@hadoop03:/home/hadoop/app
4、修改Server编号。
server.properties。hadoop01、hadoop02、hadoop03,分别设置broker.id=1、broker.id=2、broker.id=3。
# The id of the broker. This must be set to a unique integer for each broker. broker.id=1 # The id of the broker. This must be set to a unique integer for each broker. broker.id=2 # The id of the broker. This must be set to a unique integer for each broker. broker.id=3
5、启动Zookeeper集群。(分别启动hadoop01、hadoop02、hadoop03)
进入 /home/hadoop/app/zookeeper目录,使用 bin/zkServer.sh start 启动Zookeeper集群。
6、启动Kafka集群。(分别启动hadoop01、hadoop02、hadoop03)
进入 /home/hadoop/app/kafka目录,使用bin/kafka-server-start.sh config/server.properties
7、使用jps命令查看Kafka进程。