1 | #!/bin/bash |
---|
2 | mkdir -p /lib/jvm |
---|
3 | mkdir -p /opt |
---|
4 | |
---|
5 | if [ ! -x /lib/jvm/jdk* ]; then |
---|
6 | echo "Installing Sun JDK ...." |
---|
7 | unzip /usr/src/jdk*.zip -d /lib/jvm/ |
---|
8 | fi |
---|
9 | |
---|
10 | if [ ! -x /opt/hadoop ]; then |
---|
11 | echo "Installing Hadoop ...." |
---|
12 | tar zxvf /usr/src/hadoop-*.tar.gz -C /opt/ |
---|
13 | mv /opt/hadoop-* /opt/hadoop |
---|
14 | cp -R /usr/src/conf-examples/ /opt/hadoop/conf-pseudo |
---|
15 | mv /opt/hadoop/conf/ /opt/hadoop/conf-local |
---|
16 | ln -s /opt/hadoop/conf-pseudo /opt/hadoop/conf |
---|
17 | fi |
---|
18 | |
---|
19 | export JAVA_HOME=$(dirname /lib/jvm/jdk*/bin/) |
---|
20 | echo export JAVA_HOME=$JAVA_HOME >> /opt/hadoop/conf/hadoop-env.sh |
---|
21 | echo export HADOOP_HOME=/opt/hadoop >> /opt/hadoop/conf/hadoop-env.sh |
---|
22 | echo export HADOOP_CLASSPATH=/opt/hadoop >> /opt/hadoop/conf/hadoop-env.sh |
---|
23 | echo export HADOOP_CONF_DIR=/opt/hadoop/conf >> /opt/hadoop/conf/hadoop-env.sh |
---|
24 | echo export JAVA_HOME=$JAVA_HOME >> /etc/profile |
---|
25 | echo "export PATH=/opt/hadoop/bin/:$JAVA_HOME/bin:\$PATH" >> /etc/profile |
---|
26 | cd $JAVA_HOME |
---|
27 | chmod a+x `find . -name "*.exe"` |
---|
28 | chmod a+x `find . -name "*.dll"` |
---|
29 | cd /opt/hadoop |
---|
30 | /opt/hadoop/bin/hadoop namenode -format |
---|
31 | source /etc/profile |
---|
32 | /bin/start-hadoop |
---|
33 | sleep 10 |
---|
34 | /opt/hadoop/bin/hadoop dfsadmin -safemode leave |
---|
35 | /opt/hadoop/bin/hadoop fs -mkdir tmp |
---|
36 | echo "/bin/stop-hadoop" > ~/.bash_logout |
---|
37 | echo "/bin/stop-hadoop" > /etc/skel/.bash_logout |
---|
38 | cygstart http://localhost:50070 |
---|
39 | cygstart http://localhost:50030 |
---|
40 | exit |
---|