1. 程式人生 > >Flume實戰案例三(重點掌握):將A伺服器上的日誌實時採集到B伺服器

Flume實戰案例三(重點掌握):將A伺服器上的日誌實時採集到B伺服器

技術選型:

      A:  exec source +memory channel +avro sink

      B:  avro source +memory channel +logger sink

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 /usr/soft/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= wang-two
exec-memory-avro.sinks.avro-sink.port= 44444

# Use a channel which buffers events in memory
exec-memory-avro.channels.memory-channel.type = memory
# exec-memory-avro.channels.memory-channel.capacity = 1000
# exec-memory-avro.channels.memory-channel.transactionCapacity = 100

# 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

avro-memory-logger.conf

# Name the components on this agent
avro-memory-logger.sources = avro-source
avro-memory-logger.sinks = logger-sink
avro-memory-logger.channels = memory-channel

# Describe/configure the source
avro-memory-logger.sources.avro-source.type = avro
avro-memory-logger.sources.avro-source.bind=wang-two
avro-memory-logger.sources.avro-source.port=44444

# Describe the sink
avro-memory-logger.sinks.logger-sink.type = logger

# Use a channel which buffers events in memory
avro-memory-logger.channels.memory-channel.type = memory

# Bind the source and sink to the channel
avro-memory-logger.sources.avro-source.channels = memory-channel
avro-memory-logger.sinks.logger-sink.channel = memory-channel

先啟動avro-memory-logger.conf  wang-one啟動

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

再啟動exec-memory-avro.conf  wang-two啟動

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