source: drbl-hadoop-live/chroot-hook/install-hadoop @ 200

Last change on this file since 200 was 150, checked in by jazz, 14 years ago
  • modified test-live-helper.sh
    • add chroot hook to install jdk and hadoop
  • add hook/install-hadoop
    • chroot hook for jdk and hadoop
  • add Makefile
    • some simple rules for build and clean
  • Property svn:executable set to *
File size: 3.8 KB
Line 
1#!/bin/bash
2echo "---- Runninig scripts in root_local-hooks ----"
3echo "---- [1] Installing Sun Java JDK 6 ........ ----"
4echo "deb http://free.nchc.org.tw/debian lenny non-free" > lenny-non-free.list
5mv lenny-non-free.list /etc/apt/sources.list.d/.
6apt-get update
7cat << EOF | /usr/bin/debconf-set-selections
8sun-java6-bin   shared/accepted-sun-dlj-v1-1    select true
9sun-java6-jdk   shared/accepted-sun-dlj-v1-1    select true
10sun-java6-jre   shared/accepted-sun-dlj-v1-1    select true
11EOF
12apt-get -y install sun-java6-jdk
13
14echo "---- [2] Installing Hadoop 0.20.2 ........ ----"
15cd /opt
16{
17  if [ ! -x /opt/hadoop ]; then
18    wget http://ftp.twaren.net/Unix/Web/apache/hadoop/core/hadoop-0.20.2/hadoop-0.20.2.tar.gz
19    tar zxvf hadoop-0.20.2.tar.gz
20    rm -f hadoop-0.20.2.tar.gz
21    mv hadoop-0.20.2/ hadoop
22    chown -R hadoop:hadoop /opt/hadoop
23    if [ ! -x /var/hadoop ]; then
24      mkdir -p /var/hadoop
25      chown -R hadoop:hadoop /var/hadoop
26    fi
27  fi
28}
29
30if [ ! -x /opt/hadoop ]; then
31  echo "---- [ERROR] /opt/hadoop is not exist!! ----"; exit;
32else
33  echo "---- [3] Configure Hadoop NameNode and JobTracker .... ----"
34  cd /opt/hadoop
35  {
36    if [ ! -f /opt/hadoop/conf/hadoop-env.sh ]; then
37      echo "---- [ERROR] /opt/hadoop/conf/hadoop-env.sh is not exist!!  ----"; exit
38    else
39      if [ ! -f /opt/hadoop/conf/hadoop-env.sh.org ]; then
40        echo "---- [3.1] Updating /opt/hadoop/conf/hadoop-env.sh ....  ----"
41        cp /opt/hadoop/conf/hadoop-env.sh /opt/hadoop/conf/hadoop-env.sh.org
42        cat >> conf/hadoop-env.sh << EOF
43export JAVA_HOME=/usr/lib/jvm/java-6-sun
44export HADOOP_HOME=/opt/hadoop
45export HADOOP_CONF_DIR=/opt/hadoop/conf
46EOF
47      fi
48    fi
49
50    if [ ! -f /opt/hadoop/conf/core-site.xml ]; then
51      echo "---- [ERROR] /opt/hadoop/conf/core-site.xml is not exist!!  ----"; exit
52    else
53      if [ ! -f /opt/hadoop/conf/core-site.xml.org ]; then
54        echo "---- [3.2] Updating /opt/hadoop/conf/core-site.xml ....  ----"
55        cp /opt/hadoop/conf/core-site.xml /opt/hadoop/conf/core-site.xml.org
56        cat > conf/core-site.xml << EOF
57<?xml version="1.0"?>
58<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
59<configuration>
60  <property>
61    <name>fs.default.name</name>
62    <value>hdfs://localhost:9000</value>
63  </property>
64  <property>
65    <name>hadoop.tmp.dir</name>
66    <value>/var/hadoop/hadoop-\${user.name}</value>
67  </property>
68</configuration>
69EOF
70      fi
71    fi
72
73    if [ ! -f /opt/hadoop/conf/hdfs-site.xml ]; then
74      echo "---- [ERROR] /opt/hadoop/conf/hdfs-site.xml is not exist!!  ----"; exit
75    else
76      if [ ! -f /opt/hadoop/conf/hdfs-site.xml.org ]; then
77        echo "---- [3.3] Updating /opt/hadoop/conf/hdfs-site.xml ....  ----"
78        cp /opt/hadoop/conf/hdfs-site.xml /opt/hadoop/conf/hdfs-site.xml.org
79        cat > conf/hdfs-site.xml << EOF
80<?xml version="1.0"?>
81<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
82<configuration>
83  <property>
84    <name>dfs.replication</name>
85    <value>1</value>
86  </property>
87</configuration>
88EOF
89      fi
90    fi
91
92    if [ ! -f /opt/hadoop/conf/mapred-site.xml ]; then
93      echo "---- [ERROR] /opt/hadoop/conf/mapred-site.xml is not exist!!  ----"; exit
94    else
95      if [ ! -f /opt/hadoop/conf/mapred-site.xml.org ]; then
96        echo "---- [3.3] Updating /opt/hadoop/conf/mapred-site.xml ....  ----"
97        cp /opt/hadoop/conf/mapred-site.xml /opt/hadoop/conf/mapred-site.xml.org
98        cat > conf/mapred-site.xml << EOF
99<?xml version="1.0"?>
100<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
101<configuration>
102  <property>
103    <name>mapred.job.tracker</name>
104    <value>localhost:9001</value>
105  </property>
106</configuration>
107EOF
108      fi
109    fi
110
111    if [ ! -d /var/hadoop/hadoop-root/dfs/name ]; then
112      echo "---- [3.4] Formating NameNode ....  ----"
113      bin/hadoop namenode -format
114    fi
115  }
116fi
Note: See TracBrowser for help on using the repository browser.