一、操作系统
openKylin 1.0.1 X86
二、下载安装包
# 安装依赖jdk
sudo apt-get update
sudo apt-get install default-jdk
# 下载kafka
mkdir -p /data/software/kafka
wget https://archive.apache.org/dist/kafka/2.4.1/kafka_2.13-2.4.1.tgz
三、解压安装
# 解压缩Kafka压缩包
tar -xzf kafka_2.13-2.4.1.tgz
cd kafka_2.13-2.4.1
# 启动ZooKeeper服务
bin/zookeeper-server-start.sh config/zookeeper.properties
# 启动Kafka服务
bin/kafka-server-start.sh config/server.properties
# ps如果需要IP访问需要修改server.properties,默认是主机名访问:#advertised.listeners=PLAINTEXT://your.host.name:9092,放开注释,修改如下
advertised.listeners=PLAINTEXT://192.168.3.101:9092
四、测试
telnet 127.0.0.1 9092
五、脚本
1、制作启动脚本startup.sh
nohup /usr/local/server/kafka/kafka_2.13-2.4.1/bin/zookeeper-server-start.sh /usr/local/server/kafka/kafka_2.13-2.4.1/config/zookeeper.properties > /usr/local/server/kafka/logs/zookeeper.log 2>&1 &
sleep 5
nohup /usr/local/server/kafka/kafka_2.13-2.4.1/bin/kafka-server-start.sh /usr/local/server/kafka/kafka_2.13-2.4.1/config/server.properties > /usr/local/server/kafka/logs/kafka.log 2>&1 &
2、制作停止脚本shutdown.sh
/usr/local/server/kafka/kafka_2.13-2.4.1/bin/zookeeper-server-stop.sh
/usr/local/server/kafka/kafka_2.13-2.4.1/bin/kafka-server-stop.sh
仅供参考!