Hama安装及示例运行
Hama介绍
Apache Hama是一个纯BSP(Bulk Synchronous Parallel)计算框架,模仿了Google的Pregel。用来处理大规模的科学计算,特别是矩阵和图计算。
BSP概念由Valiant(2010图灵奖获得者)在1990年提出,具体参看wikipedia。Google在2009年发表了<Pregel: A System for Large-Scale Graph Processing>论文,在分布式条件下实现了BSP模型。
Hama安装
安装环境:
OS: Ubuntu 12.04 64
JAVA: jdk1.6.0_30
Hadoop: hadoop-1.0.4
安装Hama之前,应该首先确保系统中已经安装了hadoop,我这里选用的目前最新版本hadoop-1.0.4。
第一步:下载并解压文件
hama的下载地址:http://mirror.bit.edu.cn/apache/hama/0.6.0/ 我这里选用北京理工的apache镜像。
解压文件到安装目录。我喜欢把hadoop和hama都安装在用户目录下,这样整个系统都比较干净。
tar -xvzf hama-0.6.0.tar.gz
第二步:修改配置文件
进入$HAMA_HOME/conf文件夹。
修改hama-env.sh文件。加入JAVA_HOME变量。
修改hama-site.xml文件。我的hama-site.xml配置文件如下:
- <?xmlversion="1.0"?>
- <?xml-stylesheettype="text/xsl"href="configuration.xsl"?>
- <configuration>
- <property>
- <name>bsp.master.address</name>
- <value>LenovoE46a:40000</value>
- <description>The address of the bsp master server. Either the
- literal string "local" or a host:port for distributed mode
- </description>
- </property>
- <property>
- <name>fs.default.name</name>
- <value>LenovoE46a:9000/</value>
- <description>
- The name of the default file system. Either the literal string
- "local" or a host:port for HDFS.
- </description>
- </property>
- <property>
- <name>hama.zookeeper.quorum</name>
- <value>LenovoE46a</value>
- <description>Comma separated list of servers in the ZooKeeper Quorum.
- For example, "host1.mydomain.com,host2.mydomain.com,host3.mydomain.com".
- By default this is set to localhost for local and pseudo-distributed modes
- of operation. For a fully-distributed setup, this should be set to a full
- list of ZooKeeper quorum servers. If HAMA_MANAGES_ZK is set in hama-env.sh
- this is the list of servers which we will start/stop zookeeper on.
- </description>
- </property>
- <property>
- <name>hama.zookeeper.property.clientPort</name>
- <value>2181</value>
- </property>
- </configuration>
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>bsp.master.address</name>
<value>LenovoE46a:40000</value>
<description>The address of the bsp master server. Either the
literal string "local" or a host:port for distributed mode
</description>
</property> <property>
<name>fs.default.name</name>
<value>LenovoE46a:9000/</value>
<description>
The name of the default file system. Either the literal string
"local" or a host:port for HDFS.
</description>
</property> <property>
<name>hama.zookeeper.quorum</name>
<value>LenovoE46a</value>
<description>Comma separated list of servers in the ZooKeeper Quorum.
For example, "host1.mydomain.com,host2.mydomain.com,host3.mydomain.com".
By default this is set to localhost for local and pseudo-distributed modes
of operation. For a fully-distributed setup, this should be set to a full
list of ZooKeeper quorum servers. If HAMA_MANAGES_ZK is set in hama-env.sh
this is the list of servers which we will start/stop zookeeper on.
</description>
</property> <property>
<name>hama.zookeeper.property.clientPort</name>
<value>2181</value>
</property>
</configuration>
解释一下,bsp.master.address参数设置成bsp master地址。fs.default.name参数设置成hadoop里namenode的地址。hama.zookeeper.quorum和hama.zookeeper.property.clientPort两个参数和zookeeper有关,设置成为zookeeper的quorum server即可,单机伪分布式就是本机地址。
第三步:运行Hama
首先启动Hadoop,
% $HADOOP_HOME/bin/start-all.sh
再启动Hama
% $HAMA_HOME/bin/start-bspd.sh
查看所有的进程,检查是否启动成功。
jps

第四步:运行例子程序
这里我们选用Pagerank例子程序。
首先上传数据到HDFS,数据的格式为:
Site1\tSite2\tSite3
Site2\tSite3
Site3
执行Hama,其中/tmp/input/input.txt和/tmp/pagerank-output分别为输入文件和输出文件夹。
bin/hama jar ../hama-
0
.6.0-examples.jar pagerank /tmp/input/input.txt /tmp/pagerank-output

成功!
第四周周结
所做的事情:
1.在eclipse里实现了五个结点的单源最短路径算法
实现结果:
输入文件:
1 0|2|2,10,4,5,
2 10|1|3,1,4,2,
3 MAX|0|5,4,
4 5|1|5,2,3,9,2,3,
5 MAX|0|3,6,1,7,
最终迭代结果:
1 0|2|2,10,4,5,
2 8|2|3,1,4,2,
3 9|2|5,4,
4 5|2|5,2,3,9,2,3,
5 7|2|3,6,1,7,
第一次map之后输出的中间结果文件:
1 0|2|2,10,4,5,
1 0|2|2,10,4,5,
2 10|1|
2 MAX|0|3,1,4,2,
2 10|1|
2 MAX|0|3,1,4,2,
3 MAX|0|5,4,
3 MAX|0|5,4,
4 5|1|
4 MAX|0|5,2,3,9,2,3,
4 5|1|
4 MAX|0|5,2,3,9,2,3,
5 MAX|0|3,6,1,7,
5 MAX|0|3,6,1,7,
输出目录:mapred.local.dir因为没有配置,默认值:${hadoop.tmp.dir}/mapred/local
即datanode节点的/usr/local/hadoop/tmp,但是在reduce用完或者job停止之后被直接删除。
2.通过对mapreduce工作机制的理解,自己总结一些可以着手的优化方法:
(1)自定义combiner函数,在map任务的节点对输出先做一次合并,以减少传输到reducer的数据量。如在本例中,可以将上述map输出的中间结果中的<k,v>相同的对合并。或采取压缩数据
(2)InputFormat将数据先进行预处理,Split的数目决定了Map的数目
(3)自定义Partitioner函数,可以指定Reduce任务。默认采用的是hash(key)modR,分区比较平衡。
Hama安装及示例运行的更多相关文章
- Flink快速入门--安装与示例运行
flink是一款开源的大数据流式处理框架,他可以同时批处理和流处理,具有容错性.高吞吐.低延迟等优势,本文简述flink在windows和linux中安装步骤,和示例程序的运行. 首先要想运行Flin ...
- Apache Hama安装部署
安装Hama之前,应该首先确保系统中已经安装了hadoop,本集群使用的版本为hadoop-2.3.0 一.下载及解压Hama文件 下载地址:http://www.apache.org/dyn/clo ...
- S2X环境搭建与示例运行
S2X环境搭建与示例运行 http://dbis.informatik.uni-freiburg.de/forschung/projekte/DiPoS/S2X.html 环境 Maven proje ...
- Appium(JAVA)Windows 7系统搭建及示例运行
Appium(JAVA)Windows 7系统搭建及示例运行 分类: Appium 2014-11-14 17:44 4323人阅读 评论(2) 收藏 举报 1.搭建Android环境 http:// ...
- .NET Core R2安装及示例教程
.NET Core R2安装及示例教程 Install for Windows - Visual Studio 2015 1 Download Visual Studio 2015 Make sure ...
- 沁恒CH32F103C8T6(二): Linux PlatformIO环境配置, 示例运行和烧录
目录 沁恒CH32F103C8T6(一): Keil5环境配置,示例运行和烧录 沁恒CH32F103C8T6(二): Linux PlatformIO环境配置, 示例运行和烧录 StdPeriphLi ...
- Windows下将nginx安装为服务运行
今天看到nginx这个小服务器软件正式版更新到了1.4.2,想玩下它.这个服务器软件虽小,但功能强大,是开源软件,有着良好的性能,被很多个人.企业,甚至大型企业所使用! 由于是在Windows下,所以 ...
- 关于SQL Server 安装程序在运行 Windows Installer 文件时遇到错误
前几日安装sql server2008r2 的时候碰到这个问题: 出现以下错误: SQL Server 安装程序在运行 Windows Installer 文件时遇到错误. Windows Insta ...
- neo4j安装与示例
Neo4j有两种访问模式:服务器模式和嵌入模式参考,下面主要讲windows下这两种模式的配置与访问示例 1 Windows下Neo4j服务器模式安装与示例 安装: 1.下载Neo4j,我下载的版本是 ...
随机推荐
- 【转】nagios使用带url的check_http检测主机
前一段时间在Cu论坛发现一个提问,问题是nagios关于检测主机http服务的.原帖地址http://bbs.chinaunix.net /forum.php?mod=viewthread&t ...
- kickstart无人值守
笔者Q:972581034 交流群:605799367.有任何疑问可与笔者或加群交流 高逼格装系统的方法 Kickstar Cobbler 注意,kickstart并不是一个服务的名称,只是装系统的方 ...
- CSS——类和ID选择器的区别
1.相同点,可以应用在任何元素. 2.不同点,ID选择器只能在元素里只能分别引用,不能同时引用. 如: <style type="text/css">.stress{( ...
- 前端通过Nginx反向代理解决跨域问题
在前面写的一篇文章SpringMVC 跨域,我们探讨了什么是跨域问题以及SpringMVC怎么解决跨域问题,解决方式主要有如下三种方式: JSONP CORS WebSocket 可是这几种方式都是基 ...
- [SF] Symfony 组件 BrowserKit 原理
直接看下面的注释中针对每一个文件的作用说明. <?php /** * BrowserKit - Make internal requests to your application. * * I ...
- [PHP] Phalcon操作示范
这篇内容将对下列操作进行示范: Insert.Select.Update.Calculation.Transaction.models advanced.dev-tools.cookies [ Ins ...
- git的sshkey生成步骤
找到git安装的目录,运行"git-bash.exe". 配置git的user的name及email $ git config --global user.name "u ...
- 基于redis的cas实现
cas是我们常用的一种解决并发问题的手段,小到CPU指令集,大到分布式存储,都能看到cas的影子.本文假定你已经充分理解一般的cas方案,如果你还不知道cas是什么,请自行百度 我们在进行关系型数据库 ...
- java中Queue简介
Queue: 基本上,一个队列就是一个先入先出(FIFO)的数据结构 offer,add区别:一些队列有大小限制,因此如果想在一个满的队列中加入一个新项,多出的项就会被拒绝.这时新的 offer 方法 ...
- UWP: 在 UWP 中使用 Entity Framework Core 操作 SQLite 数据库
在应用中使用 SQLite 数据库来存储数据是相当常见的.在 UWP 平台中要使用 SQLite,一般会使用 SQLite for Universal Windows Platform 和 SQLit ...