使用shell编写一个kafka的部署脚本
时间: 2023-12-05 14:03:58 浏览: 83
kafka+zookeeper高可用集群搭建shell使用脚本
#!/bin/bash
# 安装依赖
sudo apt-get update
sudo apt-get install -y default-jre
# 下载kafka
KAFKA_VERSION="2.8.0"
wget https://mirrors.bfsu.edu.cn/apache/kafka/${KAFKA_VERSION}/kafka_2.13-${KAFKA_VERSION}.tgz
tar -xzf kafka_2.13-${KAFKA_VERSION}.tgz
# 设置环境变量
export KAFKA_HOME=$PWD/kafka_2.13-${KAFKA_VERSION}
export PATH=$PATH:$KAFKA_HOME/bin
# 修改配置文件
cd $KAFKA_HOME/config
sed -i 's/broker.id=0/broker.id=1/g' server.properties
sed -i 's/#listeners=PLAINTEXT:\/\/:9092/listeners=PLAINTEXT:\/\/localhost:9092/g' server.properties
# 启动kafka
nohup $KAFKA_HOME/bin/kafka-server-start.sh $KAFKA_HOME/config/server.properties > kafka.log 2>&1 &
echo "Kafka deployed successfully."
阅读全文