Kafka部署

作者: 遥想公瑾当年 | 来源:发表于2017-05-09 10:25 被阅读1300次

    一 介绍

    Kafka是一种高吞吐量的分布式发布订阅消息系统,它可以处理消费者规模的网站中的所有动作流数据,下载地址如下:https://www.apache.org/dyn/closer.cgi?path=/kafka/0.10.2.0/kafka_2.11-0.10.2.0.tgz

    二 启动

    #启动zookeeper
    bin/zookeeper-server-start.sh config/zookeeper.properties
    #更改配置
    vi config/server.properties
    #编辑内容如下
    delete.topic.enable=true
    listeners=PLAINTEXT://192.168.43.27:9092
    #保存退出
    #启动kafka服务端
    bin/kafka-server-start.sh config/server.properties
    

    三 创建主题

    bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
    # 列出主题列表
    bin/kafka-topics.sh --list --zookeeper localhost:2181
    # 删除主题
    bin/kafka-topics.sh  --delete --zookeeper 192.168.43.27:2181  --topic road
    

    四 创建消息

    bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
    #发送消息
    This is a message
    
    This is another message
    

    五 接收消息

    bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning
    
    this is a message
    this is a another message
    

    六 遇到的问题

    在生产消息时,发生如下问题:

    WARN Error while fetching metadata with correlation id 1 : {test=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)
    

    查看日志如下:

    Registered broker 0 at path /brokers/ids/0 with addresses: 
    PLAINTEXT -> EndPoint(218.30.64.194,9092,PLAINTEXT) (kafka.utils.ZkUtils)  
    

    ip是218.30.64.194不是localhost,没有绑定Kafka启动监听的host信息,只需更改配置文件绑定即可。

    vi  config/server.properties
    #修改配置如下:
    #原配置:listeners=PLAINTEXT://:9092  
    listeners=PLAINTEXT://localhost:9092  
    

    重修启动zookeeper和kafka即可。

    相关文章

      网友评论

      • 123migo:你好,麻烦问一下,你的那个日志是如何查看的?我的kafka集群上没有server.log这个文件

      本文标题:Kafka部署

      本文链接:https://www.haomeiwen.com/subject/dxjbtxtx.html