Mac上用brew 安裝kafaka

1.直接上命令:bash

brew install kafka

2.此時安裝kafka同時也會把zookeeper安裝下載下來code

因此啓動kafka時首先要啓動zookeeperserver

3.啓動zkkafka

cd  /usr/local/Cellar/kafka/1.0.0/libexec/bin
sudo zkServer start

4.修改配置/usr/local/etc/kafka/server.properties變量

將listeners =PLAINTEXT://loalhost:9092zookeeper

5.啓動kafka配置

#啓動 kafka
cd  /usr/local/Cellar/kafka/1.0.0/libexec/bin
 kafka-server-start /usr/local/etc/kafka/server.properties


cd  /usr/local/Cellar/kafka/1.0.0/libexec/bin
 kafka-server-start /usr/local/etc/kafka/server.properties權限

6.有時啓動時不喜歡這麼長的命令去啓動kafka,此時須要設置環境變量來啓動啦下載

啓動腳本im

#!/bin/sh
/usr/local/Cellar/kafka/1.0.0/libexec/bin/zookeeper-server-start.sh /usr/local/Cellar/kafka/1.0.0/libexec/config/zookeeper.properties &

sleep 3

/usr/local/Cellar/kafka/1.0.0/libexec/bin/kafka-server-start.sh /usr/local/Cellar/kafka/1.0.0/libexec/config/server.properties &

關閉腳本

#!/bin/sh
/usr/local/Cellar/kafka/1.0.0/libexec/bin/zookeeper-server-stop.sh /usr/local/Cellar/kafka/1.0.0/libexec/config/zookeeper.properties &

sleep 3

/usr/local/Cellar/kafka/1.0.0/libexec/bin/kafka-server-stop.sh /usr/local/Cellar/kafka/1.0.0/libexec/config/server.properties &

賦予可執行權限

chmod +x kafka_start.sh

chmod +x kafka_stop.sh

運行

bash kafka_start.sh

bash kafka_stop.sh

相關文章
相關標籤/搜索