环境CentOS 7.9
# 创建下载/安装的文件夹
cd /usr/local/
wget https://dlcdn.apache.org/kafka/3.0.2/kafka_2.13-3.0.2.tgz --no-check-certificate
# 解压缩
tar -zxvf kafka_2.13-3.0.2.tgz
# 重命名
mv kafka_2.13-3.0.2 kafka
vi /etc/profile
# KAFKA_HOME
export KAFKA_HOME=kafka根目录
export PATH=$PATH:$KAFKA_HOME/bin
#例如笔者的文件路径
export KAFKA_HOME=/usr/local/kafka/
export PATH=$PATH:$KAFKA_HOME/bin
vim <Kafka安装目录>/config/zookeeper.properties
# 配置端口
clientPort=2181
# 配置数据目录(Kafka安装目录下新建zookeeper-data文件夹用于存放zookeeper数据)
dataDir=/usr/local/kafka/zookeeper-data/
# 初始化连接配置
maxClientCnxns=100
initLimit=10
syncLimit=5
zookeeper的数据目录下新建myid文件,这里暂且写入1,这是以后为搭建集群用的,用于区分不同的zookeeper
# 配置brokerid
broker.id=0
# 配置监听地址(可选,不配置默认就是9092)
listeners=PLAINTEXT://内网地址:9092
advertised.listeners=PLAINTEXT://外网:9092
# 配置数据目录(Kafka安装目录下新建kafka-data文件夹用于存放kafka数据)
log.dirs=/usr/local/kafka/kafka-data
# 配置zookeeper
zookeeper.connect=127.0.0.1:2181/kafka
# 启动 zookeeper
nohup /usr/local/kafka/bin/zookeeper-server-start.sh -daemon /usr/local/kafka/config/zookeeper.properties
# 启动 Kafka
nohup /usr/local/kafka/bin/kafka-server-start.sh -daemon /usr/local/kafka/config/server.properties
Kafka安装就完成了