Ubuntu 安裝 kafka

一.安裝zookeeper
wget https://archive.apache.org/dist/zookeeper/zookeeper-3.5.6/apache-zookeeper-3.5.6-bin.tar.gz
tar -zxvf apache-zookeeper-3.5.6-bin.tar.gz
cd apache-zookeeper-3.5.6-bin

啓動zookeeper
cp zoo_sample.cfg zoo.cfg
bin/zkServer.sh start

驗證
ps -ef | grep zoo

二.安裝kafka
http://mirrors.tuna.tsinghua.edu.cn/apache/kafka/2.3.0/kafka_2.12-2.3.0.tgz
tar -zxvf kafka_2.12-2.3.0.tgz
cd kafka_2.12-2.3.0
cp config/zookeeper.properties config/zookeeper.properties.bak
修改config這四項
broker.id=1
listeners=PLAINTEXT://:9092
advertised.listeners=PLAINTEXT://host_ip:9092
log.dirs=/tmp/kafka/logs-1

啓動kafka
bin/kafka-server-start.sh ../config/server.properties

驗證
ps -ef | grep kafka

三.驗證zookeeper 是否註冊了kafka
cd apache-zookeeper-3.5.6-bin
bin/zkCli.sh
[zk: localhost:2181(CONNECTED) 0] ls /brokers/ids

如果爲空,重新啓動kafka

四.創建topic | 查看topic
cd kafka_2.12-2.3.0
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章