From 2d51406fdd5ee0d9a4042c4efaa0c9e66a45eb43 Mon Sep 17 00:00:00 2001 From: zhongyh16 Date: Mon, 15 May 2017 15:26:25 +0800 Subject: [PATCH] update etcd-multi-nodes.sh --- tools/etcd-multi-nodes.sh | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/tools/etcd-multi-nodes.sh b/tools/etcd-multi-nodes.sh index 5cb14c2..23f7361 100755 --- a/tools/etcd-multi-nodes.sh +++ b/tools/etcd-multi-nodes.sh @@ -5,11 +5,13 @@ which etcd &>/dev/null || { echo "etcd not installed, please install etcd first" && exit 1; } if [ $# -eq 0 ] ; then - echo "Usage: `basename $0` ip1 ip2 ip3" + echo "Usage: `basename $0` index ip1 ip2 ip3" echo " ip1 ip2 ip3 are the ip address of node etcd_1 etcd_2 etcd_3" exit 1 fi +etcdindex=etcd_$1 +shift etcd_1=$1 index=1 while [ $# -gt 0 ] ; do @@ -32,11 +34,20 @@ done # -initial-cluster-state : new means join a new cluster; existing means join an existing cluster # : new not means clear -etcd --name etcd_1 \ - --initial-advertise-peer-urls http://$etcd_1:2380 \ - --listen-peer-urls http://$etcd_1:2380 \ - --listen-client-urls http://$etcd_1:2379 \ - --advertise-client-urls http://$etcd_1:2379 \ +depdir=${0%/*} +tempdir=/opt/docklet/local +[ ! -d $tempdir/log ] && mkdir -p $tempdir/log +[ ! -d $tempdir/run ] && mkdir -p $tempdir/run + +etcd --name $etcdindex \ + --initial-advertise-peer-urls http://$etcdindex:2380 \ + --listen-peer-urls http://$etcdindex:2380 \ + --listen-client-urls http://$etcdindex:2379 \ + --advertise-client-urls http://$etcdindex:2379 \ --initial-cluster-token etcd-cluster \ --initial-cluster $CLUSTER \ --initial-cluster-state new + +etcdpid=$! +echo "etcd start with pid: $etcdpid and log:$tempdir/log/etcd.log" +echo $etcdpid > $tempdir/run/etcd.pid