centos7安裝kafka_2.11
阿新 • • 發佈:2019-04-10
1.0 *** profile path tor partition pro oot .html
1、下載
官網地址:http://kafka.apache.org/downloads.html
下載:
wget https://www.apache.org/dyn/closer.cgi?path=/kafka/2.2.0/kafka_2.11-2.2.0.tgz
2、解壓及目錄介紹
tar -xzvf kafka_2.11-2.2.0.tgz
3、配置
- zookeeper配置
只要配置這兩個參數就好了
- kafka配置
配置kafka的全局路徑
vim /etc/profile
#KAFKA_HOME
export KAFKA_HOME=/usr/local/src/kafka_2.11-2.1.0
vim config/server-1.properties
broker.id=1
listeners=PLAINTEXT://192.168.**.***:9092
log.dirs=/usr/local/src/kafka_2.11-2.1.0/tmp/kafka-logs1
zookeeper.connect=192.168.**.***:2182
vim config/server-2.properties
broker.id=2
listeners=PLAINTEXT://192.168.**.***:9093
log.dirs=/usr/local/src/kafka_2.11-2.1.0/tmp/kafka-logs2vim config/server-3.properties
broker.id=3
listeners=PLAINTEXT://192.168.**.***:9094
log.dirs=/usr/local/src/kafka_2.11-2.1.0/tmp/kafka-logs3
zookeeper.connect=192.168.**.***:2182
4、啟動zookeeper
zookeeper後臺啟動:
bin/zookeeper-server-start.sh -daemon config/zookeeper.properties &
5、後臺啟動kafka
kafka-server-start.sh -daemon $KAFKA_HOME/config/server-1.properties & kafka-server-start.sh -daemon $KAFKA_HOME/config/server-2.properties &
kafka-server-start.sh -daemon $KAFKA_HOME/config/server-3.properties &
6、創建topic
創建topic,包含一個分區,3個副本
bin/kafka-topics.sh --create --zookeeper 192.168.**.***:2181 --replication-factor 3 --partitions 1 --topic my_topic
查看topic
bin/kafka-topics.sh --list --zookeeper 192.168.**.***:2181
7、創建生產者和消費者
創建生產者 bin/kafka-console-producer.sh --broker-list master:9092,master:9093,master:9094 --topic my_topic 創建消費者 /bin/kafka-console-consumer.sh --bootstrap-server master:9092,master:9093,master:9094 --from-beginning --topic my_topic
註:
centos7安裝kafka_2.11