docker-compose安装etcd

1、下载docker-compose
wget https://github.com/docker/compose/releases/download/v2.6.0/docker-compose-linux-x86_64
mv docker-compose-linux-x86_64  docker-compose
chmod u+x docker-compose
2、创建etcd数据目录(根据自己需求修改)
mkdir -p /app/apisix/etcd/data
3、创建yaml配置文件
[root@localhost etcd]# more docker-compose.yaml
version: "3.5"
services:
  etcd:
    hostname: etcd
    image: bitnami/etcd:3
    deploy:
      replicas: 1
      restart_policy:
        condition: on-failure
    # ports:
    #   - "2379:2379"
    #   - "2380:2380"
    #   - "4001:4001"
    #   - "7001:7001"
    privileged: true
    volumes:
      - "/app/apisix/etcd/data:/bitnami/etcd/data"
    environment:
      - "ETCD_ADVERTISE_CLIENT_URLS=http://0.0.0.0:2379"
      - "ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379"
      - "ETCD_LISTEN_PEER_URLS=http://0.0.0.0:2380"
      - "ETCD_INITIAL_ADVERTISE_PEER_URLS=http://0.0.0.0:2380"
      #参数指不用密码可以连接
      - "ALLOW_NONE_AUTHENTICATION=yes"
      - "ETCD_INITIAL_CLUSTER=node1=http://0.0.0.0:2380"
      - "ETCD_NAME=node1"
      - "ETCD_DATA_DIR=/opt/bitnami/etcd/data"
    ports:
      - 2379:2379
      - 2380:2380
    networks:
      - etcdnet

networks:
  etcdnet:
    name: etcdnet
4、启动、停止etcd
[root@localhost etcd]# ./docker-compose up -d
[root@localhost etcd]# ./docker-compose down
5、查看etcd数据
[root@localhost snap]# pwd
/app/apisix/etcd/data/member/snap
[root@localhost snap]# strings db 

 6、安装etcd可视化工具etcdkeeper

docker run -it -d --name etcdkeeper \
-p 8080:8080 \
deltaprojects/etcdkeeper

 

 

posted @ 2022-06-16 14:44  苍茫宇宙  阅读(2086)  评论(0编辑  收藏  举报