CentOS 7部署flume


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!

參考文檔:


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM