大数据之—kafka集群环境
前言
参考:https://blog.csdn.net/huxili2020/article/details/120371459
一、安装
mkdir -p /opt/kafka && cd /opt/kafka
tar -zxvf /opt/kafka/kafka_2.13-3.3.1.tgz
mkdir -p /opt/kafka/kafka_2.13-3.3.1/logs
cp /opt/kafka/kafka_2.13-3.3.1/config/server.properties /opt/kafka/kafka_2.13-3.3.1/config/server.properties.back
二、配置
vim /opt/kafka/kafka_2.13-3.3.1/config/server.properties
# 修改以下内容
broker.id=0
log.dirs=/opt/kafka/kafka_2.13-3.3.1/data
zookeeper.connect=node1:2181,node2:2181,node3:2181
1、配置环境变量:vim /etc/profile.d/my_env.sh
# KAFKA_HOME
export KAFKA_HOME=/opt/kafka/kafka_2.13-3.3.1
export PATH=$PATH:$KAFKA_HOME/bin
2、群起脚本
touch /opt/kafka/kafka && chmod +x /opt/kafka/kafka && vim /opt/kafka/kafka
#!/bin/bash
host_names=(node1 node2 node3)
case $1 in
"start"){
for host in ${host_names[@]}
do
echo "=========== $host 启动kafka =========="
ssh $host "$KAFKA_HOME/bin/kafka-server-start.sh -daemon $KAFKA_HOME/config/server.properties"
done
};;
"stop"){
for host in ${host_names[@]}
do
echo "========== $host 停止kakfa =========="
ssh $host "$KAFKA_HOME/bin/kafka-server-stop.sh"
done
};;
esac
3、同步文件:xsync /opt/kafka/ && xsync /etc/profile.d/my_env.sh
4、修改各节点 broker.id
vim /opt/kafka/kafka_2.13-3.3.1/config/server.properties
node1 0
node2 1
node3 2
5、刷新各节点环境变量