91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

使用Docker快速搭建Zookeeper和kafka集群

發布時間:2020-07-04 12:56:03 來源:網絡 閱讀:3922 作者:知了小巷 欄目:大數據

集群搭建

鏡像選擇

Zookeeper和Kafka集群分別運行在不同的容器中
zookeeper官方鏡像,版本3.4
kafka采用wurstmeister/kafka鏡像

集群規劃
hostname Ip addr port listener
zoo1 172.19.0.11 2184:2181
zoo2 172.19.0.12 2185:2181
zoo3 172.19.0.13 2186:2181
kafka1 172.19.0.14 9092:9092 kafka1
kafka2 172.19.0.15 9093:9093 kafka2
Kafka3 172.19.0.16 9094:9094 Kafka3
宿主機root OSX 192.168.21.139【DHCP獲取,會變動】
實現目標

kafka集群在docker網絡中可用,和zookeeper處于同一網絡
宿主機可以訪問zookeeper集群和kafka的broker list
docker重啟時集群自動重啟
集群的數據文件映射到宿主機器目錄中
使用yml文件和$ docker-compose up -d命令創建或重建集群

$ docker-compose up -d
zk集群的docker-compose.yml
version: '3.4'

services:
  zoo1:
    image: zookeeper
    restart: always
    hostname: zoo1
    container_name: zoo1
    ports:
    - 2184:2181
    volumes:
    - "/Users/shaozhipeng/Development/volume/zkcluster/zoo1/data:/data"
    - "/Users/shaozhipeng/Development/volume/zkcluster/zoo1/datalog:/datalog"
    environment:
      ZOO_MY_ID: 1
      ZOO_SERVERS: server.1=0.0.0.0:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888
    networks:
      br17219:
        ipv4_address: 172.19.0.11

  zoo2:
    image: zookeeper
    restart: always
    hostname: zoo2
    container_name: zoo2
    ports:
    - 2185:2181
    volumes:
    - "/Users/shaozhipeng/Development/volume/zkcluster/zoo2/data:/data"
    - "/Users/shaozhipeng/Development/volume/zkcluster/zoo2/datalog:/datalog"
    environment:
      ZOO_MY_ID: 2
      ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=0.0.0.0:2888:3888 server.3=zoo3:2888:3888
    networks:
      br17219:
        ipv4_address: 172.19.0.12

  zoo3:
    image: zookeeper
    restart: always
    hostname: zoo3
    container_name: zoo3
    ports:
    - 2186:2181
    volumes:
    - "/Users/shaozhipeng/Development/volume/zkcluster/zoo3/data:/data"
    - "/Users/shaozhipeng/Development/volume/zkcluster/zoo3/datalog:/datalog"
    environment:
      ZOO_MY_ID: 3
      ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=0.0.0.0:2888:3888
    networks:
      br17219:
        ipv4_address: 172.19.0.13

networks:
  br17219:
    external:
      name: br17219
kafka集群的docker-compose.yml

kfkluster少拼了個c...

version: '2'

services:
  kafka1:
    image: wurstmeister/kafka
    restart: always
    hostname: kafka1
    container_name: kafka1
    ports:
    - 9092:9092
    environment:
      KAFKA_ADVERTISED_HOST_NAME: kafka1
      KAFKA_ADVERTISED_PORT: 9092
      KAFKA_ZOOKEEPER_CONNECT: zoo1:2181,zoo2:2181,zoo3:2181
    volumes:
    - /Users/shaozhipeng/Development/volume/kfkluster/kafka1/logs:/kafka
    external_links:
    - zoo1
    - zoo2
    - zoo3
    networks:
      br17219:
        ipv4_address: 172.19.0.14

  kafka2:
    image: wurstmeister/kafka
    restart: always
    hostname: kafka2
    container_name: kafka2
    ports:
    - 9093:9093
    environment:
      KAFKA_ADVERTISED_HOST_NAME: kafka2
      KAFKA_ADVERTISED_PORT: 9093
      KAFKA_ZOOKEEPER_CONNECT: zoo1:2181,zoo2:2181,zoo3:2181
    volumes:
    - /Users/shaozhipeng/Development/volume/kfkluster/kafka2/logs:/kafka
    external_links:
    - zoo1
    - zoo2
    - zoo3
    networks:
      br17219:
        ipv4_address: 172.19.0.15

  kafka3:
    image: wurstmeister/kafka
    restart: always
    hostname: kafka3
    container_name: kafka3
    ports:
    - 9094:9094
    environment:
      KAFKA_ADVERTISED_HOST_NAME: kafka3
      KAFKA_ADVERTISED_PORT: 9094
      KAFKA_ZOOKEEPER_CONNECT: zoo1:2181,zoo2:2181,zoo3:2181
    volumes:
    - /Users/shaozhipeng/Development/volume/kfkluster/kafka3/logs:/kafka
    external_links:
    - zoo1
    - zoo2
    - zoo3
    networks:
      br17219:
        ipv4_address: 172.19.0.16

networks:
  br17219:
    external:
      name: br17219

結果查看和測試

宿主機命令行創建topic
$ pwd
/Users/shaozhipeng/Development/kafka_2.11-2.0.0/bin
$ ./kafka-topics.sh --create --zookeeper localhost:2184,localhost:2185,localhost:2186 --replication-factor 1 --partitions 1 --topic test1
Kafka Tool查看

使用Docker快速搭建Zookeeper和kafka集群

docker ps查看正在運行的容器

使用Docker快速搭建Zookeeper和kafka集群

查看宿主機IP地址,并設置Host

這樣宿主機就可以訪問kafka集群了

使用Docker快速搭建Zookeeper和kafka集群

原文地址

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

沧源| 新邵县| 仲巴县| 新余市| 闽侯县| 阳城县| 盐亭县| 碌曲县| 澄江县| 宝丰县| 安西县| 大港区| 辉县市| 蛟河市| 太和县| 惠东县| 金塔县| 武山县| 郧西县| 维西| 和平区| 颍上县| 海宁市| 衡山县| 屏东市| 博野县| 榆中县| 田林县| 邹城市| 长寿区| 神农架林区| 漯河市| 崇文区| 田阳县| 苍山县| 长宁区| 巩义市| 喀喇| 呼图壁县| 南开区| 兴宁市|