(1)安装flume
(2)配置采集方案 master slave1
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# 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 = s1 s2 s3
agent.channels = c1
agent.sinks = k1
# For each one of the sources, the type is defined
agent.sources.s1.type = exec
agent.sources.s1.command = tail -f /root/logs/access.log
agent.sources.s1.interceptors = i1
agent.sources.s1.interceptors.i1.type = static
agent.sources.s1.interceptors.i1.key = type
agent.sources.s1.interceptors.i1.value = access
agent.sources.s2.type = exec
agent.sources.s2.command = tail -f /root/logs/nginx.log
agent.sources.s2.interceptors = i2
agent.sources.s2.interceptors.i2.type = static
agent.sources.s2.interceptors.i2.key = type
agent.sources.s2.interceptors.i2.value = nginx
agent.sources.s3.type = exec
agent.sources.s3.command = tail -f /root/logs/web.log
agent.sources.s3.interceptors = i3
agent.sources.s3.interceptors.i3.type = static
agent.sources.s3.interceptors.i3.key = type
agent.sources.s3.interceptors.i3.value = web
# The channel can be defined as follows.
agent.sources.s1.channels = c1
agent.sources.s2.channels = c1
agent.sources.s3.channels = c1
# Each sink's type must be defined
agent.sinks.k1.type = avro
agent.sinks.k1.hostname = slave2
agent.sinks.k1.port = 41414
#Specify the channel the sink should use
agent.sinks.k1.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 = 10000
(3)配置slave2的采集方案
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# 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 = s1
agent.channels = c1
agent.sinks = k1
# For each one of the sources, the type is defined
agent.sources.s1.type = avro
agent.sources.s1.bind = 192.168.1.7
agent.sources.s1.port = 41414
agent.sources.s1.interceptors = i1
agent.sources.s1.interceptors.i1.type = timestamp
# The channel can be defined as follows.
agent.sources.s1.channels = c1
# Each sink's type must be defined
agent.sinks.k1.type = hdfs
agent.sinks.k1.hdfs.path = hdfs://192.168.1.4:9000/source/logs/%{type}%/%Y%m%d
#Specify the channel the sink should use
agent.sinks.k1.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 = 10000
(4)启动flume
先启动slave2 ,在启动 master slave1
启动命令
flume-ng agent -n agent -f /root/apache-flume-1.9.0-bin/conf/flume-conf.properties

