fluentd收集mapreduce分布式环境下的用户日志
来源:互联网 发布:淘宝卖家体检中心链接 编辑:程序博客网 时间:2024/06/05 00:19
mapreduce下可以启动hadoop的日志合并功能,但是很多不需要存入的info/warn等日志也都合并到了一起,不利于查看程序主动打出的log。
这种应用场景比较多的是适用于etl时有一些原始数据输入格式不符合要求而被过滤的排查。
所以自己调研了一下分布式环境下异步存储日志的开源组件,觉得fluentd这个组件较好。
虽然说flume/logstash之类的肯定能完成相应的功能,但mapreduce用户主动打出的log一般不多,fluentd这种轻量级解决方案非常合适。
使用如下:
1)安装fluentd组件
curl -L https://toolbelt.treasuredata.com/sh/install-redhat-td-agent2.sh | sh
2)启动fluentd
推荐使用supervisor来管理控制。
[root@com supervisor]# cat fluentd.conf[program:fluentd-ui]command=/usr/sbin/td-agent-ui startautostart = truestartsecs = 5autorestart=truenumprocs=1user = rootredirect_stderr = truestdout_logfile = /data/logs/fluentd-ui.log
3)配置fluentd写入hdfs
<source> type forward port 24224</source><source> type http port 8888</source><source> type monitor_agent port 24220</source><source> type debug_agent port 24230</source><match debug.*> type stdout</match><match hdfs.*.*> type webhdfs host com.hunantv.hadoopnamenode port 50070 path /data/etl/logs/%Y%m%d/etl.fluentd.%Y%m%d_%H.${hostname}.log username root flush_interval 10s</match>
4)java插件
4.1 插件类
package com.hunantv.bigdata.etl.common.log;import org.fluentd.logger.FluentLogger;import java.io.IOException;import java.util.Properties;/** * Created by lzphoenix on 15/10/29. */public class FluentdLogAppender { private static final String fluentd_host; private static final int fluentd_port; private static final String fluentd_tag; private static final String fluentd_db_tag; static { String filePath = "/fluentd.properties"; Properties properties = new Properties(); try { properties.load(FluentdLogAppender.class.getResourceAsStream(filePath)); } catch (IOException e) { e.printStackTrace(); } fluentd_host = properties.getProperty("fluentd_host"); fluentd_port = Integer.parseInt(properties.getProperty("fluentd_port")); fluentd_tag = properties.getProperty("fluentd_tag"); fluentd_db_tag = properties.getProperty("fluentd_db_tag"); } public static FluentLogger getHdfsLogger(){ FluentLogger LOG = FluentLogger.getLogger(fluentd_tag,fluentd_host,fluentd_port); return LOG; } public static FluentLogger getHdfsDBLogger(){ FluentLogger LOG = FluentLogger.getLogger(fluentd_db_tag,fluentd_host,fluentd_port); return LOG; }}
fluentd_host=10.100.1.46fluentd_port=24224fluentd_tag=hdfs.etlfluentd_db_tag=http.db
private FluentLogger fluentLogger = FluentdLogAppender.getHdfsLogger();fluentLogger.log(*fluentdLogTag,"wrong_line",*lineContent);
0 0
- fluentd收集mapreduce分布式环境下的用户日志
- docker容器日志的收集---fluentd
- 分布式环境日志收集
- 用Fluentd实现收集日志到HDFS(下)
- 日志收集工具之Fluentd
- 通过fluentd收集docker日志
- fluentd分布式日志管理系统
- Elasticsearch+Fluentd+Kibana的日志收集分析系统
- 对Hadoop完全分布式集群下MapReduce日志的提取
- hadoop日志收集解决方案--fluentd配置文件
- Fluentd (td-agent) 日志收集系统
- Fluentd+Hadoop结合进行日志收集、分析
- 万能日志数据收集器 Fluentd
- 利用fluentd构建分布式日志管理系统
- 基于Elasticsearch+Fluentd+Kibana的日志收集分析系统搭建与应用
- 使用Fluentd + MongoDB构建实时日志收集系统
- 使用Fluentd + MongoDB构建实时日志收集系统
- 使用Fluentd + MongoDB构建实时日志收集系统
- Codeforces Round #287 (Div. 2) C. Guess Your Way Out!(线段树思想)
- Python yield 使用浅析
- Android Wear 进阶 - 1 Notification
- 移动端第三方登录(微信)java验证并获取用户信息
- 326. Power of Three
- fluentd收集mapreduce分布式环境下的用户日志
- 231. Power of Two
- 华为机试题:小明的筷子
- Codeforces Round #287 (Div. 2) D. The Maths Lecture(数位dp)
- 从零开始搭建opencv3.0交叉编译环境(Ubuntu14.04+eclipse)(二)
- 【吐槽】颓废良久了
- 232. Implement Queue using Stacks
- 广播(Broadcast)的简单用法
- 第一章 关于语言,对象