windows单节点配置
下载地址
启动文件配置
call bin/windows/zookeeper-server-start.bat config/zookeeper.properties
call bin/windows/kafka-server-start.bat config/server.properties
Linux6节点配置
3台服务器,每台2个节点
下载地址
Zookeeper下载地址
https://dlcdn.apache.org/zookeeper/zookeeper-3.9.3/apache-zookeeper-3.9.3-bin.tar.gz
Kafka下载地址
https://dlcdn.apache.org/kafka/3.9.0/kafka_2.13-3.9.0.tgz
配置防火墙
firewall-cmd --zone=public --add-port=9092/tcp --permanent
firewall-cmd --zone=public --add-port=3888/tcp --permanent
firewall-cmd --zone=public --add-port=2888/tcp --permanent
firewall-cmd --zone=public --add-port=8080/tcp --permanent
firewall-cmd --zone=public --add-port=2181/tcp --permanent
firewall-cmd --zone=public --add-port=80/tcp –permanent
firewall-cmd --zone=public --add-port=6379/tcp --permanent
firewall-cmd --zone=public --add-port=6380/tcp --permanent
firewall-cmd --zone=public --add-port=6381/tcp --permanent
systemctl restart firewalld
firewall-cmd --zone=public --list-ports
服务器环境配置
vim ~/.bashrc 或 vim /etc/profile
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# jdk
export JAVA_HOME=/usr/java/jdk-11
export CLASSPATH=.:${JAVA_HOME}/lib
# zk
export ZOOKEEPER_HOME=/home/programs/apache-zookeeper-3.9.3-bin_01
# KAFKA
export KAFKA_HOME=/home/programs/kafka_2.12-3.5.0_01
# redis
# export REDIS_HOME=/home/programs/redis-7.0.12
# PATH
export PATH=${JAVA_HOME}/bin:$PATH:${ZOOKEEPER_HOME}/bin:$PATH:${KAFKA_HOME}/bin:$PATH:${REDIS_HOME}/src
启用配置:source ~/.bashrc 或 source /etc/profile
安装Zookeeper
程序放到 /home/programs
软件放到 /home/soft
解压缩文件:
tar -zxf apache-zookeeper-3.9.3-bin.tar.gz -C /home/programs/
配置数据文件保存目录
/home/programs/apache-zookeeper-3.9.3-bin_01/zkdata
配置日志目录
/home/programs/apache-zookeeper-3.9.3-bin_01/zklog
配置MyId文件
vim /home/programs/apache-zookeeper-3.9.3-bin_01/zkdata/myid
输入1或2或3后保存(分别代表3台服务器)
修改配置文件
生成配置文件:cp conf/zoo_sample.cfg zoo.cfg
修改配置文件:vim conf/zoo.cfg
添加参数:
dataDir=/home/programs/apache-zookeeper-3.9.3-bin_01/zkdata
dataLogDir=/home/programs/apache-zookeeper-3.9.3-bin_01/zklog
admin.serverPort=8080
server.1=172.20.0.27:2888:3888
server.2=172.20.0.28:2888:3888
server.3=172.20.0.29:2888:3888
quorumListenOnAllIPs=true
启动Zookeeper
启动中:zkServer.sh start
查看运行状态:zkServer.sh status
显示 Mode: leader/ Mode: follower 代表配置成功
查看错误信息:zkServer.sh start-foreground
安装Kafka
程序放到 /home/programs
软件放到 /home/soft
配置参数
vim /home/programs/kafka_2.13-3.9.0_01/config/server.properties
zookeeper.connect=172.20.0.27:2181, 172.20.0.28:2181, 172.20.0.29:2181
log.retention.hours=72
log.dirs= /home/programs/kafka_2.13-3.9.0_01/log
listeners=PLAINTEXT:// 172.20.0.27:9092
启动
kafka-server-start.sh -daemon /home/programs/kafka_2.13-3.9.0_01/config/server.properties
kafka-server-start.sh -daemon /home/programs/kafka_2.13-3.9.0_02/config/server.properties
Kafka-ui安装配置
下载地址
配置文件参数地址
Misc configuration properties | UI for Apache Kafka
配置文件样例
kafka:
clusters:
-
name: local
bootstrapServers: localhost:29091
schemaRegistry: http://localhost:8085
schemaRegistryAuth:
username: username
password: password
# schemaNameTemplate: "%s-value"
metrics:
port: 9997
type: JMX
启动
java -Dspring.config.additional-location=<path-to-application-local.yml> -jar <path-to-jar>.jar
Docker 下运行Kafka-ui
docker run -it -p 8080:8080 -e DYNAMIC_CONFIG_ENABLED=true provectuslabs/kafka-ui