[ etcd部署[docker-compose] ]


部署文件

version: '3'
services:
  etcd-s1:
    image: quay.io/coreos/etcd:v3.5.9 
    restart: always
    environment:
      - ALLOW_NONE_AUTHENTICATION=yes
      - ETCD_CONFIG_FILE=/etcd-conf/conf1.yaml
    ports:
      - 2380:2380
      - 2379:2379
    volumes:
      - ./s1-data:/etcd-data
      - ./conf:/etcd-conf
    container_name: etcd-s1

  etcd-s2:
    image: quay.io/coreos/etcd:v3.5.9 
    restart: always
    environment:
      - ALLOW_NONE_AUTHENTICATION=yes
      - ETCD_CONFIG_FILE=/etcd-conf/conf2.yaml
    ports:
      - 12380:2380
      - 12379:2379
    volumes:
      - ./s2-data:/etcd-data
      - ./conf:/etcd-conf
    container_name: etcd-s2

多节点失败

使用单节点

docker-compose.yml

version: '3'
services:
  etcd-s1:
    image: quay.io/coreos/etcd:v3.5.9 
    restart: always
    environment:
      - ALLOW_NONE_AUTHENTICATION=yes
      - ETCD_CONFIG_FILE=/etcd-conf/conf1.yaml
    ports:
      - 2380:2380
      - 2379:2379
    volumes:
      - ./s1-data:/etcd-data
      - ./conf:/etcd-conf

conf1.yaml

name: "s1"

# 数据存储目录
data-dir: "/etcd-data"

# 集群提供给外部客户端访问的url, 即外部客户端必须通过指定
listen-client-urls: "http://0.0.0.0:2379"

# 想客户端发布的服务端点
advertise-client-urls: "http://47.120.55.99:2379"

# 集群成员之间通信使用的url
listen-peer-urls: "http://0.0.0.0:2380"

# 集群配置 
initial-advertise-peer-urls: "http://47.120.55.99:2380"

# 集群成员配置
initial-cluster: "s1=http://47.120.55.99:2380"

# 引导期间etcd集群的初始集群令牌
initial-cluster-token: "tkn"

# 初始化集群状态(new:新增 或者 existing: 加入已存在)
initial-cluster-state: "new"

# 日志级别
log-level: "info"

# 压缩
logger: "zap"
log-outputs:
 - "stderr"