Uploading data to hive via Flume

Source: Internet
Author: User

Target:  store in the Hive database by accepting HTTP request information for Port 1084,
Osgiweb2.db the name of the database created for hive
Periodic_report5 for the Created data table,

The flume configuration is as follows:
a1.sources=R1  a1.channels=C1  a1.sinks=    k1 =0.0.  0.01084a1.sources.r1.handler=Jkong. Test.httpsourcedpihandler  

#a1. Sources.r1.interceptors=i1 I2


#a1. Sources.r1.interceptors.i2.type=timestamp
A1.channels.c1.type=Memory A1.channels.c1.capacity=10000a1.channels.c1.transactionCapacity= +A1.channels.c1.keep-alive= -A1.sinks.k1.type=HDFs A1.sinks.k1.channel=C1 A1.sinks.k1.hdfs.path=hdfs://Gw-sp.novalocal:1086/user/hive/warehouse/osgiweb2.db/periodic_report5A1.sinks.k1.hdfs.filetype=DataStream A1.sinks.k1.hdfs.writeFormat=Text A1.sinks.k1.hdfs.rollInterval=0a1.sinks.k1.hdfs.rollSize=10240A1.sinks.k1.hdfs.rollCount=0A1.sinks.k1.hdfs.idleTimeout= -A1.sources.r1.channels=C1a1.sinks.k1.channel=c1

2. Data Sheet creation:

CREATE TABLE Periodic_report5 (ID BIGINT, deviceId string,report_time string,information STRING) row format Serde"org.openx.data.jsonserde.JsonSerDe"With Serdeproperties ("ID"="$.id","deviceId"="$.deviceid","Report_time"="$.report_time","Information"="$.information");

2.1 The fields in the data table are also split into the creation statement of the data field (not yet tested, temporarily unused)

CREATE TABLE Periodic_report4 (ID BIGINT, deviceId string,report_time string,information Struct<actualtime:bigint, Dpiversioninfo:string,subdeviceinfo:string,wantrafficdata:string,poninfo:string,eventtype:string,potsinfo: string,deviceinfo:string,devicestatus:string>) row Format Serde"org.openx.data.jsonserde.JsonSerDe"With Serdeproperties ("Input.invalid.ignore"="true","ID"="$.id","deviceId"="$.deviceid","Report_time"="$.report_time","Requestparams.actualtime"="$.requestparams.actualtime","Requestparams.dpiversioninfo"="$.requestparams.dpiversioninfo","Requestparams.subdeviceinfo"="$.requestparams.subdeviceinfo","Requestparams.wantrafficdata"="$.requestparams.wantrafficdata","Requestparams.poninfo"="$.requestparams.poninfo","Requestparams.eventtype"="$.requestparams.eventtype","Requestparams.potsinfo"="$.requestparams.potsinfo","Requestparams.deviceinfo"="$.requestparams.deviceinfo","Requestparams.devicestatus"="$.requestparams.devicestatus");

3. Start the Flume statement: Flume root directory

Bin/flume-ng agent--conf./conf/-F./conf/flume.conf--name A1-dflume.root.logger=debug,console

4. Launch Hive statement: Hive Bin directory

Hive    or:. /hive-hiveconf hive.root.logger=debug,console  #带log信息启动

Uploading data to hive via Flume

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.