Skip to content

Commit 6f80c1e

Browse files
authored
start conusl cluster
1 parent eaae438 commit 6f80c1e

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

shell/start_consul_by_docker.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh
2+
3+
function start_consul(){
4+
docker run --name consul1 -d -p 8500:8500 -p 8300:8300 -p 8301:8301 -p 8302:8302 -p 8600:8600 consul:latest agent -server -bootstrap-expect 2 -ui -bind=0.0.0.0 -client=0.0.0.0
5+
consul1_addr=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' consul1)
6+
for((i=1;i<=10;i++));
7+
do
8+
port=$((8500+$i))
9+
docker run --name consul${i} -d -p ${port}:8500 consul agent -server -ui -bind=0.0.0.0 -client=0.0.0.0 -join ${consul1_addr}
10+
done
11+
}
12+
13+
function check_consul(){
14+
docker ps | grep "consul" | grep -v grep
15+
docker exec -it consul1 "consul members"
16+
}
17+
18+
start_consul
19+
check_consul

0 commit comments

Comments
 (0)