#!/bin/bash
/etc/init.d/ssh restart
echo 1 > /proc/sys/vm/drop_caches
echo "StrictHostKeyChecking no" >> /etc/ssh/ssh_config
echo "deb http://free.nchc.org.tw/debian lenny non-free" > /etc/apt/sources.list.d/lenny-nonfree.list
echo "deb http://www.classcloud.org unstable main" > /etc/apt/sources.list.d/hadoop.list
apt-get update
apt-get clean
apt-get -y --force-yes install hadoop
apt-get -y remove --purge libavahi-common3
apt-get -y autoremove --purge
apt-get -y remove --purge dbus gsfonts
apt-get clean
rm -rf /var/lib/apt/list/*
rm -rf /var/lib/aptitude/
su -c /opt/hadoop/bin/stop-all.sh hdfsadm -
cat > /etc/hadoop/hadoop-site.xml << EOF
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<!-- Put site-specific property overrides in this file. -->

<configuration>
  <property>
    <name>fs.default.name</name>
    <value>192.168.200.254:9000</value>
    <description>
      The name of the default file system. Either the literal string
      "local" or a host:port for NDFS.
    </description>
  </property>
  <property>
    <name>mapred.job.tracker</name>
    <value>192.168.200.254:9001</value>
  </property>
  <property>
    <name>dfs.name.dir</name>
    <value>/home/hdfsadm/dfs/name</value>
  </property>
</configuration>
EOF
su -c "/opt/hadoop/bin/hadoop namenode -format" hdfsadm -
for ((i=1;i<=2;i++)); do echo "192.168.200.$i" >> /etc/hadoop/slaves; done
#for ((i=1;i<=40;i++)); do echo "192.168.200.$i" >> /etc/hadoop/slaves; done
/opt/drbl/sbin/drbl-live.sh start

