Flume HA的配置

在此處我們爲了防止單點故障,把flume配置成HA的高可用

1、首先準備3臺機器,分別是hdp-01、hdp-02、hdp-03,其中hdp-01爲source機器,而hdp-02、hdp-03爲Flume高可用集羣。

2、我們先設置hdp-02、hdp-03兩臺機器。cd apps/flume/myconf/avro-hdfs.conf (此處source端爲avro模式,sink端爲hdfs模式)

hdp-02機器中的配置信息

# Name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1

# Describe/configure the source
a1.sources.r1.type = avro
a1.sources.r1.bind = hdp-02
a1.sources.r1.port = 4141

# Describe the sink
a1.sinks.k1.type = hdfs
a1.sinks.k1.hdfs.path = /flume/events/
a1.sinks.k1.hdfs.filePrefix = events-

# 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

hdp-03機器中的配置信息

# Name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1

# Describe/configure the source
a1.sources.r1.type = avro
a1.sources.r1.bind = hdp-03
a1.sources.r1.port = 4141

# Describe the sink
a1.sinks.k1.type = hdfs
a1.sinks.k1.hdfs.path = /flume/events/
a1.sinks.k1.hdfs.filePrefix = events-

# 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

3、最後設置hdp-01機器中的配置信息

hdp-01機器中的配置信息

# Name the components on this agent
a1.sources = r1
a1.sinks = k1 k2
a1.channels = c1

#set group,因爲是HA,所以我們給HA集羣中的機器配置一個sink組
a1.sinkgroups = g1

# Describe/configure the source
a1.sources.r1.type = spooldir
a1.sources.r1.spoolDir = /root/flumeSpool
a1.sources.r1.fileHeader = true

# Describe the sink
# set sink1,其實,sink1就是k1
a1.sinks.k1.type = avro
a1.sinks.k1.hostname = hdp-03
a1.sinks.k1.port = 4141

# set sink2,其實,sink2就是k2
#a1.sinks.k2.channel = c1
a1.sinks.k2.type = avro
a1.sinks.k2.hostname = hdp-02
a1.sinks.k2.port = 4141

#set sink group
a1.sinkgroups.g1.sinks = k1 k2

# 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
a1.sinks.k2.channel = c1

#set failover,故障轉移的配置信息,懲罰因子
a1.sinkgroups.g1.processor.type = failover
a1.sinkgroups.g1.processor.priority.k1 = 10
a1.sinkgroups.g1.processor.priority.k2 = 1
a1.sinkgroups.g1.processor.maxpenalty = 10000

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章