mahout安装很简单,在官网上下载,复制到服务器上。
解压:
tar -xzvf /opt/mahout-distribution-0.9.tar.gz
将安装位置添加到环境变量
vi /etc/profile
export $MAHOUT_HOME=/opt/mahout-distribution-0.9
export PATH=$MAHOUT_HOME/conf:$MAHOUT_HOME/bin:$PATH
source /etc/profile
输入命令mahout,可以看到mahout实现的所有命令,安装成功。
用mahout运行自带的示例程序:
首先在网页
http://archive.ics.uci.edu/ml/databases/synthetic_control/synthetic_control.data下载示例数据synthetic_control.data。
在hdfs上创建目录/user/root/testdata。(注意一定要在该位置!)
若hdfs上没有,上级目录,也可以递归创建
hadoop fs -mkdir -p /user/root/testdata
hadoop fs -put synthetic_control.data /user/root/testdata
hadoop jar $MAHOUT_HOME/mahout-examples-0.9-job.jar org.apache.mahout.clustering.syntheticcontrol.kmeans.Job
程序会自动运行,并将结果写至/user/root/output文件夹中,
hadoop fs -ls /user/root/output
可以看到程序执行后的聚类。