Maven编译安装Mahout for Hadoop2

0 准备工作

安装Mahout的主机需要安装有JDK、Hadoop执行环境和Maven管理工具。


1 编译安装Mahout 1.0

Mahout 0.9默认不支持hadoop2,要使用必须修改dependency。


下载源码:

git clone git@github.com:apache/mahout.git

进入到mahout根目录,编译:

mvn -Dhadoop.version=2.5.1 clean compile

打包:

mvn -Dhadoop.version=2.5.1 -DskipTests=true clean package

安装(可选):

mvn -Dhadoop.version=2.5.1 clean install


添加环境变量:

export JAVA_HOME=/usr/java/jdk1.8.0_25
export M2_HOME=/usr/apache-maven
export M2=$M2_HOME/bin
export HADOOP_HOME=/usr/hadoop
export MAHOUT_HOME=/usr/mahout
export HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoop
export MAHOUT_CONF_DIR=$MAHOUT_HOME/conf
export PATH=$MAHOUT_HOME/bin:$M2_HOME/bin:/usr/hadoop/bin:/usr/hadoop/sbin:$HIVE_HOME/bin:$JAVA_HOME/bin:$PATH
export CLASSPATH=.:/usr/hadoop/share/hadoop/common/:/usr/hadoop/share/hadoop/common/lib/:/usr/hive/lib/:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

测试:

[root@hive ~]# mahout
MAHOUT_LOCAL is not set; adding HADOOP_CONF_DIR to classpath.
Running on hadoop, using /usr/hadoop/bin/hadoop and HADOOP_CONF_DIR=/usr/hadoop/etc/hadoop
MAHOUT-JOB: /usr/mahout/examples/target/mahout-examples-1.0-SNAPSHOT-job.jar
An example program must be given as the first argument.
Valid program names are:
  arff.vector: : Generate Vectors from an ARFF file or directory
  baumwelch: : Baum-Welch algorithm for unsupervised HMM training
  buildforest: : Build the random forest classifier
  canopy: : Canopy clustering
  cat: : Print a file or resource as the logistic regression models would see it
  cleansvd: : Cleanup and verification of SVD output
  clusterdump: : Dump cluster output to text
  clusterpp: : Groups Clustering Output In Clusters…


wget http://archive.ics.uci.edu/ml/databases/synthetic_control/synthetic_control.data

hdfs dfs -mkdir testdata
hdfs dfs -put synthetic_control.data testdata/
hadoop jar /usr/mahout/examples/target/mahout-examples-1.0-SNAPSHOT-job.jar org.apache.mahout.clustering.syntheticcontrol.kmeans.Job

mahout clusterdump -i output/clusters-10-final -p output/clusteredPoints -o ~/test

2 参考


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
提高 Maven 编译速度可以采取以下几种方法: 1. 使用并行构建:Maven 3.2.1 版本及以上支持并行构建,可以通过在命令行中添加 `-T` 参数来指定并行线程数。例如,`mvn clean install -T 4` 表示使用 4 个线程进行构建。这样可以利用多核处理器的优势加快编译速度。 2. 配置增量编译Maven 默认会对所有源代码进行重新编译,即使只有部分代码发生了变化。可以通过配置增量编译插件来只编译发生变化的代码。常用的插件有 `maven-compiler-plugin` 和 `maven-jar-plugin`。 3. 使用本地仓库:Maven 默认会从远程仓库下载依赖的 JAR 包,这会消耗一定的时间。可以将常用的依赖手动安装到本地仓库,这样在编译时就不需要从远程仓库下载了。可以使用 `mvn install:install-file` 命令将 JAR 包安装到本地仓库。 4. 配置镜像仓库:可以配置使用国内的镜像仓库,这样可以加快下载依赖的速度。可以在 Maven 的配置文件 `settings.xml` 中配置 `<mirrors>` 标签来指定镜像仓库。 5. 使用缓存:可以使用插件来缓存已编译的类文件,避免重复编译。常用的插件有 `maven-compiler-plugin` 的 `useIncrementalCompilation` 参数和 `maven-clean-plugin` 的 `excludeDefaultDirectories` 参数。 6. 调整内存设置:可以通过调整 Maven 的内存设置来提高编译速度。可以在 Maven 的配置文件 `settings.xml` 中配置 `<build>` 标签下的 `<memory>` 标签来指定内存设置。 7. 使用构建缓存工具:可以使用构建缓存工具,如 Gradle 或 Bazel,来代替 Maven。这些工具具有更高效的构建机制,可以显著提高编译速度。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值