Hadoop加速器GridGain
GridGain的Hadoop加速器
像GridGain等内存网格产品(IMDG)不仅可以作为简单的缓存,加速Hadoop中MapReduce计算也是IMDG的一个亮点。这样内存计算领域又多了一种思路和选择,而不只是Spark独霸一方的局面。关于GridGain的功能介绍请参考《开源IMDG之GridGain》。
1.安装Hadoop 2.7.1
很早之前写过一篇《Hadoop入门(一):Hadoop伪分布安装》,那时用的还是0.20的版本,转眼间都已经2.7.1了,Hadoop发展真是飞快!所以本文的前半部分重点看一下最新版2.7.1如何搭建伪分布式集群。
1.1 SSH无密码模式
为当前用户配置无密码的SSH登录,通过ssh localhost测试是否还需要输入密码。
[root@vm Software]# ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
Generating public/private rsa key pair.
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
28:58:5c:c8:0a:b3:52:83:4f:c1:9a:71:65:12:61:b1 root@BC-VM-edce4ac67d304079868c0bb265337bd4
The key's randomart image is:
+--[ RSA 2048]----+
| oBBo.. |
|=.*=o. |
| %Eoo |
|= oo . |
|. . . . S |
| . |
| |
| |
| |
+-----------------+
[root@vm Software]# cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
[root@vm Software]# ssh localhost
Last login: Wed Sep 9 15:43:19 2015 from localhost
1.2 环境变量
修改~/.bash_profile或/etc/profile,加入HADOOP_HOME环境变量。因为很多启动脚本都在sbin目录下,所以这里将sbin和bin目录都加到PATH环境变量中。
export HADOOP_HOME=/home/hadoop-2.7.1
export PATH=$HADOOP_HOME/sbin:$HADOOP_HOME/bin:$PATH
修改etc/hadoop/hadoop-env.sh。如果没有配置JAVA_HOME或想为Hadoop单独指定JDK的话就直接修改下面这一行:
export JAVA_HOME={JAVA_HOME}
Hadoop对Java的版本要求
“Hadoop requires Java 7 or a late version of Java 6. It is built and tested on both OpenJDK and Oracle (HotSpot)’s JDK/JRE”. 从官网描述能看出,用OpenJDK或Oracle的JDK或JRE运行Hadoop都是没有问题的,版本支持6的后几个版本以及7以上版本。但是从Hadoop 2.7版本开始,要求JDK必须是7以上版本了。
1.3 core-site.xml
修改etc/hadoop/core-site.xml:
<configuration>
<property>
<name>hadoop.tmp.dir</name>
<value>/usr/opt/hadoop/tmp</value>
</property>
<property>
<name>fs.defaultFS</name>
<value>hdfs://localhost:9000</value>
</property>
</configuration>
1.4 hdfs-site.xml
修改etc/hadoop/hdfs-site.xml:
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
</configuration>
1.5 yarn-site.xml
修改etc/hadoop/yarn-site.xml:
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
</configuration>
至此,一个伪分布式的Hadoop集群就配置完毕了!
2.启动Hadoop集群
2.1 格式化NameNode
启动Hadoop之前,一定要先格式化Namenode:
[root@vm hadoop-2.7.1]# hdfs namenode -format
15/09/09 13:03:08 INFO namenode.NameNode: STARTUP_MSG:
/************************************************************
STARTUP_MSG: Starting NameNode
STARTUP_MSG: host = BC-vm/192.168.1.111
STARTUP_MSG: args = [-format]
STARTUP_MSG: version = 2.7.1
STARTUP_MSG: classpath = /root/Software/hadoop-2.7.1/etc/hadoop:/root/Software/hadoop-2.7.1/share/hadoop/common/lib/commons-digester-1.8.jar:...
STARTUP_MSG: build = https://git-wip-us.apache.org/repos/asf/hadoop.git -r 15ecc87ccf4a0228f35af08fc56de536e6ce657a; compiled by 'jenkins' on 2015-06-29T06:04Z
STARTUP_MSG: java = 1.7.0_71
************************************************************/
15/09/09 13:03:08 INFO namenode.NameNode: registered UNIX signal handlers for [TERM, HUP, INT]
15/09/09 13:03:08 INFO namenode.NameNode: createNameNode [-format]
15/09/09 13:03:08 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Formatting using clusterid: CID-7fbd2609-fb3e-459d-bbcf-c24d32473ffb
...
15/09/09 13:03:09 INFO util.ExitUtil: Exiting with status 0
15/09/09 13:03:09 INFO namenode.NameNode: SHUTDOWN_MSG:
/************************************************************
SHUTDOWN_MSG: Shutting down NameNode at BC-vm/192.168.1.111
************************************************************/
2.2 启动HDFS
注意:sbin/start-all.sh中已经明确说明:“This script is Deprecated. Instead use start-dfs.sh and start-yarn.sh”,所以不要通过它来启动Hadoop了。启动成功后,通过jps命名查看运行中的Java进程,应该有NameNode、SecondaryNameNode、DataNode三个。
[root@vm hadoop-2.7.1]# start-dfs.sh
Starting namenodes on [localhost]
localhost: starting namenode, logging to /root/Software/hadoop-2.7.1/logs/hadoop-root-namenode-BC-VM-edce4ac67d304079868c0bb265337bd4.out
localhost: starting datanode, logging to /root/Software/hadoop-2.7.1/logs/hadoop-root-datanode-BC-VM-edce4ac67d304079868c0bb265337bd4.out
Starting secondary namenodes [0.0.0.0]
0.0.0.0: starting secondarynamenode, logging to /root/Software/hadoop-2.7.1/logs/hadoop-root-secondarynamenode-BC-VM-edce4ac67d304079868c0bb265337bd4.out
[root@BC-vm hadoop-2.7.1]# jps
20128 Jps
19825 DataNode
19688 NameNode
20007 SecondaryNameNode
2.3 启动YARN
Hadoop 2中单独抽离出了资源管理器YARN (Yet Another Resource Negotiator),启动YARN后能看到又多了两个Java进程:NodeManager和ResourceManager。
[root@vm hadoop-2.7.1]# start-yarn.sh
starting yarn daemons
starting resourcemanager, logging to /root/Software/hadoop-2.7.1/logs/yarn-root-resourcemanager-BC-VM-edce4ac67d304079868c0bb265337bd4.out
localhost: starting nodemanager, logging to /root/Software/hadoop-2.7.1/logs/yarn-root-nodemanager-BC-VM-edce4ac67d304079868c0bb265337bd4.out
[root@vm hadoop-2.7.1]# jps
20212 ResourceManager
19825 DataNode
20630 Jps
19688 NameNode
20007 SecondaryNameNode
20507 NodeManager
详细日志都在HADOOP_HOME/logs下。
3.测试MapReduce
这里仍旧以经典的WordCount为例,简单测试一下Hadoop 2的性能。
3.1 上传数据文件
这里还是用big.txt作为测试文件。之前我曾在《Trie的应用及拼写检查器的优化》使用过这个文件,感兴趣的可以了解一下。此外要注意,输出文件的文件夹不用提前创建,否则Hadoop会报错,认为文件夹已经存在了。
[root@vm hadoop-2.7.1]# wget http://www.norvig.com/big.txt
[root@vm hadoop-2.7.1]# hadoop fs -mkdir -p /test/wordcount/input
[root@vm hadoop-2.7.1]# hadoop fs -put big.txt /test/wordcount/input
[root@vm hadoop-2.7.1]# hadoop fs -ls /test/wordcount/input
Found 1 items
-rw-r--r-- 1 root supergroup 124 2015-09-09 14:21 /test/wordcount/input/big.txt
3.2 执行WordCount任务
还是老地方,WordCount任务依旧在share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.1.jar中。big.txt只有6MB多,所以执行过程还是挺快的,启动花了大概7秒,计算花了15秒,总体大概花了22秒多。可以利用seq 150 | xargs -i cat big.txt >> bigbig.txt
命令可以产生个1G左右的bigbig.txt作为测试文件,这次Hadoop花了214秒。
[root@vm hadoop-2.7.1]# hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.1.jar wordcount /test/wordcount/input /test/wordcount/output
15/09/09 15:23:50 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
15/09/09 15:23:51 INFO client.RMProxy: Connecting to ResourceManager at /0.0.0.0:8032
15/09/09 15:23:52 INFO input.FileInputFormat: Total input paths to process : 1
15/09/09 15:23:52 INFO mapreduce.JobSubmitter: number of splits:1
15/09/09 15:23:52 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1441775536578_0003
15/09/09 15:23:52 INFO impl.YarnClientImpl: Submitted application application_1441775536578_0003
15/09/09 15:23:52 INFO mapreduce.Job: The url to track the job: http://localhost:8088/proxy/application_1441775536578_0003/
15/09/09 15:23:52 INFO mapreduce.Job: Running job: job_1441775536578_0003
15/09/09 15:23:57 INFO mapreduce.Job: Job job_1441775536578_0003 running in uber mode : false
15/09/09 15:23:57 INFO mapreduce.Job: map 0% reduce 0%
15/09/09 15:24:05 INFO mapreduce.Job: map 100% reduce 0%
15/09/09 15:24:12 INFO mapreduce.Job: map 100% reduce 100%
15/09/09 15:24:12 INFO mapreduce.Job: Job job_1441775536578_0003 completed successfully
15/09/09 15:24:12 INFO mapreduce.Job: Counters: 49
File System Counters
FILE: Number of bytes read=1251830
FILE: Number of bytes written=2734521
...
3.3 结果验证
下面查看一下运行结果,用sort和head命令查看Top 20的单词有哪些,果然都是些虚词:
[root@vm hadoop-2.7.1]# hadoop fs -cat /test/wordcount/output/part-r-00000 | sort -rn -k 2 | head -n 20
the 71744
of 39169
and 35968
to 27895
a 19811
in 19515
that 11216
was 11129
his 9561
he 9362
with 9358
is 9247
as 7333
had 7275
it 6545
by 6384
for 6358
at 6237
not 6201
The 6149
要想重复测试的话很简单,通过 hadoop fs -rm -r /test/wordcount/output 删掉输出文件夹,就可以重新跑一次WordCount任务!
4.使用GridGain加速器
经过了前面的各种铺垫,终于到了本篇的重点了。
4.1 安装GridGain
首先下载GridGain的Hadoop Acceleration版,这是个单独的分发版,与学习GridGain的网格特性时的fabric版不是一个。
GridGain对环境有一些要求:
- Java 7及以上版本
- 配置JAVA_HOME指向JDK或JRE
- Hadoop 2.2及以上版本
- 配置HADOOP_HOME
现在就可以执行bin/setup-hadoop.sh脚本替换Hadoop的配置文件了。
[root@vm gridgain-community-hadoop-1.3.3]# bin/setup-hadoop.sh
__________ ________________
/ _/ ___/ |/ / _/_ __/ __/
_/ // (7 7 // / / / / _/
/___/\___/_/|_/___/ /_/ /___/
for Apache Hadoop
ver. 1.3.3#20150803-sha1:7d747d2a
2015 Copyright(C) Apache Software Foundation
> IGNITE_HOME is set to '/root/Software/gridgain-community-hadoop-1.3.3'.
> HADOOP_HOME is set to '/root/Software/hadoop-2.7.1'.
> HADOOP_COMMON_HOME is not set, will use '/root/Software/hadoop-2.7.1/share/hadoop/common'.
< Ignite JAR files are not found in Hadoop 'lib' directory. Create appropriate symbolic links? (Y/N): Y
> Yes.
> Creating symbolic link '/root/Software/hadoop-2.7.1/share/hadoop/common/lib/ignite-shmem-1.0.0.jar'.
> Creating symbolic link '/root/Software/hadoop-2.7.1/share/hadoop/common/lib/ignite-core-1.3.3.jar'.
> Creating symbolic link '/root/Software/hadoop-2.7.1/share/hadoop/common/lib/ignite-hadoop-1.3.3.jar'.
< Replace 'core-site.xml' and 'mapred-site.xml' files with preconfigured templates (existing files will be backed up)? (Y/N): Y
> Yes.
> Replacing file '/root/Software/hadoop-2.7.1/etc/hadoop/core-site.xml'.
> Replacing file '/root/Software/hadoop-2.7.1/etc/hadoop/mapred-site.xml'.
> Apache Hadoop setup is complete.
替换成功之后,先启动两个GridGain结点:
[root@vm gridgain-community-hadoop-1.3.3]# nohup bin/ignite.sh &
[root@vm gridgain-community-hadoop-1.3.3]# nohup bin/ignite.sh &
启动Hadoop:
[root@BC-VM-edce4ac67d304079868c0bb265337bd4 hadoop-2.7.1]# start-dfs.sh
15/09/09 17:11:37 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Incorrect configuration: namenode address dfs.namenode.servicerpc-address or dfs.namenode.rpc-address is not configured.
Starting namenodes on []
localhost: starting namenode, logging to /root/Software/hadoop-2.7.1/logs/hadoop-root-namenode-BC-VM-edce4ac67d304079868c0bb265337bd4.out
localhost: starting datanode, logging to /root/Software/hadoop-2.7.1/logs/hadoop-root-datanode-BC-VM-edce4ac67d304079868c0bb265337bd4.out
Starting secondary namenodes [0.0.0.0]
0.0.0.0: starting secondarynamenode, logging to /root/Software/hadoop-2.7.1/logs/hadoop-root-secondarynamenode-BC-VM-edce4ac67d304079868c0bb265337bd4.out
4.2 执行测试
现在测试一下GridGain加速器,还是以前的方法执行就可以了。在我的虚拟机中测试的效果不理想,对于一两个GB的数据,GridGain加速器不管是单结点还是双结点,都与Hadoop的测试结果差不多,有时还要慢一些。可能是环境或者代码实现的问题,也许要在更大的数据集上对比才会更明显。
[root@BC-VM-edce4ac67d304079868c0bb265337bd4 hadoop-2.7.1]# hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.1.jar wordcount /test/wordcount/input /test/wordcount/output
15/09/09 15:58:57 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
15/09/09 15:58:58 INFO client.RMProxy: Connecting to ResourceManager at /0.0.0.0:8032
15/09/09 15:58:59 INFO input.FileInputFormat: Total input paths to process : 1
15/09/09 15:58:59 INFO mapreduce.JobSubmitter: number of splits:9
15/09/09 15:59:00 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1441785297218_0002
15/09/09 15:59:00 INFO impl.YarnClientImpl: Submitted application application_1441785297218_0002
15/09/09 15:59:00 INFO mapreduce.Job: The url to track the job: http://localhost:8088/proxy/application_1441785297218_0002/
15/09/09 15:59:00 INFO mapreduce.Job: Running job: job_1441785297218_0002
15/09/09 15:59:07 INFO mapreduce.Job: Job job_1441785297218_0002 running in uber mode : false
15/09/09 15:59:07 INFO mapreduce.Job: map 0% reduce 0%
15/09/09 15:59:20 INFO mapreduce.Job: map 2% reduce 0%
15/09/09 15:59:23 INFO mapreduce.Job: map 3% reduce 0%
...
15/09/09 16:01:24 INFO mapreduce.Job: map 96% reduce 26%
15/09/09 16:01:26 INFO mapreduce.Job: map 96% reduce 30%
15/09/09 16:01:28 INFO mapreduce.Job: map 100% reduce 30%
15/09/09 16:01:29 INFO mapreduce.Job: map 100% reduce 45%
15/09/09 16:01:31 INFO mapreduce.Job: map 100% reduce 100%
15/09/09 16:01:31 INFO mapreduce.Job: Job job_1441785297218_0002 completed successfully
Hadoop加速器GridGain的更多相关文章
- [Hadoop 周边] Hadoop和大数据:60款顶级大数据开源工具(2015-10-27)【转】
说到处理大数据的工具,普通的开源解决方案(尤其是Apache Hadoop)堪称中流砥柱.弗雷斯特调研公司的分析师Mike Gualtieri最近预测,在接下来几年,“100%的大公司”会采用Hado ...
- Hadoop和大数据:60款顶级大数据开源工具
一.Hadoop相关工具 1. Hadoop Apache的Hadoop项目已几乎与大数据划上了等号.它不断壮大起来,已成为一个完整的生态系统,众多开源工具面向高度扩展的分布式计算. 支持的操作系统: ...
- 【转载】Hadoop和大数据:60款顶级大数据开源工具
一.Hadoop相关工具 1. Hadoop Apache的Hadoop项目已几乎与大数据划上了等号.它不断壮大起来,已成为一个完整的生态系统,众多开源工具面向高度扩展的分布式计算. 支持的操作系统: ...
- Hadoop和大数据:60款顶级开源工具(山东数漫江湖)
说到处理大数据的工具,普通的开源解决方案(尤其是Apache Hadoop)堪称中流砥柱.弗雷斯特调研公司的分析师Mike Gualtieri最近预测,在接下来几年,“100%的大公司”会采用Hado ...
- Scalability, Availability & Stability Patterns
https://blog.csdn.net/ajian005/article/details/6191814 一 自我有要求的读者应该提出问题:(研习:掌握层次:)能力级别:不会(了解)——领会( ...
- Apache Ignite高性能分布式网格框架-初探
Apache Ignite初步认识 今年4月开始倒腾openfire,过程中经历了许多,更学到了许多.特别是在集群方面有了很多的认识,真正开始认识到集群的概念及应用方法. 在openfire中使用的集 ...
- ElaticSearch网站
http://www.tuicool.com/articles/r2QJVr http://so.searchtech.pro/articles/2013/06/16/1371392427213.ht ...
- ignite学习笔记
1.一个Ignite节点可以从命令行启动,可以用默认的配置也可以传递一个配置文件.可以启动很多很多的节点然后他们会自动地发现对方. 2.Ignite只需要一个ignite-core强依赖,通常你还需要 ...
- .Ignite是什么
Ignite是什么 Apache Ignite内存数据组织是高性能的.集成化的以及分布式的内存平台,他可以实时地在大数据集中执行事务和计算,和传统的基于磁盘或者闪存的技术相比,性能有数量级的提升. ...
随机推荐
- 并发容器和框架之ConcurrentHashMap
了解HashMap的人都知道HashMap是线程不安全的(多线程下的put方法达到一定大小,引发rehash,导致闭链,最终占满CPU),同时线程安全的HashTable效率又令人望而却步(每个方法都 ...
- 数据库性能优化(database tuning)性能优化绝不仅仅只是索引
一毕业就接触优化方面的问题,专业做优化也有至少5年之多的时间了,可现在还是经常听到很多人认为优化很简单,就是建索引的问题,这确实不能怪大家,做这行20多年的时间里,在职业生涯的每个阶段,几乎都能听到这 ...
- 前端开发必备之Chrome开发者工具(下篇)
本文介绍的 Chrome 开发者工具基于 Chrome 65版本,如果你的 Chrome 开发者工具没有下文提到的那些内容,请检查下 Chrome 的版本 本文是 前端开发必备之Chrome开发者工具 ...
- angular中使用echart遇到的获取容器高度异常的问题记录
问题 在使用echart去创建图表时,发现图表只占了容器的一个角落,如图,并没有充满容器. 第一反应是容器元素的样式有问题,于是我把容器的宽高都改为px指定的(之前是百分比设定的,查询资料发现说ech ...
- 最短路径之Dijkstra算法
Dijkstra(迪杰斯特拉)算法是典型的最短路径路由算法,用于计算一个节点到其他所有节点的最短路径.主要特点是以起始点为中心向外层层扩展,直到扩展到终点为止.Dijkstra算法能得出最短路径的最优 ...
- How to preview html file in our browser at sublime text?
sublime preview html.md open In Browser what should we do if we want to preview html file in our bro ...
- [LeetCode] Encode and Decode TinyURL 编码和解码精简URL地址
Note: This is a companion problem to the System Design problem: Design TinyURL. TinyURL is a URL sho ...
- openSUSE虚拟机安装并连接Xshell
- 机器学习基石:08 Noise and Error
噪声:误标.对同一数据点的标注不一致.数据点信息不准确...... 噪声是针对整个输入空间的. 存在噪声的情况下,VC bound依旧有用: 存在噪声,就是f------>p(y|x),f是p的 ...
- Python中time模块详解
Python中time模块详解 在平常的代码中,我们常常需要与时间打交道.在Python中,与时间处理有关的模块就包括:time,datetime以及calendar.这篇文章,主要讲解time模块. ...