1.下载hadoop
http://hadoop.apache.org/releases.html
2.解压下载的hadoop文件
tar -zxvf /HADOOP-VERSION-FULL-PATH.tar.gz
3.配置hadoop环境
# vim /etc/profile
##添加HADOOP_HOME路径
# export HADOOP_HOME=/HADOOP-VERSION-FULL-PATH
# export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
# wq
# source /etc/profile
## 创建hadoop数据目录
# sudo mkdir /var/hadoop
# sudo chmod 777 /var/hadoop
4.hadoop需要java环境的支持,配置java环境略
5.修改hadoop配置文件,主要包括以下几个文件
- core.site.xml
# vim /HADOOP-VERSION-FULL-PATH/etc/hadoop/core.site.xml
在configuration节点中添加以下内容
<property>
<name>fs.defaultFS</name>
<value>hdfs://hadoop:9000</value>
</property>
- hdfs.site.xml文件
# vim /HADOOP-VERSION-FULL-PATH/etc/hadoop/hdfs.site.xml
在configuration节点中添加以下内容
<!-- 单节点hadoop不需要复制 -->
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
<property>
<name>dfs.namenode.name.dir</name>
<value>file:/var/hadoop/data/hdfs/nn</value>
</property>
<property>
<name>fs.checkpoint.dir</name>
<value>file:/var/hadoop/data/hdfs/snn</value>
</property>
<property>
<name>fs.checkpoint.edits.dir</name>
<value>file:/var/hadoop/data/doop/hdfs/snn</value>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>file:/var/hadoop/data/hdfs/dn</value>
</property>
- mapred-site.xml
# cp /HADOOP-VERSION-FULL-PATH/etc/hadoop/mapred-site.xml.template
/HADOOP-VERSION-FULL-PATH/etc/hadoop/mapred-site.xml
在configuration节点中添加以下内容
<property>
<name>mapreduce.frameword.name</name>
<value>yarn</value>
</property>
- yarn-site.xml
# vim /HADOOP-VERSION-FULL-PATH/etc/hadoop/yarn-site.xml
在configuration节点中添加以下内容
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
<property>
<name>yarn.nodemanager.aux-services.shuffle.class</name>
<value>org.apache.hadoop.mapred.ShuffleHandler</value>
</property>
- hadoop-env.sh
# vim /HADOOP-VERSION-FULL-PATH/etc/hadoop/hadoop-env.sh
覆盖正确的JAVA_HOME
export JAVA_HOME=JAVA_HOME_PATH
6.格式化hdfs文件系统
# /HADOOP-VERSION-FULL-PATH/bin/hdfs namenode -format
7.启动hdfs服务
# /HADOOP-VERSION-FULL-PATH/sbin/start-dfs.sh
8.启动yran服务
# /HADOOP-VERSION-FULL-PATH/sbin/start-yarn.sh
9.通过web接口验证正在运行的服务
http://127.0.0.1:50070
http://127.0.0.1:8088
10.配置ssh免秘钥登录
# cd ~/.ssh/ # 若没有该目录,请先执行一次ssh localhost
# ssh-keygen -t rsa # 会有提示,都按回车就可以
# cat id_rsa.pub >> authorized_keys # 加入授权
# chmod 600 ./authorized_keys # 修改文件权限