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 /opt/hadoop/conf/ /opt/hadoop/conf-local |
---|
15 | mv /opt/hadoop/conf/ /opt/hadoop/conf-pseudo |
---|
16 | ln -s /opt/hadoop/conf-pseudo /opt/hadoop/conf |
---|
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 |
---|
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 |
---|
51 | fi |
---|
52 | |
---|
53 | export JAVA_HOME=$(dirname /lib/jvm/jdk*/bin/) |
---|
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 |
---|
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 |
---|
60 | cd $JAVA_HOME |
---|
61 | chmod a+x `find . -name "*.exe"` |
---|
62 | chmod a+x `find . -name "*.dll"` |
---|
63 | cd /opt/hadoop |
---|
64 | /opt/hadoop/bin/hadoop namenode -format |
---|
65 | source /etc/profile |
---|
66 | /bin/start-hadoop |
---|
67 | sleep 10 |
---|
68 | /opt/hadoop/bin/hadoop dfsadmin -safemode leave |
---|
69 | /opt/hadoop/bin/hadoop fs -mkdir tmp |
---|
70 | echo "/bin/stop-hadoop" > ~/.bash_logout |
---|
71 | echo "/bin/stop-hadoop" > /etc/skel/.bash_logout |
---|
72 | cygstart http://localhost:50070 |
---|
73 | cygstart http://localhost:50030 |
---|
74 | exit |
---|