需要先安装JDK1.8
下载
wget https://archive.apache.org/dist/kafka/2.6.2/kafka_2.12-2.6.2.tgz
解压
tar -xzvf kafka_2.12-2.6.2.tgz -C /data
创建目录
mv /data/kafka_2.12-2.6.2 /data/kafka && mkdir /data/kafka/logs
修改配置文件
vim /data/kafka/config/server.properties
#全局唯一id,在同一个zookeeper中保持唯一
broker.id=0
#监听地址和端口
listeners=PLAINTEXT://172.22.177.102:9092
num.network.threads=3
num.io.threads=8
socket.send.buffer.bytes=102400
socket.receive.buffer.bytes=102400
socket.request.max.bytes=104857600
#日志输出路径
log.dirs=/data/kafka/logs
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.flush.interval.messages=10000
log.flush.interval.ms=1000
log.retention.hours=24
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000
#zookeeper单机配置
zookeeper.connect=172.22.177.102:2888
#zookeeper集群配置
#zookeeper.connect={{ zookeeper_cluster.zookeeper_cluster_1_ip }}:{{ zookeeper.zookeeper_port }},{{ zookeeper_cluster.zookeeper_cluster_2_ip }}:{{ zookeeper.zookeeper_port }},{{ zookeeper_cluster.zookeeper_cluster_3_ip }}:{{ zookeeper.zookeeper_port }}
zookeeper.connection.timeout.ms=6000
group.initial.rebalance.delay.ms=0
配置system管理
vim /etc/systemd/system/kafka.service
[Unit]
Description=kafka
After=network.target
[Service]
Type=simple
ExecStart=/data/kafka/bin/kafka-server-start.sh /data/kafka/config/server.properties
ExecStop=/data/kafka/bin/kafka-server-stop.sh
TimeoutStartSec=0
Restart=always
[Install]
WantedBy=multi-user.target
启动
systemctl start kafka
systemctl enable kafka