-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathetcd.sh
executable file
·95 lines (71 loc) · 3.3 KB
/
etcd.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash
# Created by martin on 24/01/2019
set -e
pushd $(dirname $0) > /dev/null
SCRIPTPATH=$(pwd -P)
popd > /dev/null
SCRIPTFILE=$(basename $0)
function log() {
echo "================================================================================"
echo "$(date +'%Y-%m-%d %H:%M:%S%z') [INFO] - $@"
echo ""
}
function err() {
echo "================================================================================"
echo "$(date +'%Y-%m-%d %H:%M:%S%z') [ERRO] - $@" >&2
}
# initial-advertise-peer-urls 对等节点接受消息的url 发送
# listen-peer-urls 接受对等节点的消息的url 接受
function run() {
docker run -d -p 4001:4001 -p 2380:2380 -p 2379:2379 --name etcd quay.io/coreos/etcd:v3.3.10 etcd -name etcd0 \
-initial-advertise-peer-urls http://0.0.0.0:2380 \
-listen-peer-urls http://0.0.0.0:2380 \
-listen-client-urls http://0.0.0.0:2379,http://127.0.0.1:2379 \
-advertise-client-urls http://0.0.0.0:2379 \
-initial-cluster-token etcd-cluster-1 \
-initial-cluster etcd0=http://0.0.0.0:2380,etcd0=http://0.0.0.0:2381,etcd0=http://0.0.0.0:2382 \
-initial-cluster-state new
}
function run2(){
docker run -d -p 4001:4001 -p 2380:2380 -p 2379:2379 --name etcd quay.io/coreos/etcd:v3.3.10 etcd -name etcd0 \
-advertise-client-urls http://192.168.0.105:2379,http://192.168.0.105:4001 \
-listen-client-urls http://0.0.0.0:2379,http://0.0.0.0:4001 \
-initial-advertise-peer-urls http://192.168.0.105:2380 \
-listen-peer-urls http://0.0.0.0:2380 \
-initial-cluster-token etcd-cluster-1 \
-initial-cluster etcd0=http://192.168.0.105:2380,etcd1=http://192.168.0.117:2380,etcd2=http://192.168.0.198:2380 \
-initial-cluster-state new
}
function run2(){
docker run -d -p 4001:4001 -p 2380:2380 -p 2379:2379 --name etcd quay.io/coreos/etcd:v3.3.10 etcd -name etcd1 \
-advertise-client-urls http://192.168.0.117:2379,http://192.168.0.117:4001 \
-listen-client-urls http://0.0.0.0:2379,http://0.0.0.0:4001 \
-initial-advertise-peer-urls http://192.168.0.117:2380 \
-listen-peer-urls http://0.0.0.0:2380 \
-initial-cluster-token etcd-cluster-1 \
-initial-cluster etcd0=http://192.168.0.105:2380,etcd1=http://192.168.0.117:2380,etcd2=http://192.168.0.198:2380\
-initial-cluster-state new
}
function run3(){
docker run -d -p 4001:4001 -p 2380:2380 -p 2379:2379 --name etcd quay.io/coreos/etcd:v3.3.10 etcd -name etcd2 \
-advertise-client-urls http://192.168.0.198:2379,http://192.168.0.198:4001 \
-listen-client-urls http://0.0.0.0:2379,http://0.0.0.0:4001 \
-initial-advertise-peer-urls http://192.168.0.198:2380 \
-listen-peer-urls http://0.0.0.0:2380 \
-initial-cluster-token etcd-cluster-1 \
-initial-cluster etcd0=http://192.168.0.105:2380,etcd1=http://192.168.0.117:2380,etcd2=http://192.168.0.198:2380\
-initial-cluster-state new
}
function runWithConfig(){
docker run -d -p 4001:4001 -p 2380:2380 -p 2379:2379 --name etcd quay.io/coreos/etcd:v3.3.10 etcd --config-file = "./etcd.yml"
}
#ps -ef |grep zookeeper 这个就是看zookeeper的启动情况
#grep -v "grep" 是为了去掉查询 grep的那一条
#wc -l 是计数的
COUNT=$(ps -ef |grep zokeeper |grep -v "grep" |wc -l)
echo $COUNT
if [ $COUNT -eq 0 ]; then
echo NOT RUN
else
echo is RUN
fi