forked from kiwenlau/hadoop-cluster-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
12 additions
and
291 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,24 @@ | ||
#!/bin/bash | ||
|
||
# run N slave containers | ||
N=$1 | ||
# run N slave containers, the default valume is 3 | ||
N=${1:-3} | ||
|
||
# the defaut node number is 3 | ||
if [ $# = 0 ] | ||
then | ||
N=3 | ||
fi | ||
|
||
|
||
# delete old master container and start new master container | ||
sudo docker rm -f master &> /dev/null | ||
echo "start master container..." | ||
sudo docker run -d -t --dns 127.0.0.1 -P --name master -h master.kiwenlau.com -w /root kiwenlau/hadoop-master:0.1.0 &> /dev/null | ||
# start hadoop master container | ||
sudo docker rm -f hadoop-master > /dev/null | ||
echo "start hadoop-master container..." | ||
sudo docker run -d -t -P --name hadoop-master -h master.kiwenlau.com -w /root --net=hadoop kiwenlau/hadoop-master:1.0.0 &> /dev/null | ||
|
||
# get the IP address of master container | ||
FIRST_IP=$(sudo docker inspect --format="{{.NetworkSettings.IPAddress}}" master) | ||
FIRST_IP=$(sudo docker inspect --format="{{.NetworkSettings.IPAddress}}" hadoop-master) | ||
|
||
# delete old slave containers and start new slave containers | ||
# start hadoop slave container | ||
i=1 | ||
while [ $i -lt $N ] | ||
do | ||
sudo docker rm -f slave$i &> /dev/null | ||
echo "start slave$i container..." | ||
sudo docker run -d -t --dns 127.0.0.1 -P --name slave$i -h slave$i.kiwenlau.com -e JOIN_IP=$FIRST_IP kiwenlau/hadoop-slave:0.1.0 &> /dev/null | ||
sudo docker rm -f hadoop-slave$i > /dev/null | ||
echo "start hadoop-slave$i container..." | ||
sudo docker run -d -t -P --name hadoop-slave$i -h slave$i.kiwenlau.com --net=hadoop kiwenlau/hadoop-slave:1.0.0 &> /dev/null | ||
i=$(( $i + 1 )) | ||
done | ||
|
||
|
||
# create a new Bash session in the master container | ||
sudo docker exec -it master bash | ||
# sudo docker exec -it hadoop-master bash |