zoukankan      html  css  js  c++  java
  • Kafka学习之(二)Centos下安装Kafka

    环境:Centos6.4,官方下载地址:http://kafka.apache.org/downloads  ,前提是还需要安装了Java环境,本博客http://www.cnblogs.com/wt645631686/p/8267239.html有安装方法

    # wget https://archive.apache.org/dist/kafka/0.10.1.0/kafka_2.10-0.10.1.0.tgz
    # tar zxvf kafka_2.10-0.10.1.0.tgz
    # mv ./kafka_2.10-0.10.1.0 /usr/local/kafka
    # cd /usr/local/kafka/config/
    # vim zookeeper.properties   #编辑zookeeper配置文件
    #---------------------------------------------------------#
    dataDir=/tmp/zookeeper
    # the port at which the clients will connect
    #客户端端口2181,也就是通过zookeeper启动kafka的时候,指定端口号
    clientPort=2181
    # disable the per-ip limit on the number of connections since this is a non-production config
    maxClientCnxns=0
    # vim server.properties   #编辑kafka配置文件
    #------------------------------------------------------#
    listeners=PLAINTEXT://127.0.0.1:9092

    记住先启动zookeeper,再启动kafka

    # ./bin/zookeeper-server-start.sh ./config/zookeeper.properties   #启动zookeeper
    # ./bin/kafka-server-start.sh config/server.properties            #打开新终端启动kafka
    [root@localhost ~]# netstat -tunlp | grep 9092
    tcp        0      0 ::ffff:127.0.0.1:9092       :::*                        LISTEN      3092/java 

    启动成功,测试一下

    创建消费者

    # bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic mytest --from-beginning  //消费的集群--zookeeper  localhost:2181 zookeeper端口地址  --topic mytest   监听的主题
    #--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].

    打开新终端创建生产者

    # bin/kafka-console-producer.sh --broker-list localhost:9092 --topic mytest

    继续操作,输入想要输入的字符串敲击回车,观察消费者终端会发现有新消息。

    OK~

  • 相关阅读:
    Node Exporter监控指标
    Prometheus组件介绍
    记录阿里云安全组设置遇到的奇葩问题--出口ip
    7.prometheus监控多个MySQL实例
    使用Docker Compose部署SpringCloud项目docker-compose.yml文件示例
    Docker Compose的安装及命令补全
    如何调试 Docker
    Dockerfile 最佳实践
    Docker 命令查询
    Docker常见问题
  • 原文地址:https://www.cnblogs.com/wt645631686/p/8296257.html
Copyright © 2011-2022 走看看