【发布时间】:2014-07-17 07:41:27
【问题描述】:
我使用 Flume 1.5.0 从应用服务器收集日志。 假设我有三个 App 服务器,App-A、App-B、App-C。一台运行 hive 的 HDFS 服务器。 现在,flume 代理在所有 3 个应用服务器上运行,并将日志消息从应用服务器传递到 Hdfs 服务器,另一个 Flume 代理正在运行,最终日志存储在 hadoop 文件系统中。现在我创建了一个外部 Hive 表来映射这些日志数据。 但是除了 hive 无法正确解析日志数据并存储在表中之外,一切都进行得很顺利。
这是我的 Flume 和 Hive 配置:
虚拟日志文件格式(| 分隔):ClientId|App Request|URL
应用服务器上的 Flume conf:
app-agent.sources = tail
app-agent.channels = memoryChannel
app-agent.sinks = avro-forward-sink
app-agent.sources.tail.type = exec
app-agent.sources.tail.command = tail -F /home/kuntal/practice/testing/application.log
app-agent.sources.tail.channels = memoryChannel
app-agent.channels.memoryChannel.type = memory
app-agent.channels.memoryChannel.capacity = 100000
app-agent.channels.memoryChannel.transactioncapacity = 10000
app-agent.sinks.avro-forward-sink.type = avro
app-agent.sinks.avro-forward-sink.hostname = localhost
app-agent.sinks.avro-forward-sink.port = 10000
app-agent.sinks.avro-forward-sink.channel = memoryChannel
Hdfs 服务器上的 Flume conf:
hdfs-agent.sources = avro-collect
hdfs-agent.channels = memoryChannel
hdfs-agent.sinks = hdfs-write
hdfs-agent.sources.avro-collect.type = avro
hdfs-agent.sources.avro-collect.bind = localhost
hdfs-agent.sources.avro-collect.port = 10000
hdfs-agent.sources.avro-collect.channels = memoryChannel
hdfs-agent.channels.memoryChannel.type = memory
hdfs-agent.channels.memoryChannel.capacity = 100000
hdfs-agent.channels.memoryChannel.transactioncapacity = 10000
hdfs-agent.sinks.hdfs-write.channel = memoryChannel
hdfs-agent.sinks.hdfs-write.type = hdfs
hdfs-agent.sinks.hdfs-write.hdfs.path = hdfs://localhost:9000/user/flume/tail_table/avro
hdfs-agent.sinks.hdfs-write.rollInterval = 30
Hive 外部表:
CREATE EXTERNAL TABLE IF NOT EXISTS test(clientId int, itemType string)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n'
LOCATION '/user/flume/tail_table/avro';
请建议我该怎么做?我需要在 hive 端包含 AvroSerde 吗?
【问题讨论】:
标签: logging hadoop hive flume avro