apache—使用flume在两个单独的表中写入hive仓库目录中的数据

jljoyd4f  于 2021-06-01  发布在  Hadoop
关注(0)|答案(1)|浏览(570)

我想在hivewarehouse目录中,在两个单独的表中写入数据,称为 flumemaleemployee 以及 flumefemaleemployee . 最后 3 records 应插入 female table和鞋面 3 records 应插入 male 下表是我的数据:

1,alok,mumbai
1,jatin,chennai
1,yogesh,kolkata
2,ragini,delhi
2,jyotsana,pune
1,valmiki,banglore

下面是我的
flume conf 代码:

agent.sources = tailsrc 
agent.channels = mem1 mem2 
agent.sinks = stdl std2 
agent.sources.tailsrc.type = exec 
agent.sources.tailsrc.command = tail -F /home/cloudera/Desktop/in.txt 
agent.sources.tailsrc.batchSize = 1 
agent.sources.tailsrc.interceptors = i1 
agent.sources.tailsrc.interceptors.i1.type = regex_extractor 
agent.sources.tailsrc.interceptors.il.regex = A(\\d} 
agent.sources.tailsrc. interceptors. M.serializers = t1 
agent.sources.tailsrc. interceptors, i1.serializers.t1. name = type 
agent.sources.tailsrc.selector.type = multiplexing 
agent.sources.tailsrc.selector.header = type 
agent.sources.tailsrc.selector.mapping.1 = mem1 
agent.sources.tailsrc.selector.mapping.2 = mem2 
agent.sinks.std1.type = hdfs 
agent.sinks.stdl.channel = mem1 
agent.sinks.stdl.batchSize = 1 
agent.sinks.std1.hdfs.path = /user/hive/warehouse/aisehibanayatp.db/flumemaleemployee
agent.sinks.stdl.rolllnterval = 0 
agent.sinks.stdl.hdfs.fileType = DataStream 
agent.sinks.std2.type = hdfs 
agent.sinks.std2.channel = mem2 
agent.sinks.std2.batchSize = 1 
agent.sinks.std2.hdfs.path = /user/hi ve/warehouse/aisehibanayatp.db/flumefemaleemployee
agent.sinks.std2.rolllnterval = 0 
agent.sinks.std2.hdfs.fileType = DataStream 
agent.channels.mem1.type = memory 
agent.channels.meml.capacity = 100 
agent.channels.mem2.type = memory 
agent.channels.mem2.capacity = 100 
agent.sources.tailsrc.channels = mem1 mem2

我没有得到任何错误,但当我开始
flume service 用下面的命令,它只是在一些我不知道如何处理,因为我没有得到任何错误

flume-ng agent --name agent -conf-file /home/cloudera/Desktop/flume1.config

它在下面的步骤停止:

18/11/13 08:03:00 INFO instrumentation.MonitoredCounterGroup: Shutdown Metric for type: CHANNEL, name: mem2. channel.event.take.success == 0
18/11/13 08:03:00 INFO node.Application: Starting new configuration:{ sourceRunners:{} sinkRunners:{std2=SinkRunner: { policy:org.apache.flume.sink.DefaultSinkProcessor@17ade71c counterGroup:{ name:null counters:{} } }} channels:{mem2=org.apache.flume.channel.MemoryChannel{name: mem2}} }
18/11/13 08:03:00 INFO node.Application: Starting Channel mem2
18/11/13 08:03:00 INFO instrumentation.MonitoredCounterGroup: Component type: CHANNEL, name: mem2 started
18/11/13 08:03:00 INFO node.Application: Starting Sink std2
18/11/13 08:03:00 INFO instrumentation.MonitoredCounterGroup: Monitored counter group for type: SINK, name: std2: Successfully registered new MBean.
18/11/13 08:03:00 INFO instrumentation.MonitoredCounterGroup: Component type: SINK, name: std2 started

那么我如何才能做到这一点??

gudnpqoy

gudnpqoy1#

问题是打字错误,缺少格式和空格,用l代替1。我设法解决了这些问题,它运行,我改变了你的正则表达式,你可以定制,但大部分是一个准确性问题。按如下方式使用该文件,它可以正常工作,当然还有您自己的HDF和设置:

agent.sources = tailsrc 
agent.channels = mem1 mem2 
agent.sinks = std1 std2 
agent.sources.tailsrc.type = exec 
agent.sources.tailsrc.command = tail -F /home/cloudera/in.txt 
agent.sources.tailsrc.batchSize = 1 
agent.sources.tailsrc.interceptors = i1 
agent.sources.tailsrc.interceptors.i1.type = regex_extractor 
agent.sources.tailsrc.interceptors.i1.regex = ^.*(1|2) 
agent.sources.tailsrc.interceptors.i1.serializers = t1 
agent.sources.tailsrc.interceptors.i1.serializers.t1.name = type 
agent.sources.tailsrc.selector.type = multiplexing 
agent.sources.tailsrc.selector.header = type 
agent.sources.tailsrc.selector.mapping.1 = mem1 
agent.sources.tailsrc.selector.mapping.2 = mem2
agent.sinks.std1.type = hdfs 
agent.sinks.std1.channel = mem1 
agent.sinks.std1.batchSize = 1 
agent.sinks.std1.hdfs.path = hdfs://quickstart.cloudera:8020/user/hive/warehouse/flumemaleemployee
agent.sinks.std1.rolllnterval = 0 
agent.sinks.std1.hdfs.fileType = DataStream 
agent.sinks.std2.type = hdfs 
agent.sinks.std2.channel = mem2 
agent.sinks.std2.batchSize = 1 
agent.sinks.std2.hdfs.path =  hdfs://quickstart.cloudera:8020/user/hive/warehouse/flumefemaleemployee
agent.sinks.std2.rolllnterval = 0 
agent.sinks.std2.hdfs.fileType = DataStream 
agent.channels.mem1.type = memory 
agent.channels.meml.capacity = 100 
agent.channels.mem2.type = memory 
agent.channels.mem2.capacity = 100 
agent.sources.tailsrc.channels = mem1 mem2

相关问题