flume-自定义Sink基本框架
来源:互联网 发布:酷比魔方windows系统 编辑:程序博客网 时间:2024/05/23 21:20
1,flume日志输出到控制台
bin/flume-ng agent --conf conf/ --name a1 --conf-file conf/xxx.properties -Dflume.root.logger=INFO,console -Dflume.monitoring.type=http -Dflume.monitoring.port=1234
2,flume日志输出到日志文件
bin/flume-ng agent --conf conf/ --name a1 --conf-file conf/xxx.properties -Dflume.root.logger=INFO,LOGFILE -Dflume.monitoring.type=http -Dflume.monitoring.port=1234
3,conf/flume-env.sh文件的配置JVM虚拟机内存
export JAVA_OPTS="-Xms1024m -Xmx2560m -Dcom.sun.management.jmxremote"
export JAVA_HOME=/opt/jdk1.7.0_79
4,flume执行文件
a1.sources = s1
a1.channels = c1
a1.sinks = k1
# define source
a1.sources.s1.type = exec
a1.sources.s1.command = tail -F /data/xxx/xxx.log
a1.sources.s1.shell = /bin/sh -c
#define channel
a1.channels.c1.type = memory
a1.channels.c1.capacity = 10000
a1.channels.c1.transactionCapacity = 4000
#a1.channels.c1.type = file
#a1.channels.c1.checkpointDir = /data/data1/flumedata/check
#a1.channels.c1.dataDirs = /data/data1/flumedata/datadir
#define selfhbase sinks
a1.sinks.k1.type=xxx.xxx.xxx.xxx
a1.sinks.k1.zoolist=cdh1:2181,cdh2:2181,cdh3:2181
a1.sinks.k1.tablename=xxxxx
a1.sinks.k1.bulkputsize=50
# define zuhe
a1.sources.s1.channels = c1
a1.sinks.k1.channel = c1
5,flume自定义sink问题
begin() called when transaction is OPEN!
//Flume-XXXsink的整体框架public Status process() throws EventDeliveryException {Channel channel = getChannel();try {transaction = channel.getTransaction();transaction.begin();event = channel.take();if(event == null){break;}body = Bytes.toString(event.getBody());splits = body.split(",");====================your code===========================transaction.commit(); return Status.READY; } catch(IOException e){logger.error("ERROR Message "+e.toString());transaction.rollback(); // step 1return Status.BACKOFF; // step 2} catch (NullPointerException e){logger.info("ERROR Message null ==>"+e.toString());transaction.rollback(); // step 1return Status.BACKOFF; // step 2} catch (Throwable th){ transaction.rollback();if (th instanceof Error){throw (Error) th;}else{ throw new EventDeliveryException(th);}}finally {try {this.table.put(this.hbasePutList); } catch (IOException e) {logger.error("", e);}this.hbasePutList.clear(); transaction.close(); //一定是等流程处理完成后才close()
}
注意,要在transaction.close()之前操作transaction.rollback()或是transaction.commit()
- flume-自定义Sink基本框架
- flume自定义sink source
- flume自定义sink
- flume开发--自定义Sink
- flume开发--自定义Sink
- flume自定义sink
- flume 自定义 hbase sink 类
- flume之自定义sink组件
- flume自定义interceptor和hbase sink
- flume 自定义source,sink,channel,拦截器
- Flume Sink
- Flume(ng) 自定义sink实现和属性注入
- 自定义的flume-ng的postgresql数据库sink
- Flume-ng 自定义sink实现和属性注入
- flume 自定义kafka sink运行失败:找不到Callback
- Flume(ng) 自定义sink实现和属性注入
- Flume自定义Source、Sink和Interceptor(简单功能实现)
- Flume(ng) 自定义sink实现和属性注入
- C++ Builder快捷键
- 类人的普适的计算机视觉是如何感知这个世界的?
- js获取浏览器高度和宽度值
- 数组指针的三种定义形式
- 运行时权限
- flume-自定义Sink基本框架
- 在编译Faac1.28库时出现编译C++ 的undefined reference to '__cxa_end_cleanup'及 __gxx_personality_v0问题
- vi vim 常用指令
- mybatis中的CDATA标签的用法
- 项目管理的主要内容
- 时间获取(当月第一天/当天/下一年)以及转换_MD5加密_清session
- jqGrid使用整理
- JSP 标准标签库(JSTL)
- linux下重启oracle服务:监听器和实例