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

Writing data in hive warehouse directory in two separate tables using flume

我想在 hive 仓库目录中写入数据,在两个单独的 table 中,称为 flumemaleemployeeflumefemaleemployee。最后一个 3 records 应该插入 female table 上面 3 records 应该插入 male table.Below 是我的数据:

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

下面是我的flumeconf代码:

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

那么我该如何实现呢??

问题是拼写错误,缺少格式和空格,l 而不是 1。我设法解决了这些问题 运行,我更改了你的正则表达式,你可以定制它,但大部分都是准确性问题。按如下方式使用该文件并且它可以工作,当然是您自己的 HDFS 和设置:

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