-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-cluster.sh
executable file
·44 lines (38 loc) · 1.18 KB
/
run-cluster.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
#!/bin/bash
# the default node number is 3
N=${1:-3}
echo "check docker network."
if ! docker network ls | grep -q 'hadoop'; then
echo " - create docker network."
docker network create --driver=bridge hadoop
else
echo " - exist hadoop network"
fi
# start hadoop master container
echo " - remove exist hadoop-master container..."
docker rm -f hadoop-master &> /dev/null
echo " + start hadoop-master container..."
docker run -itd \
--net=hadoop \
-p 50070:50070 \
-p 8088:8088 \
-p 9000:9000 \
--name hadoop-master \
--hostname hadoop-master \
hadoop:latest &> /dev/null
# start hadoop slave container
i=1
while [ $i -lt $N ]
do
echo " - remove exist hadoop-slave$i container..."
docker rm -f hadoop-slave$i &> /dev/null
echo " + start hadoop-slave$i container..."
docker run -itd \
--net=hadoop \
--name hadoop-slave$i \
--hostname hadoop-slave$i \
hadoop:latest &> /dev/null
i=$(( $i + 1 ))
done
# get into hadoop master container
docker exec -it hadoop-master bash /usr/local/hadoop/bootstrap.sh