CentOS 7 安装 kafka,简单配置使用kafka
安装
1 2 3 4
| wget http://mirror.bit.edu.cn/apache/kafka/2.2.0/kafka_2.12-2.2.0.tgz
tar -xzf kafka_2.12-2.2.0.tgz
|
启动
1 2 3 4
| bin/zookeeper-server-start.sh config/zookeeper.properties
bin/kafka-server-start.sh config/server.properties
|
测试
1 2 3 4 5 6 7 8
| bin/kafka-topics.sh --create --bootstrap-server localhost:9092 -- replication-factor 1 --partitions 1 --topic test
bin/kafka-topics.sh --list --bootstrap-server localhost:9092
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
1 2 3 4
| bin/zookeeper-server-start.sh config/zookeeper.properties
bin/zookeeper-server-start.sh -daemon config/zookeeper.properties
|
启动kafka
1 2 3 4
| bin/kafka-server-start.sh config/server.properties
bin/kafka-server-start.sh -daemon config/server.properties
|
查看topic列表
1
| bin/kafka-topics.sh --list --zookeeper localhost:2181
|
创建topic
1
| bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
|
生产者
1
| bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
|
消费者
1
| bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning
|
关闭kafka
1
| bin/kafka-server-stop.sh
|
关闭zookeeper
1
| bin/zookeeper-server-stop.sh
|
向博主反馈问题