大數(shù)據(jù)開發(fā)學(xué)習(xí)筆記——flume集成hive

又是周五啦~

分享完就回家過周末~_~

flume集成hive的筆記

1、 確定你的flume在哪臺主機上

2、 確認該臺主機上的flume是否可以正常使用?

在指定的目錄下,創(chuàng)建一個bigdata_page_to_hive.conf

內(nèi)容可以是官網(wǎng)的實例:http://flume.apache.org/FlumeUserGuide.html

啟動:

flume-ng agent --conf conf --conf-file bigdata_page_to_hive.conf --name a1 -Dflume.root.logger=INFO,console

3、 flume將數(shù)據(jù)寫入到hive中

3.1:驗證你的hive是否可以成功使用

3.2:創(chuàng)建表

創(chuàng)建表

3.3 flume的sink為hive

發(fā)現(xiàn)我們需要用到hive的metastore服務(wù),先看一下服務(wù)是否啟動

a1.sinks.k1.hive.metastore = thrift://master:9083

可以采用telnet的方式判斷端口是否通【但是最好是通過CDH界面】

啟動:

nohup flume-ng agent --conf conf --conf-file bigdata_page_to_hive.conf --name a1 &

發(fā)現(xiàn)異常

java.lang.NoClassDefFoundError: org/apache/hive/hcatalog/streaming/RecordWriter

1、 沒有導(dǎo)入依賴

2、 有可能maven沒有下載完整

3、 包沖突的問題

沒有依賴包----flume中缺少某個包

1、 根據(jù)異常信息,確定缺少什么包

根據(jù)網(wǎng)上的搜索信息,確定缺少某一個包:

https://zhidao.baidu.com/question/923836961800918739.html

find / -name 'hive-hcatalog-core*'

根據(jù)link文件過濾、版本對比、猜測等,優(yōu)先選擇了一個jar包

/opt/cloudera/parcels/CDH-5.11.1-1.cdh5.11.1.p0.4/jars/hive-hcatalog-core-1.1.0-cdh5.11.1.jar

2、 如果找到的包正好是自己要的包的話,將包放在什么地方?

通過flume-ng啟動時產(chǎn)生的日志信息

/opt/cloudera/parcels/CDH-5.11.1-1.cdh5.11.1.p0.4/lib/flume-ng/lib/*

3、 問題解決

cp /opt/cloudera/parcels/CDH-5.11.1-1.cdh5.11.1.p0.4/jars/hive-hcatalog-streaming-1.1.0-cdh5.11.1.jar /opt/cloudera/parcels/CDH-5.11.1-1.cdh5.11.1.p0.4/lib/flume-ng/lib/

可以采用鏈接的方式來解決:

ln -s /opt/cloudera/parcels/CDH-5.11.1-1.cdh5.11.1.p0.4/jars/hive-hcatalog-streaming-1.1.0-cdh5.11.1.jar hive-hcatalog-streaming-1.1.0-cdh5.11.1.jar

異常:java.lang.NoClassDefFoundError: org/apache/hadoop/hive/metastore/api/MetaException

解決辦法:

異常:java.lang.ClassNotFoundException: org.apache.hadoop.hive.ql.session.SessionState

解決辦法:

異常:java.lang.ClassNotFoundException: org.apache.hadoop.hive.cli.CliSessionState

異常:org.apache.commons.cli.MissingOptionException: Missing required option: n

異常:java.lang.ClassNotFoundException: com.facebook.fb303.FacebookService$Iface

異常:Cannot stream to table that has not been bucketed : {metaStoreUri='thrift://master:9083', database='default', table='t_pages', partitionVals=[] }

異常:org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat cannot be cast to org.apache.hadoop.hive.ql.io.AcidOutputFormat

測試,在hive當(dāng)中去看是否有當(dāng)前數(shù)據(jù)

4、 修改sources

capacity 100 full, consider committing more frequently, increasing capacity, or increasing thread count

5、 最好將channel的存儲轉(zhuǎn)為文件

END。。

來源:成都科多大數(shù)據(jù)科技有限公司

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容