使用docker配置etcd集群

docker配置etcd集群与直接部署etcd集群在配置上并没有什么太大差别。

我这里直接使用docker-compose来实现容器化的etcd部署

环境如下:

HostNameIP
etcd110.1.61.175
etcd210.1.61.176
etcd310.1.61.177

etcd1上的docker-compose.yaml内容如下:

version: "2"
services:
  etcd:
    image: hub.dz11.com/library/etcd-amd64:3.1.10
    restart: always
    network_mode: host
    volumes:
      - "/home/www/server/etcd:/data/etcd"
      - "/etc/localtime:/etc/localtime"
    environment:
      ETCDCTL_API: "3"
    command: etcd  -name etcd1 -data-dir /data/etcd -advertise-client-urls http://10.1.61.175:2379 -listen-client-urls http://10.1.61.175:2379,http://127.0.0.1:2379 -initial-advertise-peer-urls http://10.1.61.175:2380 -listen-peer-urls http://0.0.0.0:2380 -initial-cluster-token etcd-cluster-1 -initial-cluster etcd1=http://10.1.61.175:2380,etcd2=http://10.1.61.176:2380,etcd3=http://10.1.61.177:2380 -initial-cluster-state new

etcd2上的docker-compose.yaml内容如下:

version: "2"
services:
  etcd:
    image: hub.dz11.com/library/etcd-amd64:3.1.10
    restart: always
    network_mode: host
    volumes:
      - "/home/www/server/etcd:/data/etcd"
      - "/etc/localtime:/etc/localtime"
    environment:
      ETCDCTL_API: "3"
    command: etcd  -name etcd2 -data-dir /data/etcd -advertise-client-urls http://10.1.61.176:2379 -listen-client-urls http://10.1.61.176:2379,http://127.0.0.1:2379 -initial-advertise-peer-urls http://10.1.61.176:2380 -listen-peer-urls http://0.0.0.0:2380 -initial-cluster-token etcd-cluster-1 -initial-cluster etcd1=http://10.1.61.175:2380,etcd2=http://10.1.61.176:2380,etcd3=http://10.1.61.177:2380 -initial-cluster-state new

etcd3上的docker-compose.yaml内容如下:

version: "2"
services:
  etcd:
    image: dk-reg.op.douyuyuba.com/library/etcd-amd64:3.1.10
    restart: always
    network_mode: host
    volumes:
      - "/home/www/server/etcd:/data/etcd"
      - "/etc/localtime:/etc/localtime"
    environment:
      ETCDCTL_API: "3"
    command: etcd  -name etcd3 -data-dir /data/etcd -advertise-client-urls http://10.1.61.177:2379 -listen-client-urls http://10.1.61.177:2379,http://127.0.0.1:2379 -initial-advertise-peer-urls http://10.1.61.177:2380 -listen-peer-urls http://0.0.0.0:2380 -initial-cluster-token etcd-cluster-1 -initial-cluster etcd1=http://10.1.61.175:2380,etcd2=http://10.1.61.176:2380,etcd3=http://10.1.61.177:2380 -initial-cluster-state new

启动docker-compose:

docker-compose up -d 

转载于:https://www.cnblogs.com/breezey/p/8847418.html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值