-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·66 lines (48 loc) · 1.36 KB
/
run.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
echo "Creating docker machine using virtualbox driver..."
docker-machine create --driver virtualbox vbk
docker-machine env vbk
eval $(docker-machine env vbk)
echo "docker machine created"
echo "Creating Image..."
cd master
docker build -t hd/master .
cd ..
cd slave
docker build -t hd/slave .
cd ..
echo "Image created for master and slave"
#docker images
echo "Creating network"
docker network create vbknetwork
echo "Starting master..."
docker run -itd --net=vbknetwork --name master -h master hd/master /etc/bootstrap.sh -bash
echo "Container started with name 'master'"
N=4
i=0
while [ $i -lt $N ]
do
echo "Start slave$i container..."
docker run -itd --net=vbknetwork --name slave$i -h slave$i hd/slave /etc/bootstrap.sh -d
i=$(( $i + 1 ))
done
echo "Containers created."
#docker ps -a
echo "Waiting for 60 seconds for Hadoop Cluster to setup and HDFS to synchronize..."
sleep 60
docker exec -it master /bin/bash /usr/local/hadoop/bin/hdfs dfsadmin -report
docker exec -it master /bin/bash /usr/local/hadoop/runjob.sh
echo "Stopping and cleaning up containers..."
docker stop slave0
docker rm -f slave0
docker stop slave1
docker rm -f slave1
docker stop slave2
docker rm -f slave2
docker stop slave3
docker rm -f slave3
docker stop master
docker rm -f master
docker network rm vbknetwork
#docker-machine stop vbk
#docker-machine rm -y vbk
echo "Done. Bye!"