Kafka安装 (简单)

xiaoxiao2025-04-15  14

预装JDK1.8,Zookeeper

安装Kafka Broker:

tar zxvf kafka-2.11-1.1.1.tar.gz -C /opt/

mv /opt/kafka-2.11-1.1.1 /opt/kafka

启动:/opt/kafka/bin/kafka-server-start.sh -daemon /opt/kafka/config/server.properties

jps 查看进程: 30575 Kafka 表明启动了。

简单测试如下

生成主题:

# ./kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test11 Created topic "test11".

查看主题:

# ./kafka-topics.sh  --zookeeper localhost:2181 --describe --topic test11 Topic:test11    PartitionCount:1    ReplicationFactor:1    Configs:     Topic: test11    Partition: 0    Leader: 0    Replicas: 0    Isr: 0

发送消息:

# ./kafka-console-producer.sh --broker-list localhost:9092 --topic test11 >hello >hello,it's me! >

接收消息:

# ./kafka-console-consumer.sh --zookeeper localhost:2181 --topic test11 --from-beginning Using the ConsoleConsumer with old consumer is deprecated and will be removed in a future major release. Consider using the new consumer by passing [bootstrap-server] instead of [zookeeper]. hello hello,it's me!

 

转载请注明原文地址: https://www.6miu.com/read-5028318.html

最新回复(0)