Junhc

岂止于博客

Kafka

安装Kafka
下载地址https://kafka.apache.org/downloads
wget http://mirrors.tuna.tsinghua.edu.cn/apache/kafka/2.3.1/kafka_2.11-2.3.1.tgz
解压
tar -zxvf kafka_2.11-2.3.1.tgz
修改配置文件
cd kafka_2.11-2.3.1

vim config/server.properties

`broker.id=1`
`log.dir=/data/kafka/logs`

启动zk
bin/zookeeper-server-start.sh -daemon config/zookeeper.properties
启动kafka
bin/kafka-server-start.sh -daemon config/server.properties
创建topic
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic zipkin

// 查看topic列表
bin/kafka-topics.sh --list --zookeeper localhost:2181
生产消息
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic zipkin
消费消息
bin/kafka-console-producer.sh --bootstrap-server localhost:9092 --topic zipkin