• Kafka:容器安装篇


    一:拉取 kafka镜像: docker pull bitnami/kafka

    docker search kafka
    docker pull bitnami/kafka

    [root@vboxnode3ccccccttttttchenyang data]# docker pull bitnami/kafka
    Using default tag: latest
    latest: Pulling from bitnami/kafka
    0796bf144e3f: Pull complete
    6d8d1650718e: Retrying in 12 seconds
    295a174e4cfb: Retrying in 1 second
    165586489a46: Retrying in 1 second
    462b8c8ce5a5: Waiting
    8a9dcdf65003: Waiting
    47c266a8c4bf: Waiting
    baacf938d67b: Waiting
    4f65080d9aff: Waiting
    7598e22d2eda: Waiting
    1bed0f0253ed: Waiting
    cf9a6955b62d: Waiting
    6de0db3a4a7b: Waiting
    latest: Pulling from bitnami/kafka
    b9dd917e5b67: Pull complete
    Digest: sha256:510326ce7bec53d5cdd4be948228871f4f5732af9cfde168be0f15c94ae0d7ee
    Status: Downloaded newer image for bitnami/kafka:latest
    docker.io/bitnami/kafka:latest
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21

    在这里插入图片描述

    二:运行 kafka容器: docker run containerId

    Kafka集群中,每个broker都有一个唯一的id值用来区分彼此。
    Kafka在启动时会在zookeeper中/brokers/ids路径下创建一个与当前broker的id为名称的虚节点,Kafka的健康状态检查就依赖于此节点。
    当broker下线时,该虚节点会自动删除,其他broker或者客户端通过判断/brokers/ids路径下是否有此broker的id来确定该broker的健康状态。

    docker run -d --name kafka -p 9092:9092 --restart=always \
    > -e KAFKA_BROKER_ID=0 \
    > -e ALLOW_PLAINTEXT_LISTENER=yes \
    > -e KAFKA_CFG_ZOOKEEPER_CONNECT=192.168.56.103:2181 \
    > -e KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://192.168.56.103:9092 \
    > -e TZ="Asia/Shanghai" bitnami/kafka:latest
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    [root@vboxnode3ccccccttttttchenyang data]# docker run -d --name kafka -p 9092:9092 --restart=always \
    > -e KAFKA_BROKER_ID=0 \
    > -e ALLOW_PLAINTEXT_LISTENER=yes \
    > -e KAFKA_CFG_ZOOKEEPER_CONNECT=192.168.56.103:2181 \
    > -e KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://192.168.56.103:9092 \
    > -e TZ="Asia/Shanghai" bitnami/kafka:latest
    a3e131e6907dbfb57e330ba2e8d65fecde7f6d3f582e9f5c12fc631abecca317
    [root@vboxnode3ccccccttttttchenyang data]# docker ps
    CONTAINER ID   IMAGE                                                 COMMAND                   CREATED          STATUS          PORTS                                                                     NAMES
    a3e131e6907d   bitnami/kafka:latest                                  "/opt/bitnami/script…"   13 seconds ago   Up 12 seconds   0.0.0.0:9092->9092/tcp, :::9092->9092/tcp                                 kafka
    c69d6caece82   08616d26b8e7                                          "start_runit"             20 minutes ago   Up 20 minutes                                                                             k8s_calico-node_calico-node-m84mj_kube-system_ab5d7060-5c41-4ec1-b089-3285a140c7d9_4
    490e4d88400c   a4ca41631cc7                                          "/coredns -conf /etc…"   20 minutes ago   Up 20 minutes                                                                             k8s_coredns_coredns-545d6fc579-bn8hg_kube-system_cd934cf8-f20a-4c51-949d-5ce889e92d39_3
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    在这里插入图片描述

    三:开放防火墙

    [root@vboxnode3ccccccttttttchenyang data]# firewall-cmd --permanent --zone=public --add-port=9092/tcp
    success
    [root@vboxnode3ccccccttttttchenyang data]# firewall-cmd --reload
    success
    [root@vboxnode3ccccccttttttchenyang data]# firewall-cmd --permanent --zone=public --list-port
    3306/tcp 8848/tcp 8091/tcp 8879/tcp 8887/tcp 8083/tcp 8086/tcp 8090/tcp 8099/tcp 9600/tcp 4560/tcp 5601/tcp 443/tcp 8443/tcp 30001/tcp 6443/tcp 2181/tcp 9092/tcp
    [root@vboxnode3ccccccttttttchenyang data]#
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    在这里插入图片描述

  • 相关阅读:
    【PHP快速上手(十四)】
    MQTT Paho Android 支持SSL/TLS(亲测有效)
    14---OpenCV:图像检测之边缘检测
    获取Spring中@PathVariable注解里带点的完整参数
    如何将数据库某列的值(如日期)作为表格的列名
    遥感数据与作物模型同化应用:PROSAIL模型、DSSAT模型、参数敏感性分析、数据同化算法、模型耦合、精度验证等主要环节
    MySQL比较两个表数据的差异
    并发编程之CompletableFuture全网最细最全用法(一)
    十进制转二进制的算法代码 ← Python
    java架构知识-设计模式与实践(学习笔记)
  • 原文地址:https://blog.csdn.net/Abraxs/article/details/132475280