Ubuntu Hadoop环境搭建(Hadoop2.6.5+jdk1.8.0_121)
1、JDK的安装
添加:
122.205.135.211 master
122.205.135.212 slave1
122.205.135.213 slave2
export JAVA_HOME=/usr/jdk/jdk1.8.0_121
2>修改hadoop-2.6.5/etc/hadoop/core-site.xml
添加:
<configuration> <property> <name>hadoop.tmp.dir</name> <value>/usr/local/hadoop/hadoop-2.6.5/tmp</value> </property> <property> <name>fs.default.name</name> <value>hdfs://Master:9000</value> </property> </configuration>
3>修改hadoop-2.6.5/etc/hadoop/hdfs-site.xml
<configuration> <property> <name>dfs.http.address</name> <value>Master:50070</value> </property> <property> <name>dfs.namenode.secondary.http-address</name> <value>Master:50090</value> </property> <property> <name>dfs.replication</name> <value>2</value> </property> <property> <name>dfs.namenode.name.dir</name> <value>/usr/local/hadoop/hadoop-2.6.5/dfs/name</value> </property> <property> <name>dfs.datanode.data.dir</name> <value>/usr/local/hadoop/hadoop-2.6.5/dfs/data</value> </property> </configuration>
4>修改hadoop-2.6.0/etc/hadoop/mapred-site.xml(原先文件名为mapred-site.xml.templete,将其改为现在文件名)
<configuration> <property> <name>mapreduce.framework.name</name> <value>yarn</value> </property> </configuration>
5>修改hadoop-2.6.5/etc/hadoop/slaves 添加所有datanode的机器名
slave1
slave2
以slave1为例:命令如下:
scp -r ~/hadoop-2.6.5 root@slave1:~(具体目录具体定)
#JAVA_HOME
JAVA_HOME=/usr/local/jdk/jdk1.8.0_121
JRE_HOME=JAVA_HOME/jre
CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin
export PATH JAVA_HOME JRE_HOME CLASSPATH
#HADOOP_HOME
export HADOOP_HOME=/usr/local/hadoop/hadoop-2.6.5
export HADOOP_CONF_DIR=${HADOOP_HOME}/etc/hadoop
#choice----
export HADOOP_MAPRED_HOME=${HADOOP_HOME}
export HADOOP_COMMON_HOME=${HADOOP_HOME}
export HADOOP_HDFS_HOME=${HADOOP_HOME}
export HADOOP_COMMON_LIB_NATIVE_DIR=${HADOOP_HOME}/lib/native
export YARN_HOME=$HADOOP_HOME
export YARN_CONF_DIR=$HADOOP_HOME/etc/hadoop
export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
8>将配置文件拷贝到所有的slave结点上
以slave1为例:命令如下:
scp /etc/profile root@slave1:/etc/profile
5.启动Hadoop
1>格式化HDFS文件系统的namenode
(这里要进入hadoop-2.6.5目录来格式化):
cd hadoop-2.6.5 //进入hadoop-2.6.5目录
bin/hdfs namenode -format //格式化(特别注意:这个只能格式化一次,否则会出很多问题)
2>启动Hadoop集群
启动hdrs命令如下:
sbin/start-dfs.sh //开启进程
补充,关闭hdfs集群的命令如下:sbin/stop-dfs.sh(每次启动完必须关)
开启yarn:sbin/start-yarn.sh
补充:之后开启就直接用sbin/start-all.sh 来代替上面两个开启项,关闭用sbin/stop-all.sh
6.查看是否成功
通过网页来看是否正常安装与配置,地址如下:http://master:50070/; http://master:8088;