forked from jazzwang/hicloud-hadoop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-ubuntu
executable file
·56 lines (49 loc) · 1.94 KB
/
install-ubuntu
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
#!/bin/bash
### Check Configuration Files ###
if [ ! -f $(pwd)/conf/master ]; then
echo "ERROR: missing configuration file: conf/master"; exit;
fi
if [ ! -f $(pwd)/conf/slave ]; then
echo "ERROR: missing configuration file: conf/slave"; exit;
fi
### Variables ###
NN_IP=$(cat $(pwd)/conf/master | awk '{ print $1 }')
DN_IP=$(cat $(pwd)/conf/slave | awk '{ print $1 }')
### Stage 1 : root SSH Key Exchange ###
cat $(pwd)/conf/master | while read line; do $(pwd)/bin/ssh-cp-id $line; done
cat $(pwd)/conf/slave | while read line; do $(pwd)/bin/ssh-cp-id $line; done
### Stage 1.5 : modify config for SSHD and restart it ###
echo "modifying config for sshd and restart sshd at $NN_IP"
ssh "root@$NN_IP" "(echo \"useDNS no\" >> /etc/ssh/sshd_config && service ssh restart)"
for i in $DN_IP; do
echo "modifying config for sshd and restart sshd at $i"
ssh "root@$i" "(echo \"useDNS no\" >> /etc/ssh/sshd_config && service ssh restart)"
done
### Stage 2 : setup /etc/hostname ###
echo "setting hostname of $NN_IP to hadoop"
ssh "root@$NN_IP" "echo \"hadoop\" > /etc/hostname"
ssh "root@$NN_IP" "hostname -F /etc/hostname"
echo "$NN_IP hadoop" > hosts
ID=1
#echo "" > $HOME/.dsh/machines.list
for i in $DN_IP; do
echo "setting hostname of $i to node$ID"
ssh "root@$i" "echo \"node$ID\" > /etc/hostname"
ssh "root@$i" "hostname -F /etc/hostname"
echo "$i node$ID" >> hosts
ID=$(($ID+1))
done
### Stage 3 : setup /etc/hosts ###
echo "copying /etc/hosts for all hosts"
scp hosts root@$NN_IP:/etc/hosts
scp $HOME/.ssh/id_rsa root@$NN_IP:.ssh/.
for i in $DN_IP; do scp hosts root@$i:/etc/hosts; scp $HOME/.ssh/id_rsa root@$i:.ssh/.; done
rm hosts
### Stage 3 : install JDK, Hadoop CHD3, ganglia ###
scp $(pwd)/bin/install-hadoop-nn root@$NN_IP:.
ssh root@$NN_IP /root/install-hadoop-nn
for i in $DN_IP; do
scp $(pwd)/bin/install-hadoop-dn root@$i:.
ssh root@$i /root/install-hadoop-dn
done
echo "Please check http://$NN_IP:50070 and http://$NN_IP:50030 for the status"