-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathadd-node.sh
More file actions
executable file
·55 lines (44 loc) · 1.12 KB
/
Copy pathadd-node.sh
File metadata and controls
executable file
·55 lines (44 loc) · 1.12 KB
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
#!/bin/bash
# adds a node in a running hadoop cluster
# Run this script on Master
# takes first argument as the ip_address/name of the node to be added
if [ "$#" -ne 1 ]; then
echo "Usage: $0 [options] Node_IP" >&2
exit 1
fi
DFS_ONLY=0
MAPREDUCE_ONLY=0
INSTALL_DIR=/usr/local
while getopts "md" opt; do
case $opt in
m ) MAPREDUCE_ONLY=1
;;
d ) DFS_ONLY=1;;
\?) echo "Invalid Option: $OPTARG"
usage
exit 1
;;
esac
done
# Node reachable ?
echo "Checking connectivity to the node..."
ping $1 -c 5
if [ "$?" -ne 0 ]; then
echo "Ping to the node $1 Failed. Check the node connectivity and try again" >&2
exit 1
fi
#cd /usr/local/hadoop/conf
#echo $1 >> slaves
# copy hadoop
rsync -vaz --exclude='logs/*' /usr/local/hadoop $1:/usr/local/
#refresh nodelist
if [ $MAPREDUCE_ONLY -eq 0 ] ;then
$INSTALL_DIR/hadoop/bin/hadoop mradmin -refreshNodes
ssh $1 "$INSTALL_DIR/hadoop/bin/hadoop-daemon.sh start tasktracker"
fi
if [ $MAPREDUCE_ONLY -eq 0 ] ;then
$INSTALL_DIR/hadoop/bin/hadoop dfsadmin -refreshNodes
ssh $1 "$INSTALL_DIR/hadoop/bin/hadoop-daemon.sh start datanode"
fi
# verify
ssh $1 "jps"