热门IT资讯网

【kafka】简单安装kafka单机版

发表于:2024-11-25 作者:热门IT资讯网编辑
编辑最后更新 2024年11月25日,1.安装kafka下载地址 : https://www.apache.org/dyn/closer.cgi?path=/kafka/0.9.0.0/kafka_2.11-0.9.0.0.tgzrzta

1.安装kafka

下载地址 : https://www.apache.org/dyn/closer.cgi?path=/kafka/0.9.0.0/kafka_2.11-0.9.0.0.tgz

rztar zxf kafka_2.11-0.9.0.0.tgzmv kafka_2.11-0.9.0.0 /usr/local/kafka


2.启停

/usr/local/kafka/bin/kafka-server-stop.sh  /usr/local/kafka/config/server.properties/usr/local/kafka/bin/kafka-server-start.sh /usr/local/kafka/config/server.properties &jps2695 QuorumPeerMain   # ZooKeeper 守护进程6268 Kafka            # Kafka     守护进程6553 Jps


3.以上是"单节点 & 单代理"配置


4.简单修改配置

cd /usr/local/kafkavim config/server.properties-------------advertised.host.name=10.1.44.187-------------


5.创建和删除topic

# 创建topicbin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic HelloWorld# 删除bin/kafka-topics.sh --delete --zookeeper localhost:2181 --topic HelloWorld# 查看已有topicbin/kafka-topics.sh --list  --zookeeper localhost:2181


6.开启2个窗口进行生产和消费测试

# 生产/usr/local/kafka/bin/kafka-console-producer.sh --broker-list   10.1.44.187:9092 --topic HelloWorld# 消费/usr/local/kafka/bin/kafka-console-consumer.sh --zookeeper   10.1.44.187:2181 --topic HelloWorld --from-beginning





0