安装Homebrew
ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
运行
brew install hadoop
,当完成安装后,直接可以在/user/local/Cellar/hadoop/ 找到安装的hadoop。更改设置文件(/hadoop/2.6.0/libexec/etc/hadoop/hadoop-env.sh),添加或修改:
export JAVA_HOME=/Library/Java/Home
export PATH=$JAVA_HOME/bin:$PATH
export HADOOP_CLASSPATH=$JAVA_HOME/lib/tools.jar编写源代码
Compile :
bin/hadoop com.sun.tools.javac.Main FileName.java jar -cvf Job.jar -C filefolder/ .
执行:
bin/hadoop jar Job.jar JobName inputFolder outputFolder
最后在outputFolder里面查看生成结果即可。