zoukankan      html  css  js  c++  java
  • kafka指令

    后台形式启动kafka

      ./bin/kafka-server-start.sh -daemon /usr/local/kafka/config/server.properties

    查询当前所有 topic 

       ./bin/kafka-topics.sh --list --zookeeper localhost:2181

    创建生产者

    ./kafka-console-producer.sh --broker-list localhost:9092 --topic testkafka

    启动消费者

     ./bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic testkafka --from-beginning

    完美

    转载:

    https://www.orchome.com/454

    问题汇总:

    1.

    在做kafka测试的时候,使用命令bin/kafka-console-consumer.sh --zookeeper 192.168.0.140:2181,192.168.0.141:2181 --topic test --from-beginning启动消费者,发现一只报错consumer zookeeper is not a recognized option,搜索了半天,一只没有解决,最后,换了一个低版本的kakfa,发现在启动的时候说使用 --zookeeper是一个过时的方法,此时,才知道原来在最新的版本中,这种启动方式已经被删除了,
    最后附上0.90版本之后启动消费者的方法: bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning
    2.
     WARN [Consumer clientId=consumer-1, groupId=console-consumer-77498] Connection to node -1 (localhost/127.0.0.1:9092) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
    说明broker挂掉了,在zookeeper上可以查看当前运行的broker数量
    在zkCli.sh打开命令行后,ls /brokers/ids查看当前运行的broker数量
    为什么会发生这个问题,因为meta.properties(在tmp或者logs目录下)跟service.properties(在config目录下)中的brokerid不一致造成的。
    部分资料直接复制网络中其他文章,仅供个人参考学习
  • 相关阅读:
    C++常变量
    C++变量(C++变量定义、变量赋值、命名规则)
    463. Island Perimeter
    500. Keyboard Row
    811. Subdomain Visit Count
    901. Online Stock Span
    419. Battleships in a Board
    620. Not Boring Movies
    893. Groups of Special-Equivalent Strings
    575. Distribute Candies
  • 原文地址:https://www.cnblogs.com/decq/p/11992751.html
Copyright © 2011-2022 走看看