一、资源准备
1.下载地址
https://kafka.apache.org/downloads
本次使用的资源为kafka_2.12-2.8.0.tgz
采用本机搭建集群方式实现;
二、安装步骤
1.解压安装包并移动到指定的目录
tar -zxvf kafka_2.12-2.8.0.tgz
mv kafka_2.12-2.8.0 /usr/local/apps/
- 在kafka_2.12-2.8.0/conf下面,复制server.properties为三份
分别为server1.properties,server2.properties,server3.properties
cp server.properties server1.properties
cp server.properties server2.properties
cp server.properties server3.properties
- 修改server1.properties,server2.properties,server3.properties配置文件
各个配置文件修改如下:
# broker.id=1 broker.id=2 broker.id=3
broker.id=1
# 9092 9093 9094
listeners=PLAINTEXT://:9092
# 9092 9093 9094
advertised.listeners=PLAINTEXT://175.24.205.216:9092
# kafka1-log kafka2-log kafka3-log
log.dirs=/usr/local/apps/kafka_2.12-2.8.0/logs/kafka1-log
zookeeper.connect=localhost:2181,localhost:2182,localhost:2183
zookeeper.connection.timeout.ms=18000
num.network.threads=3
num.io.threads=8
socket.send.buffer.bytes=102400
socket.receive.buffer.bytes=102400
socket.request.max.bytes=104857600
num.partitions=1
num.recovery.threads.per.data.dir=1
offsets.topic.replication.factor=1
transaction.state.log.replication.factor=1
transaction.state.log.min.isr=1
log.retention.hours=24
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000
group.initial.rebalance.delay.ms=0
- 启动集群
启动服务1
./kafka-server-start.sh -daemon ../config/server1.properties
启动服务2
./kafka-server-start.sh -daemon ../config/server2.properties
启动服务3
./kafka-server-start.sh -daemon ../config/server3.properties