今天遇到这样的一个问题,flume拉取kafka数据,下沉到hdfs中,然后存取到hive中。是可以存进去的,但是执行查询语句。出现下面这样的代码
或者存进去后,查询出现下面这样的问题
SEQ!org.apache.hadoop.io.LongWritable"org.apache.hadoop.io.BytesWritable��6Xz�i���;�z
后来查询资料说,flume采集数据下沉到hdfs,有默认的文件格式,
hdfs.fileType默认为SequenceFile,将其改为DataStream就可以按照采集的文件原样输入到hdfs,加一行a1.sinks.k1.hdfs.fileType=DataStream
所以,在配置文件中加入这行代码
## sink1
a1.sinks.k1.type = hdfs
a1.sinks.k1.hdfs.fileType=DataStream
a1.sinks.k1.hdfs.path = hdfs://clusterldg:8020/usertopic_start/%Y-%m-%d
a1.sinks.k1.hdfs.filePrefix = logstart-
a1.sinks.k1.hdfs.round = true
a1.sinks.k1.hdfs.roundValue = 20
a1.sinks.k1.hdfs.roundUnit = second
这样以后,可以插入hive中,并且也能查询正常数据