etcd单机集群

etcd在单机部署集群,可以先弄清楚配置文件参数的意思。起3个集成监听不同的端口号

1. 启动

在/etc/soft/etcd/node1文件夹中,创建脚本start1.sh

etcd --name infra1 --initial-advertise-peer-urls http://127.0.0.1:2381 \
  --listen-peer-urls http://127.0.0.1:2381 \
    --listen-client-urls http://127.0.0.1:2379 \
          --advertise-client-urls http://127.0.0.1:2379 \
            --initial-cluster-token etcd-cluster-1 \
                  --initial-cluster infra1=http://127.0.0.1:2381,infra2=http://127.0.0.1:2382,infra3=http://127.0.0.1:2383 \
                    --initial-cluster-state new

在/etc/soft/etcd/node2文件夹中,创建脚本start2.sh

etcd --name infra2 --initial-advertise-peer-urls http://127.0.0.1:2382 \
  --listen-peer-urls http://127.0.0.1:2382 \
    --listen-client-urls http://127.0.0.1:2378 \
          --advertise-client-urls http://127.0.0.1:2378 \
            --initial-cluster-token etcd-cluster-1 \
                  --initial-cluster infra1=http://127.0.0.1:2381,infra2=http://127.0.0.1:2382,infra3=http://127.0.0.1:2383 \
                    --initial-cluster-state new

在/etc/soft/etcd/node3文件夹中,创建脚本start3.sh

etcd --name infra3 --initial-advertise-peer-urls http://127.0.0.1:2383 \
  --listen-peer-urls http://127.0.0.1:2383 \
    --listen-client-urls http://127.0.0.1:2377 \
          --advertise-client-urls http://127.0.0.1:2377 \
            --initial-cluster-token etcd-cluster-1 \
                  --initial-cluster infra1=http://127.0.0.1:2381,infra2=http://127.0.0.1:2382,infra3=http://127.0.0.1:2383 \
                    --initial-cluster-state new

分别运行三个脚本

2. 检查集群是否启动成功

etcdctl --endpoint "http://127.0.0.1:2379" member list
19ac17627e3e396f: name=infra2 peerURLs=http://127.0.0.1:2382 clientURLs=http://127.0.0.1:2378 isLeader=false
8f65a5fdd9ee42ad: name=infra3 peerURLs=http://127.0.0.1:2383 clientURLs=http://127.0.0.1:2377 isLeader=true
e7b968b9fb1bc003: name=infra1 peerURLs=http://127.0.0.1:2381 clientURLs=http://127.0.0.1:2379 isLeader=false
etcdctl cluster-health
member 19ac17627e3e396f is healthy: got healthy result from http://127.0.0.1:2378
member 8f65a5fdd9ee42ad is healthy: got healthy result from http://127.0.0.1:2377
member e7b968b9fb1bc003 is healthy: got healthy result from http://127.0.0.1:2379

3个节点启动完成

 

posted on 2018-04-02 22:53  luckygxf  阅读(695)  评论(0编辑  收藏  举报

导航