首先去Apache Kafka网站下载tgz安装包进行解压,防止解压文件不然损坏容易报错;
tar -xzvf kafka_2.13-3.1.0.tgz
cd kafka_2.13-3.1.0
之后去kafka文件夹目录启动zookeeper和kafka服务;
bin/zookeeper-server-start.sh config/zookeeper.properties
bin/kafka-server-start.sh config/server.properties &
配置zookeeper.properties;
# 配置log目录
dataDir=/usr/local/kafka_2.13-3.1.0/zookeeper-logs
# broker连接端口
clientPort=2181
# 开启Server
admin.enableServer=true
# 开启日志审核
audit.enable=true
配置server.properties,单机单broker配置,其余默认即可;
# 设置broker对应id
broker.id=10
# 设置broker监听地址
listeners=PLAINTEXT://localhost:9092
# 设置自动新增topic
auto.create.topics.enable=true
# 配置log目录
log.dirs=/usr/local/kafka_2.13-3.1.0/kafka-logs
# 设置topic分区数
num.partitions=1
# 设置自动清理log
log.cleaner.enable=true
# 设置zookeeper连接地址
zookeeper.connect=localhost:2181
|