[129] | 1 | #!/bin/bash |
---|
| 2 | mkdir -p /lib/jvm |
---|
| 3 | mkdir -p /opt |
---|
[143] | 4 | |
---|
[129] | 5 | if [ ! -x /lib/jvm/jdk* ]; then |
---|
[241] | 6 | echo "Installing Sun JDK ...." |
---|
[129] | 7 | unzip /usr/src/jdk*.zip -d /lib/jvm/ |
---|
| 8 | fi |
---|
[143] | 9 | |
---|
[129] | 10 | if [ ! -x /opt/hadoop ]; then |
---|
[241] | 11 | echo "Installing Hadoop ...." |
---|
[129] | 12 | tar zxvf /usr/src/hadoop-*.tar.gz -C /opt/ |
---|
[241] | 13 | mv /opt/hadoop-* /opt/hadoop |
---|
[242] | 14 | cp /opt/hadoop/conf/ /opt/hadoop/conf-local |
---|
| 15 | mv /opt/hadoop/conf/ /opt/hadoop/conf-pseudo |
---|
[241] | 16 | ln -s /opt/hadoop/conf-pseudo /opt/hadoop/conf |
---|
[242] | 17 | cat > /opt/hadoop/conf/core-site.xml << EOF |
---|
| 18 | <?xml version="1.0"?> |
---|
| 19 | <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> |
---|
| 20 | <configuration> |
---|
| 21 | <property> |
---|
| 22 | <name>fs.default.name</name> |
---|
| 23 | <value>hdfs://localhost:9000</value> |
---|
| 24 | </property> |
---|
| 25 | <property> |
---|
| 26 | <name>hadoop.tmp.dir</name> |
---|
| 27 | <value>/var/hadoop/hadoop-\${user.name}</value> |
---|
| 28 | </property> |
---|
| 29 | </configuration> |
---|
| 30 | EOF |
---|
| 31 | cat > /opt/hadoop/conf/hdfs-site.xml << EOF |
---|
| 32 | <?xml version="1.0"?> |
---|
| 33 | <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> |
---|
| 34 | <configuration> |
---|
| 35 | <property> |
---|
| 36 | <name>dfs.replication</name> |
---|
| 37 | <value>1</value> |
---|
| 38 | </property> |
---|
| 39 | </configuration> |
---|
| 40 | EOF |
---|
[243] | 41 | cat > /opt/hadoop/conf/mapred-site.xml << EOF |
---|
| 42 | <?xml version="1.0"?> |
---|
| 43 | <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> |
---|
| 44 | <configuration> |
---|
| 45 | <property> |
---|
| 46 | <name>mapred.job.tracker</name> |
---|
| 47 | <value>localhost:9001</value> |
---|
| 48 | </property> |
---|
| 49 | </configuration> |
---|
| 50 | EOF |
---|
[129] | 51 | fi |
---|
[143] | 52 | |
---|
[129] | 53 | export JAVA_HOME=$(dirname /lib/jvm/jdk*/bin/) |
---|
[136] | 54 | echo export JAVA_HOME=$JAVA_HOME >> /opt/hadoop/conf/hadoop-env.sh |
---|
| 55 | echo export HADOOP_HOME=/opt/hadoop >> /opt/hadoop/conf/hadoop-env.sh |
---|
[140] | 56 | echo export HADOOP_CLASSPATH=/opt/hadoop >> /opt/hadoop/conf/hadoop-env.sh |
---|
| 57 | echo export HADOOP_CONF_DIR=/opt/hadoop/conf >> /opt/hadoop/conf/hadoop-env.sh |
---|
| 58 | echo export JAVA_HOME=$JAVA_HOME >> /etc/profile |
---|
| 59 | echo "export PATH=/opt/hadoop/bin/:$JAVA_HOME/bin:\$PATH" >> /etc/profile |
---|
[129] | 60 | cd $JAVA_HOME |
---|
| 61 | chmod a+x `find . -name "*.exe"` |
---|
| 62 | chmod a+x `find . -name "*.dll"` |
---|
| 63 | cd /opt/hadoop |
---|
[236] | 64 | /opt/hadoop/bin/hadoop namenode -format |
---|
[232] | 65 | source /etc/profile |
---|
[140] | 66 | /bin/start-hadoop |
---|
[241] | 67 | sleep 10 |
---|
| 68 | /opt/hadoop/bin/hadoop dfsadmin -safemode leave |
---|
[236] | 69 | /opt/hadoop/bin/hadoop fs -mkdir tmp |
---|
[140] | 70 | echo "/bin/stop-hadoop" > ~/.bash_logout |
---|
| 71 | echo "/bin/stop-hadoop" > /etc/skel/.bash_logout |
---|
[129] | 72 | cygstart http://localhost:50070 |
---|
[139] | 73 | cygstart http://localhost:50030 |
---|
[236] | 74 | exit |
---|