CentOS 7部署flume

准备工作:

安装java并设置java环境变量,在`/etc/profile`中加入

export JAVA_HOME=/usr/java/jdk1.8.0_65 export PATH=$PATH:$JAVA_HOME/bin

注意事项

需要启动多个shell脚本交互客户端进行验证,运行中的客户端不要停止。

安装flume

  • 下载:wget http://mirrors.hust.edu.cn/apache/flume/1.6.0/apache-flume-1.6.0-bin.tar.gz

  • 解压:tar -zxvf apache-flume-1.6.0-bin.tar.gz

  • 移动到指定目录:mv apache-flume-1.6.0 /usr/local/flume

配置

source 使用 necat 类型,sink 采用 file_roll 类型, 从监听端口获取数据,保存到本地文件。 拷贝配置模板:

cp conf/flume-conf.properties.template conf/flume-conf.properties

编辑配置如下:

# The configuration file needs to define the sources,
# the channels and the sinks.
# Sources, channels and sinks are defined per agent, # in this case called 'agent' agent.sources = r1 agent.channels = c1 agent.sinks = s1  # For each one of the sources, the type is defined agent.sources.r1.type = netcat agent.sources.r1.bind = localhost agent.sources.r1.port = 8888  # The channel can be defined as follows. agent.sources.r1.channels = c1  # Each sink's type must be defined agent.sinks.s1.type = file_roll agent.sinks.s1.sink.directory = /tmp/log/flume  #Specify the channel the sink should use agent.sinks.s1.channel = c1  # Each channel's type is defined. agent.channels.c1.type = memory  # Other config values specific to each type of channel(sink or source) # can be defined as well # In this case, it specifies the capacity of the memory channel agent.channels.c1.capacity = 100

功能验证

1.建立输出目录

mkdir -p /tmp/log/flume

2.启动服务

bin/flume-ng agent --conf conf -f conf/flume-conf.properties -n agent&

运行日志位于logs目录,或者启动时添加-Dflume.root.logger=INFO,console 选项前台启动,输出打印日志,查看具体运行日志,服务异常时查原因。

3.发送数据

telnet localhost 8888

输入

hello world!
hello Flume!

4.查看数据文件 查看 /tmp/log/flume 目录文件:

# 文件名不同,需要根据实际情况修改和查看
cat /tmp/log/flume/1447671188760-2 hello world! hello Flume!

转载于:https://www.cnblogs.com/aibabel/p/10843349.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值