zoukankan      html  css  js  c++  java
  • kafka_2.11-1.1.0 基础环境搭建

    下载与解压

    1. 下载kafka安装包,下载地址:https://www.apache.org/dyn/closer.cgi?path=/kafka/1.1.0/kafka_2.11-1.1.0.tgz
    2. 接下对应的安装包到你的目录(我的是:D:devSoftkafka_2.11-1.1.0)

    修改配置文件

    zookeeper配置文件修改

    新版本的kafka自带zookeeper。配置文件的位置在 kafka_2.11-1.1.0configzookeeper.properties。需要修改对应的dataDir指向的位置。

    # Licensed to the Apache Software Foundation (ASF) under one or more
    # contributor license agreements.  See the NOTICE file distributed with
    # this work for additional information regarding copyright ownership.
    # The ASF licenses this file to You under the Apache License, Version 2.0
    # (the "License"); you may not use this file except in compliance with
    # the License.  You may obtain a copy of the License at
    # 
    #    http://www.apache.org/licenses/LICENSE-2.0
    # 
    # Unless required by applicable law or agreed to in writing, software
    # distributed under the License is distributed on an "AS IS" BASIS,
    # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    # See the License for the specific language governing permissions and
    # limitations under the License.
    # the directory where the snapshot is stored.
    dataDir=D:devSoftkafka_2.11-1.1.0zookeeperData
    # the port at which the clients will connect
    clientPort=2181
    # disable the per-ip limit on the number of connections since this is a non-production config
    maxClientCnxns=0
    

    kafka配置文件修改

    kafka配置文件的位置在 kafka_2.11-1.1.0configserver.properties。需要修改对应的dataDir指向的位置。

    ############################# Log Basics #############################
    
    # A comma separated list of directories under which to store log files
    log.dirs=D:devSoftkafka_2.11-1.1.0server_data
    
    # The default number of log partitions per topic. More partitions allow greater
    # parallelism for consumption, but this will also result in more files across
    # the brokers.
    

    zookeeper启动

    安装目录kafka_2.11-1.1.0inwindows下执行zookeeper-server-start.bat ....configzookeeper.properties,默认端口(2181)在配置文件中已配置。

    kafka启动

    安装目录kafka_2.11-1.1.0inwindows下执行kafka-server-start.bat ....config/server.properties,默认端口(9092)

    创建与查询topic

    安装目录kafka_2.11-1.1.0inwindows下执行kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic topicDemo创建topicDemo主题。
    安装目录kafka_2.11-1.1.0inwindows下执行kafka-topics.bat --list --zookeeper localhost:2181列出所有主题。

    生产者启动

    安装目录kafka_2.11-1.1.0inwindows下执行kafka-console-producer.bat --broker-list localhost:9092 --topic topicDemo

    消费者启动

    安装目录kafka_2.11-1.1.0inwindows下执行kafka-console-consumer.bat --zookeeper localhost:2181 --topic topicDemo --from-beginning

    消息发送接收

    测试生产者发送消息

    测试消费者接收消息

  • 相关阅读:
    阿里云云效技术专家分享:云原生开发、调测及可靠发布解决方案
    对话李飞飞,揭秘国际体育赛事风“云”背后的黑科技
    时序数据库永远的难关 — 时间线膨胀(高基数 Cardinality)问题的解决方案
    当Java遇上机密计算,又一段奇幻之旅开始了!
    内核热补丁,真的安全么?
    在 Dubbo3.0 上服务治理的实践
    CCF-201509-3-生成模板系统
    WPF CommandParameter的使用
    UWP App Data存储和获取
    在WPF中的ItemsControl中使用事件和命令(Using events and Commands within ItemsControl in WPF)
  • 原文地址:https://www.cnblogs.com/yiweiblog/p/13919549.html
Copyright © 2011-2022 走看看