flume入门
# example.conf: A single-node Flume configuration# Name the components on this agent
#給那三個(gè)組件取個(gè)名字
a1.sources = r1
a1.sinks = k1
a1.channels = c1# Describe/configure the source
#類(lèi)型, 從網(wǎng)絡(luò)端口接收數(shù)據(jù),在本機(jī)啟動(dòng), 所以localhost, type=spoolDir采集目錄源,目錄里有就采
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
#下沉的時(shí)候是一批一批的, 下沉的時(shí)候是一個(gè)個(gè)eventChannel參數(shù)解釋:
#capacity:默認(rèn)該通道中最大的可以存儲(chǔ)的event數(shù)量
#trasactionCapacity:每次最大可以從source中拿到或者送到sink中的event數(shù)量
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啟動(dòng)命令:
#告訴flum啟動(dòng)一個(gè)agent,指定配置參數(shù), --name:agent的名字,
$ bin/flume-ng agent --conf conf --conf-file conf/netcat-logger.conf --name a1 -Dflume.root.logger=INFO,console
首先要啟動(dòng)hdfs,
使用telnet通信就可以做測(cè)試,如果是其他機(jī)器訪問(wèn)的那么netcat要配置成ip而不是localhost,netcat默認(rèn)讀取字符長(zhǎng)度是16個(gè)數(shù)字,可以設(shè)置更大
?啟動(dòng)flume 之后?telnet mini2 44444?
文件系統(tǒng) 到hdfs
agent1.sources=source1 agent1.sinks=sink1 agent1.channels=channel1 #source1 agent1.sources.source1.type=spooldir agent1.sources.source1.spoolDir=/home/hadoop/flume/test/logs agent1.sources.source1.channels=channel1 agent1.sources.source1.fileHeader=false agent1.sources.source1.interceptors?=?i1 agent1.sources.source1.interceptors.i1.type?=?timestamp #sink1 agent1.sinks.sink1.type=hdfs agent1.sinks.sink1.hdfs.path=hdfs://mini1:9000/flume/data agent1.sinks.sink1.hdfs.fileType=DataStream agent1.sinks.sink1.hdfs.writeFormat=TEXT agent1.sinks.sink1.hdfs.rollInterval=1 agent1.sinks.sink1.hdfs.useLocalTimeStamp = true agent1.sinks.sink1.channel=channel1 agent1.sinks.sink1.hdfs.filePrefix=%Y-%m-%d #配置channel1 agent1.channels.channel1.type=file agent1.channels.channel1.checkpointDir=/home/hadoop/flume/channel_data.backup agent1.channels.channel1.dataDirs=/home/hadoop/flume/channel_data?
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來(lái)咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
- 上一篇: Shell脚本/bin/bash^M:
- 下一篇: ReactNative学习笔记(二)Fl