华为仓库下载kafka zookeeper
https://mirrors.huaweicloud.com/apache/kafka
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/usr/local/zookeeper/data
clientPort=2181
export ZOOKEEPER_HOME=/usr/local/zookeeper/zookeeper-3.4.10
export PATH=.:$ZOOKEEPER_HOME/bin:$JAVA_HOME/bin:$PATH
启动:sh zkServer.sh start
关闭:sh zkServer.sh stop
说明:zookeeper为什么需要配置环境变量,因为zookeeper不需要自己启动。kafka配置的时候会配置zookeeper,到时候会在kafka中启动zookeeper。
tar -zxvf kafka_2.12-1.0.0.tgz
kafka/kafka_2.12-1.0.0/config文件夹下面修改四个配置文件:
配置server.properties:
broker.id=0
port=9092
host.name=localhost
/usr/local/kafka/kafka_2.12-1.0.0/log (文件夹路径可能导致问题)
配置zookeeper.properties:
dataDir=/usr/local/kafka/kafka_2.12-1.0.0/zookeeper/data
clientPort=2181
host.name=localhost
maxClientCnxns=0
配置producer.properties:
zookeeper.connect=localhost:2181
配置consumer.properties:
zookeeper.connect=localhost:2181
启动zookeeper
bin/zookeeper-server-start.sh config/zookeeper.properties
启动kafka
bin/kafka-server-start.sh config/server.properties
原文:https://www.cnblogs.com/windy13/p/12057456.html