linux安装

2019-05-16  本文已影响0人  mick_

前期准备

kafka下载

官网下载地址:http://kafka.apache.org/downloads
wget https://www.apache.org/dyn/closer.cgi?path=/kafka/2.2.0/kafka_2.11-2.2.0.tgz

kafka下载.png

解压

tar -zxvf  kafka_2.11-2.2.0.tgz
mv kafka_2.11-2.2.0   /usr/local/kafka
cd /usr/local/kafka

启动

启动zookeeper:

bin/zookeeper-server-start.sh  config/zookeeper.properties 

启动kafka:

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

消息测试

创建一个topic叫test:

bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test

查看topic :

  bin/kafka-topics.sh -list -zookeeper localhost:2181

开启一个shell启动生产者:

bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
生产者.png

开启一个shell启动一个消费者:

bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning
消费者.png

kafka远程连接

 30 #     listeners = PLAINTEXT://your.host.name:9092
 31 listeners=PLAINTEXT://:9092
 32 
 33 # Hostname and port the broker will advertise to producers and consumers. If not set, 
 34 # it uses the value for "listeners" if configured.  Otherwise, it will use the value
 35 # returned from java.net.InetAddress.getCanonicalHostName().
 36 advertised.listeners=PLAINTEXT://192.168.3.213:9092

 bin/kafka-server-start.sh config/server.properties   1>/dev/null 2>&1 &
 bin/zookeeper-server-start.sh  config/zookeeper.properties   1>/dev/null 2>&1 &
上一篇 下一篇

猜你喜欢

热点阅读