日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

flume 写入文件服务器,Flume环境配置以及基本操作

發布時間:2025/3/12 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 flume 写入文件服务器,Flume环境配置以及基本操作 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

flume的作用是從接受外界的日志信息,然后輸出到本地的一個框架。

agent是Flume很重要的組成,包括有source,channel,sink。

source是從外部接受日志。

channel跟內存相似,讀滿了之后再寫到sink中。

sink是將數據寫到本地,可以寫在HDFS上也能先寫在Fafka等等。

配置

1.

首先下載包,解壓,并將bin路徑配置到~/.bash_profile

復制flume-env.sh.template配置文件并修改,指定jdk的路徑。

2.

在conf文件夾下新建conf文件:

# example.conf: A single-node Flume configuration

# Name the components on this agent

a1.sources=r1

a1.sinks=k1

a1.channels=c1

#Describe/configure the source

a1.sources.r1.type=netcat

a1.sources.r1.bind=localhost

a1.sources.r1.port=44444

# Describe the sink

a1.sinks.k1.type=logger

# Use a channel which buffers events in memory

a1.channels.c1.type=memory

a1.channels.c1.capacity=1000

a1.channels.c1.transactionCapacity=100

# Bind the source and sink to the channel

a1.sources.r1.channels=c1

a1.sinks.k1.channel=c1

啟動agent

flume-ng agent \

--name a1 \

--conf $FLUME_HOME/conf \

--conf-file $FLUME_HOME/conf/example.conf \

-Dflume.root.logger=INFO.console

在另一個控制臺里輸入telnet hadoop000 44444 輸入些文字測試。。。

以上是Flume監聽端口信息,接下來實時監聽本地文件信息:

只需將#Describe/configure the source下的三行改為:

a1.sources.r1.type = exec

a1.sources.r1.command = tail -F /home/hadoop/data/data.log

a1.sources.r1.shell = /bin/sh -C

在conf目錄下新建 exec-memory-logger.conf文件寫入以上配置信息,然后啟動agent。

flume-ng agent \

--name a1 \

--conf $FLUME_HOME/conf \

--conf-file $FLUME_HOME/conf/exec-memory-logger.conf \

-Dflume.root.logger=INFO.console

在另一個控制臺里往data.log里寫數據

echo hello >> data.log

echo world >> data.log

這樣agent就會輸出日志信息了。

接下來將A服務器上的日志實時采集到B服務器上、

圖1

機器A的conf配置:

# exec-memory-avro.conf:

# Name the components on this agent

exec-memory-avro.sources=exec-source

exec-memory-avro.sinks=avro-sink

exec-memory-avro.channels= memory-channel

#Describe/configure the source

exec-memory-avro.sources.exec-source.type=exec

exec-memory-avro.sources.exec-source.command=tail -F /home/hadoop/data/data.log

exec-memory-avro.sources.exec-source.shell= /bin/sh -c

# Describe the sink

exec-memory-avro.sinks.avro-sink.type=avro

exec-memory-avro.sinks.avro-sink.hostname = hadoop000

exec-memory-avro.sinks.avro-sink.port = 44444

# Use a channel which buffers events in memory

exec-memory-avro.channels.memory-channel.type=memory

# Bind the source and sink to the channel

exec-memory-avro.sources.exec-source.channels=memory-channel

exec-memory-avro.sinks.avro-sink.channel=memory-channel

機器B的conf文件:

avro-memory-logger.sources = avro-source

avro-memory-logger.sinks = logger-sink

avro-memory-logger.channels = memory-channel

avro-memory-logger.sources.avro-source.type = avro

avro-memory-logger.sources.avro-source.bind = hadoop000

avro-memory-logger.sources.avro-source.port = 44444

avro-memory-logger.sinks.logger-sink.type = logger

avro-memory-logger.channels.memory-channel.type = memory

avro-memory-logger.sources.avro-source.channels = memory-channel

avro-memory-logger.sinks.logger-sink.channel = memory-channel

配置完成。先啟動機器B(第一個控制臺):

flume-ng agent \

--name avro-memory-logger \

--conf $FLUME_HOME/conf \

--conf-file $FLUME_HOME/conf/avro-memory-logger.conf \

-Dflume.root.logger=INFO,console

再啟動機器A

(第二個控制臺)

flume-ng agent \

--name exec-memory-avro \

--conf $FLUME_HOME/conf \

--conf-file $FLUME_HOME/conf/exec-memory-avro.conf \

-Dflume.root.logger=INFO,console

在第三個控制臺的data目錄輸入echo welcome >> data.log

第一個控制臺就會有日志信息顯示了。。。

總結

以上是生活随笔為你收集整理的flume 写入文件服务器,Flume环境配置以及基本操作的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。