目录
一、安装flume
二、flume相关配置
备注:只在hadoop102安装flume就行,下面命令只用在hadoop102上执行
一、安装flume
将flume安装包拖到/opt/software目录下
flume安装包:01-学习笔记尚硅谷数仓搭建-基础Linux环境搭建(使用3台主机模拟Hadoop集群)-CSDN博客
在资源的3.flume目录下

解压到/opt/module目录下
cd /opt/software
tar -zxf /opt/software/apache-flume-1.10.1-bin.tar.gz -C /opt/module/
对flume重命名
mv /opt/module/apache-flume-1.10.1-bin /opt/module/flume
二、flume相关配置
配置/opt/module/flume/conf目录下的log4j2.xml文件
cd /opt/module/flume/conf
vim log4j2.xml
找到LOG_DIR,将原本的“.”修改为/opt/module/flume/log如图:

并增加
<AppenderRef ref="Console" />
用于方便在控制台输出报错,如图中位置所示:

修改后完整代码
<?xml version="1.0" encoding="UTF-8"?>
<!–
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.
–>
<Configuration status="ERROR">
<Properties>
<Property name="LOG_DIR">/opt/module/flume/log</Property>
</Properties>
<Appenders>
<Console name="Console" target="SYSTEM_ERR">
<PatternLayout pattern="%d (%t) [%p – %l] %m%n" />
</Console>
<RollingFile name="LogFile" fileName="${LOG_DIR}/flume.log" filePattern="${LOG_DIR}/archive/flume.log.%d{yyyyMMdd}-%i">
<PatternLayout pattern="%d{dd MMM yyyy HH:mm:ss,SSS} %-5p [%t] (%C.%M:%L) %equals{%x}{[]}{} – %m%n" />
<Policies>
<!– Roll every night at midnight or when the file reaches 100MB –>
<SizeBasedTriggeringPolicy size="100 MB"/>
<CronTriggeringPolicy schedule="0 0 0 * * ?"/>
</Policies>
<DefaultRolloverStrategy min="1" max="20">
<Delete basePath="${LOG_DIR}/archive">
<!– Nested conditions: the inner condition is only evaluated on files for which the outer conditions are true. –>
<IfFileName glob="flume.log.*">
<!– Only allow 1 GB of files to accumulate –>
<IfAccumulatedFileSize exceeds="1 GB"/>
</IfFileName>
</Delete>
</DefaultRolloverStrategy>
</RollingFile>
</Appenders>
<Loggers>
<Logger name="org.apache.flume.lifecycle" level="info"/>
<Logger name="org.jboss" level="WARN"/>
<Logger name="org.apache.avro.ipc.netty.NettyTransceiver" level="WARN"/>
<Logger name="org.apache.hadoop" level="INFO"/>
<Logger name="org.apache.hadoop.hive" level="ERROR"/>
<Root level="INFO">
<AppenderRef ref="LogFile" />
<AppenderRef ref="Console" />
</Root>
</Loggers>
</Configuration>



