kafka 集群

部署准备

至少三台服务器,Zookeeper 集群

安装

Kafka 安装包准备

Kafka 下载页面

配置文件修改

server.properties

# The id of the broker. This must be set to a unique integer for each broker.
broker.id=0
# The address the socket server listens on.
listeners=PLAINTEXT://x.x.x.x:9092
# A comma separated list of directories under which to store log files
# 数据文件存放地址
log.dirs=/home/bigdata/kafka/log
# Zookeeper connection string 
# 最后的 /kafka 是zk上的路径信息,如果不写,默认在根目录下展开 kafka 元数据信息,容易于其他系统冲突
zookeeper.connect=x.x.x.x:2181/kafka

分发配置文件到所有节点

# 复制 hadoop 安装包的解压文件夹到所有的机器
scp -r kafka_2.12-3.7.0 root@x.x.x.x:$PWD

其他节点配置文件修改

server.properties

修改 broker.id 。不能出现重复

# The id of the broker. This must be set to a unique integer for each broker.
broker.id=0
# The address the socket server listens on.
listeners=PLAINTEXT://x.x.x.x:9092

配置环境变量

export export KAFKA_HOME=/usr/bigdata/kafka_2.12-3.7.0
export PATH=$PATH:$KAFKA_HOME/bin

启动集群

所有节点执行启动命令

kafka-server-start.sh -daemon ${配置文件绝对路径}