一、前提,先去安装java环境
二、安装kafka
wget http://www.apache.org/dyn/closer.cgi?path=/kafka/2.8.0/kafka_2.13-3.6.0.tgz
tar xzf kafka_2.13-3.6.0.tgz
mv kafka_2.13-3.6.0 /usr/local/kafka // 这一步也可以不用
启动zookeeper
sudo /usr/local/kafka_2.13-3.6.0/bin/zookeeper-server-start.sh /usr/local/kafka_2.13-3.6.0/config/zookeeper.properties
开启另一个窗口
启动zookeeper
sudo /usr/local/kafka_2.13-3.6.0/bin/kafka-server-start.sh /usr/local/kafka_2.13-3.6.0/config/server.properties
三、测试可用性
创建主题
sudo /usr/local/kafka_2.13-3.6.0/bin/kafka-topics.sh --bootstrap-server localhost:9092 --create --topic test
查看主题
sudo /usr/local/kafka_2.13-3.6.0/bin/kafka-topics.sh --list --bootstrap-server localhost:9092
发送消息
另起一个窗口
sudo /usr/local/kafka_2.13-3.6.0/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
接收消息
另起一个窗口
sudo /usr/local/kafka_2.13-3.6.0/bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning