docker compose部署etcd
环境:
OS:Centos 7
etcd:3.5.5
1.创建目录
mkdir -p /opt/etcd
2.进入目录创建yml文件
cd /opt/etcd
vi docker-compose.yml
version: "3"
services:
etcd:
container_name: etcd
hostname: etcd
image: registry.cn-shenzhen.aliyuncs.com/hxlk8s/etcd:v3.5.5
volumes:
- "./etcd/data:/bitnami/etcd/data"
environment:
- ALLOW_NONE_AUTHENTICATION=yes
- ETCD_ADVERTISE_CLIENT_URLS=http://0.0.0.0:2379
- ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379
ports:
- 2379:2379
- 2380:2380
3.启动
cd /opt/etcd
docker compose up -d
4.重新部署命令
docker compose down
docker compose up -d
5.启停命令
docker compose stop
docker compose start
6.下载客户端
wget https://github.com/etcd-io/etcd/releases/download/v3.5.5/etcd-v3.5.5-linux-amd64.tar.gz
[root@node2 soft]# cd /soft
[root@node2 soft]# tar -xvf etcd-v3.5.5-linux-amd64.tar.gz
[root@node2 soft]# cd etcd-v3.5.5-linux-amd64
7.验证使用
[root@node2 etcd-v3.5.5-linux-amd64]# ./etcdctl member list
8e9e05c52164694d, started, default, http://localhost:2380, http://0.0.0.0:2379, false
[root@node2 etcd-v3.5.5-linux-amd64]# ./etcdctl -w table --endpoints=192.168.1.106:2379 endpoint health
+--------------------+--------+------------+-------+
| ENDPOINT | HEALTH | TOOK | ERROR |
+--------------------+--------+------------+-------+
| 192.168.1.106:2379 | true | 3.860335ms | |
+--------------------+--------+------------+-------+
[root@node2 etcd-v3.5.5-linux-amd64]# ./etcdctl put mykey "test"
OK
[root@node2 etcd-v3.5.5-linux-amd64]# ./etcdctl get mykey
mykey
test
[root@node2 etcd-v3.5.5-linux-amd64]#