-
Notifications
You must be signed in to change notification settings - Fork 0
/
stop.sh
94 lines (70 loc) · 1.77 KB
/
stop.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/bash
USERNAME=achla
#loading namenode config
file="config/namenode.properties"
if [ -f "$file" ]
then
echo "$file found."
while IFS='=' read -r key value
do
key=$(echo $key)
eval ${key}=\${value}
done < "$file"
echo "User Id = " ${ip}
echo "user password = " ${port}
else
echo "$file not found."
fi
NAMENODE_HOST=${ip}
NAMENODE_PORT=${port}
#stop nameNode
SCRIPT="fuser -k ${NAMENODE_PORT}/tcp"
ssh -l ${USERNAME} ${NAMENODE_HOST} "${SCRIPT}"
#loading namenode config
file="config/ressourcemanager.properties"
if [ -f "$file" ]
then
echo "$file found."
while IFS='=' read -r key value
do
key=$(echo $key)
eval ${key}=\${value}
done < "$file"
echo "User Id = " ${ip}
echo "user password = " ${port}
else
echo "$file not found."
fi
RM_HOST=${ip}
RM_PORT=${port}
#stop nameNode
SCRIPT="fuser -k ${RM_PORT}/tcp"
ssh -l ${USERNAME} ${RM_HOST} "${SCRIPT}"
#loading datanodes config
filename=config/datanodes.properties
hostArr=($(grep "host" $filename))
portArr=($(grep "port" $filename))
NB_HOSTS=${#hostArr[@]}
#stop datanodes
SCRIPT="fuser -k"
for (( i=0; i<${NB_HOSTS}; i++ ))
do
hostVal=$(cut -d"=" -f2 <<< ${hostArr[i]})
portVal=$(cut -d"=" -f2 <<< ${portArr[i]})
ssh -l ${USERNAME} ${hostVal} "${SCRIPT} ${portVal}/tcp"
done
#loading daemons config
filename=config/nodemanagers.properties
hostDArr=($(grep "host" $filename))
portDArr=($(grep "port" $filename))
nameDArr=($(grep "name" $filename))
NB_DHOSTS=${#hostArr[@]}
#stop datanodes
SCRIPT="fuser -k"
for (( i=0; i<${NB_HOSTS}; i++ ))
do
hostDVal=$(cut -d"=" -f2 <<< ${hostDArr[i]})
portDVal=$(cut -d"=" -f2 <<< ${portDArr[i]})
nameDVal=$(cut -d"=" -f2 <<< ${nameDArr[i]})
ssh -l ${USERNAME} ${hostDVal} "${SCRIPT} ${portDVal}/tcp"
done