zoukankan      html  css  js  c++  java
  • 【Linux】【kafka】【zookeeper】Linux安装kafka

    前提已经安装JDK:【Linux】安装JDK8,查看java进程、查看jdk安装路径

     

    1、下载kafka和zookeeper,本文放在/home/kafka目录下

    直接下载:wget https://archive.apache.org/dist/kafka/2.2.1/kafka_2.11-2.1.1.tgz

                      wget https://archive.apache.org/dist/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz

    下载好上传到Linux

    https://archive.apache.org/dist/kafka/2.2.1/

    https://archive.apache.org/dist/zookeeper/zookeeper-3.4.6/

    2、解压kafka和zookeeper

    tar -zxvf zookeeper-3.4.6.tar.gz

    tar -zxvf kafka_2.11-2.1.1.tgz

    3、修改zookeeper

    环境变量设置

    vim /etc/profile

    按i编辑,文件最后添加

    export ZOOKEEPER=/home/kafka/zookeeper-3.4.6/
    export PATH=$PATH:$ZOOKEEPER/bin

    按ESC,再按:wq退出

    重新加载配置文件

    source /etc/profile

    复制一个zoo.cfg

    cp /home/kafka/zookeeper-3.4.6/conf/zoo_sample.cfg /home/kafka/zookeeper-3.4.6/conf/zoo.cfg

    创建两个文件夹

    mkdir /home/kafka/zookeeper-3.4.6/data

    mkdir /home/kafka/zookeeper-3.4.6/log

    修改zoo.cfg

    进入配置文件后,按i

    vi /home/kafka/zookeeper-3.4.6/conf/zoo.cfg

    内容

    dataDir=/home/kafka/zookeeper-3.4.6/data
    dataLogDir=/home/kafka/zookeeper-3.4.6/log
    clientPort=2182

    按ESC,再按:wq

    4、启动zookeeper

    /home/kafka/zookeeper-3.4.6/bin/zkServer.sh start

    5、修改kafka

    创建文件夹

    mkdir /home/kafka/kafka_2.11-2.1.1/log

    修改配置文件

    vi /home/kafka/kafka_2.11-2.1.1/config/server.properties

    按i进入编辑,修改

    log.dirs=/home/kafka/kafka_2.11-2.1.1/log
    zookeeper.connect=localhost:2182

    按ESC,再按:wq退出

    6、启动kafka

    /home/kafka/kafka_2.11-2.1.1/bin/kafka-server-start.sh /home/kafka/kafka_2.11-2.1.1/config/server.properties

    后台启动:/home/kafka/kafka_2.11-2.1.1/bin/kafka-server-start.sh -daemon /home/kafka/kafka_2.11-2.1.1/config/server.properties

    7、查看kafka启动

    netstat -lnp|grep 9092

    或者

    jps

    8、启动生产者/home/kafka/kafka_2.11-2.1.1/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic helloKafka

     9、启动消费者/home/kafka/kafka_2.11-2.1.1/bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic helloKafka

     

     

    参考文章:https://blog.csdn.net/weixin_39984161/article/details/91971731

  • 相关阅读:
    位向量法、二进制法枚举子集
    jfinal 下载文件时重命名
    Java程序员开发参考资源
    (二)Hive1.2.2
    (一)Hive1.2.2
    YARN资源调度框架
    MapReduce并行编程模型
    HDFS 分布式文件系统
    Kafka
    观察者模式
  • 原文地址:https://www.cnblogs.com/xiaostudy/p/14356976.html
Copyright © 2011-2022 走看看