安装Java环境:
sudo apt-get install openjdk-8-jdk
下载Kafka:
wget http://mirrors.tuna.tsinghua.edu.cn/apache/kafka/2.5.0/kafka_2.12-2.5.0.tgz
解压Kafka:
tar -xzf kafka_2.12-2.5.0.tgz
进入Kafka安装目录:
cd kafka_2.12-2.5.0
启动Zookeeper:
bin/zookeeper-server-start.sh config/zookeeper.properties
启动Kafka:
bin/kafka-server-start.sh config/server.properties
创建Topic:
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
发送消息:
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
接收消息:
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning
Zookeeper配置:
config/zookeeper.properties
Kafka配置:
config/server.properties
Kafka主题配置:
config/topics.properties
Kafka日志配置:
config/log4j.properties
本文链接:http://task.lmcjl.com/news/6915.html