linux单机kafka配置
华为仓库下载kafka zookeeper
https://mirrors.huaweicloud.com/apache/kafka
zookeeper相关:
- 解压:tar -zxvf zookeeper-3.4.10.tar.gz
- 创建文件夹:mkdir -vp /usr/local/kafka
- 切换到conf目录下: cd zookeeper-3.4.10/conf/
- 修改zoo.cfg cp zoo_sample.cfg zoo.cfg
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/usr/local/zookeeper/data
clientPort=2181
- zookeeper环境变量vi /etc/profile
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。
kafka相关
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