1.首先需要配置java环境
2.上传hadoop到/usr/local目录 并解压
cd /usr/local
ls
3.配置hadoop环境目录
vim /etc/profile
#java environment
export JAVA_HOME=/usr/local/jdk1.8.0_151
export JRE_HOME=/usr/local/jdk1.8.0_151/jre
#export PATH=$PATH:/usr/local/jdk1.8.0_151/bin
export CLASSPATH=./:$JAVA_HOME/lib:$JRE_HOME/lib
#hadoop environment
export HADOOP_HOME=/usr/local/hadoop-2.8.4
export PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:
4.在hadoop配置文件 配置java jdk
vim /usr/local/hadoop-2.8.4/etc/hadoop/hadoop-env.sh
source /usr/local/hadoop-2.8.4/etc/hadoop/hadoop-env.sh
# The java implementation to use.
export JRE_HOME=/usr/local/jdk1.8.0_151
5.查看
which hadoop
hadoop version
6.统计单词
这里统计的是 /root/input/a.txt 文件,并且将结果存放到 /root/output 目录
hadoop jar /usr/local/hadoop-2.8.4/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.8.4.jar wordcount /root/input/a.txt /root/output
7.查看结果
cd /root/output
如需转载请标明出处,有兴趣可以加q群交流779133600