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
可以看到程序執行後的聚類。