作者:奋怒的小超_656 | 来源:互联网 | 2023-08-28 20:38
flume 1.4 安装不说了
hadoop 2.2 的安装也不说了
PS:话说flume也有大半年没更新了,这可怎么跟上hadoop的ecosystem啊,都是一家的,互相扶持一下呗。
PPS:如果不想看过程可以直接看后面的结论哦~
好吧,回归正文:
缘起flume1.4不支持hadoop2.2,网上找了好久也没有相关信息,于是自己试着摸索一下。
首先一如既往的在flume中配置sink到hdfs,启动,报错:
于是google之,(这里鄙视一下baidu,出来的都是什么玩意啊)
这是由于hadoop client 和 server端版本不兼容,这类的问题出现在各种hadoop体系的组件上,比如hbase的0.94,或者chukwa等等。但不幸的是对于flume上出现此问题的解决办法几乎没有,怎么办?胡乱搜索了一番,号称是hadoop-core-1.0.4.jar这个jar包替换掉就好了。
于是,去hadoop下面找了一遍,竟然没有!!也难怪2.2的架构大换血,聪明的我于是照着这个样子找到了hadoop的基础包,打开包看了看里面的包接口发现少了好多类。没办法,硬着头皮试试吧。
删了hadoop-core-1.0.4.jar 换成了hadoop-common-2.2.0.jar,再启动,如我所料报了ClassNotFoundException:
继续google之,发现2.2里面把core拆成了多个jar包,这个PlatFormName类被分到了 hadoop-auth-2.2.0.jar里。
其他还会不会有类似的类找不到呢?于是把hadoop的share目录下的和hadoop相关的jar包一并考走,这里面除了src,test,client的一律打包。(更为细致的你,可以逐一找出来依赖的包,像我这样的懒家伙就干脆一股脑弄过来算了)
于是找出来的包全部扔到flume的lib下,再次启动,又报错了…………
继续google之,于是发现了一篇文章 http://grepalex.com/2014/02/09/flume-and-hadoop-2.2/
文中指出(咳咳,有点新闻联播的赶脚),有两个依赖包有版本问题,需要挪走这两个包,可我觉得不靠谱(实验证明确实不靠谱),于是去hadoop的share下找来了新的版本,替换之。这两个包是
用protobuf-java-2.5.0.jar 和 guava-11.0.2.jar 替换之,再启动,大功告成。
----------------------------------------这是操作顺序的分割线,以下总结步骤----------------------------------------------------------------------------------------------------------------------------------------
- 在${FLUME_HOME}/lib下执行以下命令,把老版本的相关包,备份掉:
mv guava-10.0.1.jar guava-10.0.1.jar.bak
mv protobuf-java-2.4.1.jar protobuf-java-2.4.1.jar.bak
mv hadoop-core-1.0.4.jar hadoop-core-1.0.4.jar.bak - 打包${HADOOP_HOME}/share下面的一些包,可能在不同的目录下,自行find,文件及路径给出如下,把他们拷到${FLUME_HOME}/lib下:
${HADOOP_HOME}/share/hadoop/hdfs/hadoop-hdfs-2.2.0.jar
${HADOOP_HOME}/share/hadoop/hdfs/hadoop-hdfs-nfs-2.2.0.jar
${HADOOP_HOME}/share/hadoop/tools/lib/hadoop-streaming-2.2.0.jar
${HADOOP_HOME}/share/hadoop/tools/lib/hadoop-datajoin-2.2.0.jar
${HADOOP_HOME}/share/hadoop/tools/lib/hadoop-archives-2.2.0.jar
${HADOOP_HOME}/share/hadoop/tools/lib/hadoop-gridmix-2.2.0.jar
${HADOOP_HOME}/share/hadoop/tools/lib/hadoop-rumen-2.2.0.jar
${HADOOP_HOME}/share/hadoop/tools/lib/hadoop-extras-2.2.0.jar
${HADOOP_HOME}/share/hadoop/tools/lib/hadoop-distcp-2.2.0.jar
${HADOOP_HOME}/share/hadoop/yarn/hadoop-yarn-applications-unmanaged-am-launcher-2.2.0.jar
${HADOOP_HOME}/share/hadoop/yarn/hadoop-yarn-api-2.2.0.jar
${HADOOP_HOME}/share/hadoop/yarn/hadoop-yarn-site-2.2.0.jar
${HADOOP_HOME}/share/hadoop/yarn/lib/hadoop-annotations-2.2.0.jar
${HADOOP_HOME}/share/hadoop/yarn/hadoop-yarn-server-nodemanager-2.2.0.jar
${HADOOP_HOME}/share/hadoop/yarn/hadoop-yarn-applications-distributedshell-2.2.0.jar
${HADOOP_HOME}/share/hadoop/yarn/hadoop-yarn-server-web-proxy-2.2.0.jar
${HADOOP_HOME}/share/hadoop/yarn/hadoop-yarn-server-common-2.2.0.jar
${HADOOP_HOME}/share/hadoop/yarn/hadoop-yarn-common-2.2.0.jar
${HADOOP_HOME}/share/hadoop/common/hadoop-nfs-2.2.0.jar
${HADOOP_HOME}/share/hadoop/common/hadoop-common-2.2.0.jar
${HADOOP_HOME}/share/hadoop/common/lib/hadoop-annotations-2.2.0.jar
${HADOOP_HOME}/share/hadoop/common/lib/hadoop-auth-2.2.0.jar
${HADOOP_HOME}/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.2.0.jar
${HADOOP_HOME}/share/hadoop/mapreduce/lib/hadoop-annotations-2.2.0.jar - 把guava和protocal buf两个包也拷到${FLUME_HOME}/lib下,文件名如下:
protobuf-java-2.5.0.jar
guava-11.0.2.jar - 大功告成。
用hadoop2.2做flume1.4的sink,该怎么好呢?,布布扣,bubuko.com