zoukankan      html  css  js  c++  java
  • docker-Overlay原生网络

    节点1/键值存储:192.168.50.130
    节点2192.168.50.131
    1.下载Consul二进制包并启动
    wget https://releases.hashicorp.com/consul/0.9.2/consul_0.9.2_linux_amd64.zip
     unzip consul_0.9.2_linux_amd64.zipmv consul /usr/bin/consul && chmod +x /usr/bin/consul
     nohup consul agent -server -bootstrap -ui -data-dir /var/lib/consul -client=192.168.50.130 -bind=192.168.50.130
    &>/var/log/consul.log &
    2.节点配置Docker守护进程连接Consul
    vi /lib/systemd/system/docker.service
    [Service]
    ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock --cluster-store
    consul://192.168.50.130:8500 --cluster-advertise 192.168.1.130:2375
     systemctl restart docker
    3.创建overlay网络
     docker network create -d overlay multi_host
    4.测试互通
     docker run -itd --net=multi_host busybox

     

    节点B192.168.50.131

     

    1.启动docker

    Systemctl start docker

    2.修改配置文件:vim /usr/lib/systemd/system/docker.service

    -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock --cluster-store consul:// 192.168.50.131:8500 --cluster-advertise 192.168.50.131:2375

    systemctl daemon-reload && systemctl restart docker

     

    就可以在consul ui上面看到新增加的节点了

     

    3.创建overlay网络:

    docker network create -d overlay multi_host(只要在一个节点创建,就会同步到其他节点,不需要在配置其他节点)

    4.测试互通:

      A B节点都启动一个容器

      docker run -it --rm=true  --net=multi_host mydockerfile /bin/bash

     

    ping overlay分配的网络

  • 相关阅读:
    剑指 Offer 55
    剑指 Offer 55
    剑指 Offer 22. 链表中倒数第k个节点
    剑指 Offer 29. 顺时针打印矩阵
    剑指 Offer 17. 打印从1到最大的n位数
    剑指 Offer 57
    剑指 Offer 59
    B. Han Solo and Lazer Gun 暴力 水
    C. Number of Ways 思维
    C. Destroying Array 并查集/线段树 Intel Code Challenge Elimination Round (Div. 1 + Div. 2, combined)
  • 原文地址:https://www.cnblogs.com/fuyuteng/p/9411145.html
Copyright © 2011-2022 走看看