zoukankan      html  css  js  c++  java
  • docker安装kafka

    docker安装kafka

    1. 下载镜像

    Copy//下载zookeeper
    docker pull wurstmeister/zookeeper
    
    //下载kafka
    docker pull wurstmeister/kafka:2.11-0.11.0.3
    

    2.启动镜像

    Copy//启动zookeeper
    docker run -d --name zookeeper -p 2181:2181 -v /etc/localtime:/etc/localtime wurstmeister/zookeeper
    
    //启动kafka
    [root@middleware ~]# docker run  -d --name kafka -p 9092:9092 -e KAFKA_BROKER_ID=0 -e KAFKA_ZOOKEEPER_CONNECT=192.168.1.106:2181 -e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://192.168.1.106:9092 -e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 -t wurstmeister/kafka
    b66d6b7e4d7ffce3756b60108b201ced00d43cc86fe48933699d18e77facd795
    [root@middleware ~]# docker ps -a
    CONTAINER ID        IMAGE                                               COMMAND                  CREATED             STATUS                 PORTS                                                NAMES
    b66d6b7e4d7f        wurstmeister/kafka                                  "start-kafka.sh"         6 seconds ago       Up 4 seconds           0.0.0.0:9092->9092/tcp                               kafka
    0acd95e5ebbf        wurstmeister/zookeeper                              "/bin/sh -c '/usr/sb…"   4 hours ago         Up 4 hours             22/tcp, 2888/tcp, 3888/tcp, 0.0.0.0:2181->2181/tcp   zookeeper
    419673cf7ed0        goharbor/nginx-photon:v1.8.2                        "nginx -g 'daemon of…"   3 days ago          Up 4 hours (healthy)   0.0.0.0:8088->80/tcp                                 nginx
    1a84841ae1c2        goharbor/harbor-jobservice:v1.8.2                   "/harbor/start.sh"       3 days ago          Up 4 hours                                                                  harbor-jobservice
    0c8e50ba2cfb        goharbor/harbor-portal:v1.8.2                       "nginx -g 'daemon of…"   3 days ago          Up 4 hours (healthy)   80/tcp                                               harbor-portal
    993f9bc91fc5        goharbor/harbor-core:v1.8.2                         "/harbor/start.sh"       3 days ago          Up 4 hours (healthy)                                                        harbor-core
    f6f6b1c4fb21        goharbor/registry-photon:v2.7.1-patch-2819-v1.8.2   "/entrypoint.sh /etc…"   3 days ago          Up 4 hours (healthy)   5000/tcp                                             registry
    eafdc5eb0b0e        goharbor/harbor-registryctl:v1.8.2                  "/harbor/start.sh"       3 days ago          Up 4 hours (healthy)                                                        registryctl
    cde71175159c        goharbor/harbor-db:v1.8.2                           "/entrypoint.sh post…"   3 days ago          Up 4 hours (healthy)   5432/tcp                                             harbor-db
    b73355140a25        goharbor/redis-photon:v1.8.2                        "docker-entrypoint.s…"   3 days ago          Up 4 hours             6379/tcp                                             redis
    d3e0c898919d        goharbor/harbor-log:v1.8.2                          "/bin/sh -c /usr/loc…"   3 days ago          Up 4 hours (healthy)   127.0.0.1:1514->10514/tcp                            harbor-log
    
    

    3.测试kafka

    收发消息

    /opt/kafka_2.13-2.6.0/bin # ./kafka-console-producer.sh --broker-list localhost:9092 --topic sun
    >123
    >;
    >exit
    >{"datas":[{"channel":"","metric":"temperature","producer":"ijinus","sn":"IJA0101-00002245","time":"1543207156000","value":"80"}],"ver":"1.0"}
    

    image-20201009223817083

    创建查看topic

    /opt/kafka_2.13-2.6.0/bin # cd ..
    /opt/kafka_2.13-2.6.0 # ls
    LICENSE    NOTICE     bin        config     libs       logs       site-docs
    /opt/kafka_2.13-2.6.0 # bin/kafka-topics.sh --zookeeper 192.168.1.106:2181 --create --topic dalianpai --partitions 2 --replication-factor 1
    Created topic dalianpai.
    /opt/kafka_2.13-2.6.0 # bin/kafka-topics.sh --zookeeper 192.168.1.106:2181 --list
    __consumer_offsets
    dalianpai
    sun
    /opt/kafka_2.13-2.6.0 #
    
  • 相关阅读:
    【Java每日一题】20161227
    【Java每日一题】20161226
    【Java每日一题】20161223
    【Java每日一题】20161222
    【Java每日一题】20161221
    【Java每日一题】20161220
    【Java每日一题】20161219
    【Java每日一题】20161216
    【Java每日一题】20161215
    【Java每日一题】20161214
  • 原文地址:https://www.cnblogs.com/dalianpai/p/13789351.html
Copyright © 2011-2022 走看看