Kafka【部署 03】Zookeeper与Kafka自动部署脚本

脚本是针对特定脚本编写的,使用的话要结合自己安装的版本进行调整。

1.zookeeper

#!/bin/bash
rm -rf /usr/local/zookeeper

echo "1.安装Zookeeper..."
tar -zxvf apache-zookeeper-3.6.2-bin.tar.gz
mv ./apache-zookeeper-3.6.2-bin/ /usr/local/zookeeper
echo "1.安装Zookeeper完毕"

echo "2.环境变量配置..."
cat <<EOF > /etc/profile.d/zookeeper.sh
export ZOOKEEPER_HOME=/usr/local/zookeeper
export PATH=$PATH:$ZOOKEEPER_HOME/bin
EOF
chmod +x /etc/profile.d/zookeeper.sh
source /etc/profile.d/zookeeper.sh
echo "ZOOKEEPER_HOME目录:"${ZOOKEEPER_HOME}
echo "2.环境变量配置完毕"

echo "3.Zookeeper配置..."
cp ${ZOOKEEPER_HOME}/conf/zoo_sample.cfg ${ZOOKEEPER_HOME}/conf/zoo.cfg
sed -i "12c dataDir=/usr/local/zookeeper/data" ${ZOOKEEPER_HOME}/conf/zoo.cfg
sed -i "13i dataLogDir=/usr/local/zookeeper/datalog" ${ZOOKEEPER_HOME}/conf/zoo.cfg
echo "3.Zookeeper配置完毕"

echo "4.启动Zookeeper..."
zkServer.sh start
echo "4.启动Zookeeper完毕"

echo "5.开启2181端口..."
firewall-cmd --zone=public --add-port=2181/tcp --permanent && firewall-cmd --reload
echo "5.开启2181端口完毕"

2.kafka

#!/bin/bash
rm -rf /usr/local/kafka

echo "1.安装Kafka..."
tar -zxvf kafka_2.12-2.6.0.tgz
mv ./kafka_2.12-2.6.0/ /usr/local/kafka
echo "1.安装Kafka完毕"

echo "2.环境变量配置..."
cat <<EOF > /etc/profile.d/kafka.sh
export KAFKA_HOME=/usr/local/kafka
export PATH=$PATH:$KAFKA_HOME/bin
EOF
chmod +x /etc/profile.d/kafka.sh
source /etc/profile.d/kafka.sh
echo "KAFKA_HOME目录:"${KAFKA_HOME}
echo "2.环境变量配置完毕"

echo "3.Kafka配置..."
sed -i "32i listeners=PLAINTEXT://localhost:9092" ${KAFKA_HOME}/config/server.properties
sed -i "61c log.dirs=${KAFKA_HOME}/kafka-logs" ${KAFKA_HOME}/config/server.properties
echo "3.Kafka配置完毕"

echo "4.启动Kafka..."
kafka-server-start.sh -daemon ${KAFKA_HOME}/config/server.properties
echo "4.启动Kafkaj完毕"

echo "5.开启9092端口..."
firewall-cmd --zone=public --add-port=9092/tcp --permanent && firewall-cmd --reload
echo "5.开启9092端口完毕"
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

シ風

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值