linux集群环境与flume监听案例

1.搭建进群环境,简述截止目前集群中安装了哪些软件,如何启动和操作这些软件

安装软件:①hadoop ②hive ③jdk1.8 ④mysql ⑤zookeeper ⑥flume

简单使用hadoop

hdfs fs -命令 目录
hadoop dfs -命令 目录

单独命令hadoop集群

start-dfs.sh 启动

status-dfs.sh 查看状态

stop-dfs.sh 关闭

start-yarn.sh yarn资源调度启用

zookeeper的搭建需要jdk文件

zkServer.sh start 启动

zkServer.sh status 查看状态

zkServer.sh stop 关闭

mysql的安装

\

#关闭mysql服务
systemctl stop mysqld.service
#查找系统自带的mysql包
rpm -qa | grep -i mysql  
#卸载
yum remove -y +包名
#查找mysql相关目录 删除
find / -name mysql 得到目录
rm -rf 删除目录
#删除默认配置 日志
rm -rf /etc/my.cnf 
rm -rf /var/log/mysqld.log
#安装自己上传的包
yum -y install libaio
#初始化mysql
mysqld --initialize
#更改所属组
chown mysql:mysql /var/lib/mysql -R
#启动mysql
systemctl start mysqld.service
#查看生成的临时root密码
cat  /var/log/mysqld.log
#这行日志的最后就是随机生成的临时密码
[Note] A temporary password is generated for root@localhost:密码
#更新root密码  设置为root
mysql> alter user user() identified by "123456";
授权
mysql> use mysql;
mysql> GRANT ALL PRIVILEGES ON *.* TO 'itwise'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
#mysql的启动和关闭 状态查看
systemctl stop mysqld
systemctl status mysqld
systemctl start mysqld
#建议设置为开机自启动服务
systemctl enable  mysqld
#查看是否已经设置自启动成功
systemctl list-unit-files | grep mysqld

hive启动 和hiveserver2服务

必须要先启动 hdfs 和 yarn,因为对hive发送HQL语句底层执行的是MR,而执行MR需要yarn,yarn又依赖于hdfs

**hive --service metastore**
hive --service metastore
cd $HIVE_HOME,或者使用绝对路径
-- 非阻塞运行metastore, hiveserver2服务
beeline是HiveServer2提供了一种新的命令行接口,可以提交执行SQL语句,Beeline 要与HiveServer2配合使用。
客户的通过beeline两种方式连接到hive
1、beeline -u jdbc:hive2://node03:10000/default
2、 beeline
beeline> !connect jdbc:hive2://<host>:<port>/<db>;auth=noSasl root root
1、使用beeline方式登录的时候,默认的用户名和密码是不验证的,也就是说随便写用户名和密码即可
2、使用第一种beeline的方式访问的时候,用户名和密码可以不输入
3、使用第二种beeline方式访问的时候,必须输入用户名和密码,用户名和密码是什么无所谓
cd $HIVE_HOME
nohup hive --service metastore > logs/metastore.log 2>&1 &
nohup hive --service hiveserver2 > logs/hiveserver2.log 2>&1 &

Hbase

我们在开启虚拟机之后,一般会将高可用的Hadoop集群准备好,因此集群中已经包含zookeeper的服务,因此,建议将单节点的HBase配置在没有安装zookeeper的节点上.启动之前需要先启动hdfs、zookeeper

启动:start-hbase.sh
状态:status-hbase.sh
停止:stop-hbase.sh

flume

因为依附hadoop集群,所以启动hadoop集群即可,通过新建端口来使用

可以通过编写shell脚本的方式启动一键启动

开启hadoop集群
my_cluster.sh start
my_cluster.sh脚本
#!/bin/bash
#判断接收参数小于1,直接退出
if [ $# -lt 1 ]
 then
  echo 'No Args Input...'
  exit;
fi
case $1 in
"start")
  #启动HDFS集群
  echo "=============启动HDFS集群=================="
  ssh node2 /opt/module/hadoop-3.1.3/sbin/start-dfs.sh
  #启动HDFS集群
  echo "=============启动YARN集群=================="
  ssh node3 /opt/module/hadoop-3.1.3/sbin/start-yarn.sh
;;
"stop")
  #停止HDFS集群
  echo "=============停止HDFS集群=================="
  ssh node2 /opt/module/hadoop-3.1.3/sbin/stop-dfs.sh
  #停止HDFS集群
  echo "=============停止YARN集群=================="
  ssh node3 /opt/module/hadoop-3.1.3/sbin/stop-yarn.sh
;;
*)
  echo 'args error!!!,please input args  start or stop'
  exit
;;
esac

一键分发文件给各用户

#参数预处理
if [ $# -lt 1 ]
 then
  echo 'Not Enough Arguement!!!'
  exit
fi
#遍历集群中的机器依次分发内容
for host in node3 node4
do
 #依次分发内容
 for file in $@
 do
  #判断当前文件是否存在
  if [ -e $file ]
   then
   #存在
    #1.获取当前文件的目录结构
    pdir=$(cd -P $(dirname $file); pwd)
    #2.获取当前的文件名
    fname=$(basename $file)
    #3.登录目标机器,创建统一的目录结构
    ssh $host "mkdir -p $pdir"
    #4.依次把要分发的文件或目录进行分发
    rsync -av $pdir/$fname $host:$pdir
   else
   #不存在
    echo "$file does not exists!"
    exit
  fi
 done
done

一键开启zookeeper集群

zk_cluster.sh start

#!/bin/bash
if [ $# -lt 1 ]
 then
  echo '参数不能为空!!!'
  exit
fi
for host in node2 node3 node4
do
 case $1 in
 "start")
  echo "$1 ********$host******ZK***********"
  ssh $host /opt/module/zookeeper-3.5.7/bin/zkServer.sh $1
 ;;
 "stop")
  echo "$1 ********$host******ZK***********"
  ssh $host /opt/module/zookeeper-3.5.7/bin/zkServer.sh $1
 ;;
 "status")
  echo "$1 ********$host******ZK***********"
  ssh $host /opt/module/zookeeper-3.5.7/bin/zkServer.sh $1
 ;;
 *)
   echo '参数有误!!!'
   exit
 ;;
 esac
done

一键启动hive脚本

先进入hive文件中
cd /opt/module/hive-3.1.2/bin/
hiveservices.sh start

hiveservices.sh脚本

#!/bin/bash
HIVE_LOG_DIR=$HIVE_HOME/logs
if [ ! -d $HIVE_LOG_DIR ]
  then
    mkdir -p $HIVE_LOG_DIR
fi
#检查进程是否运行正常,参数1为进程名,参数2为进程端口
function check_process()
    [[ "$pid" =~ "$ppid" ]] && [ "$ppid" ] && return 0 || return 1
}

function hive_start()
{   
    metapid=$(check_process HiveMetastore 9083)
    cmd="nohup hive --service metastore >$HIVE_LOG_DIR/metastore.log 2>&1 &"
    cmd=$cmd" sleep 4; hdfs dfsadmin -safemode wait >/dev/null 2>&1"
    [ -z "$metapid" ] && eval $cmd || echo "Metastroe服务已启动"
    server2pid=$(check_process HiveServer2 10000)
    cmd="nohup hive --service hiveserver2 >$HIVE_LOG_DIR/hiveServer2.log 2>&1 &"
    [ -z "$server2pid" ] && eval $cmd || echo "HiveServer2服务已启动"
}

function hive_stop()
{
    metapid=$(check_process HiveMetastore 9083)
    [ "$metapid" ] && kill $metapid || echo "Metastore服务未启动"
    server2pid=$(check_process HiveServer2 10000)
    [ "$server2pid" ] && kill $server2pid || echo "HiveServer2服务未启动"
}

case $1 in
"start")
    hive_start
    ;;
"stop")
    hive_stop
    ;;
"restart")
    hive_stop
    sleep 2
    hive_start
    ;;
"status")
    check_process HiveMetastore 9083 >/dev/null && echo "Metastore服务运行正常" || echo "Metastore服务运>行异常"
    check_process HiveServer2 10000 >/dev/null && echo "HiveServer2服务运行正常" || echo "HiveServer2服务
运行异常"
    ;;
*)
    echo Invalid Args!
    echo 'Usage: '$(basename $0)' start|stop|restart|status'
    ;;
esac
                      

2.flume是是什么,有什么工作组件,如何进行工作的,画图说明?

flume定义:flume是一个由Cloudera(课捞的爱rua)所提供的一个高可用,高可靠分布式的海量日志采集,聚合和传输系统,特点:灵活简单,流式架构.

工作组件:在一个Agent(爱剪剃)代理JVM进程中,

Sourse :接收数据,处理各种类型,各种格式的数据
Sink : 不断轮询,主动处理Channel里的事件,批量的写入存储HDFS库中,或者发送到第其他Agent处理jVM中
Channel:(读音:前脑)管道,位于sourse读取与sink写入的缓冲区,线程安全,
memory(卖毛瑞) channel 内存缓冲区易丢失数据,file channel:磁盘缓冲区不易丢失数据

画图运行流程

3,写出安装flume步骤,验证安装成功,截图说明

(1)从官网下载对应的安装包, .gz

下载地址:http://archive.apache.org/dist/flume/

(2)上传并解压安装包到自己的安装文件目录下

切换到兄弟目录

例如同一个父目录/opt下
cd /opt/software/
cd ../module/
1,直接通过下载的,gz的安装包上传到/opt/software目录下

2,解压文件夹 到 /opt/module目录下
tar -zxvf apache-flume-1.9.0-bin.tar.gz -C /opt/module/

3,在安装目录module下 将文件改名
mv apache-flume-1.9.0-bin/ flume-1.9.0

4,到lib目录下删除与hadoop 3.1.3兼容的的guava-11.0.2,jar
cd /opt/module/flume/lib
rm -rf guava-11.0.2.jar

5,根目录下配置fulme环境变量
vim /etc/profile.d/my_env.sh
配置以下内容
#flume
export FLUME_HOME=/opt/module/flume-1.9.0
export PATH=$PATH:$FLUME_HOME/bin

6,重启服务
source /etc/profile

7,验证配置成功 进入目录
cd $FLUME_HOME

4,编写一个成功案例代码,并分析意义,截图说明

使用nc在node2监听一个端口

不知道如何使用nc 可以提使用以下两个代码查询
nc -help
man nc
监听:
nc -l localhost 44444

在 flume 目录下创建 job 文件夹并进入 job 文件夹。

[itwise@node2 flume]$ mkdir job
[itwise@node2 flume]$ cd job/

在 job 文件夹下创建 Flume Agent 配置文件 flume-netcat-logger.conf。

[itwise@node2 job]$ vim flume-netcat-logger.conf

在 flume-netcat-logger.conf 文件中添加配置:

# example.conf: A single-node Flume configuration

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

# Describe/configure the source
a1.sources.r1.type = netcat     -- 类型
a1.sources.r1.bind = localhost  -- ip
a1.sources.r1.port = 4444      -- 端口号

# Describe the sink
a1.sinks.k1.type = logger       -- 类型

# Use a channel which buffers events in memory
a1.channels.c1.type = memory    -- 类型
a1.channels.c1.capacity = 1000  -- 容量:放入事件的数量
a1.channels.c1.transactionCapacity = 100  -- course存入/sink写入事务的大小

# Bind the source and sink to the channel
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1

进行测试

1,第一步,node启动flume,默认端口监听输出位log4j日志文件,需要将后面的改为,console
   bin/flume-ng agent --conf conf --conf-file jobs/flume-netcat-logger.conf --name a1
2,重新开启一个node2窗口保存到第一种方式的保存到log/log4j中的
  本地开启监听,这个窗口输出内容
nc localhost 44444 
3,再开一个窗口,查看监测日志.  注意:上一个窗口重新输入内容,查看日志需要重新打开
   cd /opt/module/flume-1.9.0/
   vim flume.log 

#方法一:
bin/flume-ng agent --conf conf --conf-file jobs/flume-netcat-logger.conf --name a1 -Dflume.root.logger=INFO,console

#方法二
[itwise@node2 flume]$ bin/flume-ng agent -c conf -f jobs/flume netcat-logger.conf -n al Dflume.root.logger=INFO,console

#常用写法,将地址写错成环境变量的方式
[itwise@node2 flume]$ bin/flume-ng agent -c $FLUME_HOME/conf -f $FLUME_HOME/jobs/flume netcat-logger.conf -n al Dflume.root.logger=INFO,console




在这里插入代码片

案列二:监听Hive日志,并上传到hdfs中

分解:监听一个文件,如果文件发生变化追加文件,将内容打印到控制台

补充:linux命令 监控文本输入 写入会覆盖( > ) 追加(>>)

tail -f $FLUME_HOME/jobs/workdir/file1.txt

在这里插入图片描述

在这里插入图片描述

1,创建文件:
[itwise@node2 jobs]$ pwd
/opt/module/flume-1.9.0/jobs
[itwise@node2 jobs]$ mkdir workdir
[itwise@node2 jobs]$ cd workdir/
[itwise@node2 jobs]$ touch file1.txt

#打开一个窗口node2监听
[itwise@node2 home]$ tail -f $FLUME_HOME/jobs/workdir/file1.txt 
#在窗口写入数据
[itwise@node2 workdir]$ echo 222 >> file1.txt 
[itwise@node2 workdir]$ echo 333 >> file1.txt
# 原数据发生数据变化:
使用flume进行文本写入的监听

注意在配置文件中,路径要是绝对路径

# example.conf: A single-node Flume configuration
# Name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1
# Describe/configure the source
a1.sources.r1.type = exec
a1.sources.r1.command = tail -f /opt/module/flume-1.9.0/jobs/workdir/file1.txt
# Describe the sink
a1.sinks.k1.type = logger
# 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
创建脚本文件
[itwise@node2 jobs]$ vim flume-exec-logger.conf
上面的文件添加到文本当中
执行命令行
#常用写法,将地址写错成环境变量的方式
[itwise@node2 flume-1.9.0]$ 
flume-ng agent -c $FLUME_HOME/conf -f $FLUME_HOME/jobs/flume-exec-logger.conf -n a1 -Dflume.root.logger=INFO,console

flume-ng agent -c $FLUME_HOME/conf -f $FLUME_HOME/jobs/flume-exec-logger.conf -n al -Dflume.root.logger=INFO,console

echo 4444 >> $FLUME_HOME/jobs/workdir/file1.txt

在这里插入图片描述
在这里插入图片描述

3,将文件追加爱文件上传到hdfs中

写入目标位置,修改Sink的配置,其余的预上面保持一致

# example.conf: A single-node Flume configuration
# Name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1
# Describe/configure the source
a1.sources.r1.type = exec
a1.sources.r1.command = tail -f /opt/module/flume-1.9.0/jobs/workdir/file1.txt
# Describe the sink
#Sink
a1.sinks.k1.type = hdfs
a1.sinks.k1.hdfs.path = hdfs://node2:9820/flume/%Y%m%d/%H
#上传文件的前缀
a1.sinks.k1.hdfs.filePrefix = logs-
#是否按照时间滚动文件夹
a1.sinks.k1.hdfs.round = true
#多少时间单位创建一个新的文件夹
a1.sinks.k1.hdfs.roundValue = 1
#重新定义时间单位
a1.sinks.k1.hdfs.roundUnit = hour
#是否使用本地时间戳
a1.sinks.k1.hdfs.useLocalTimeStamp = true
#积攒多少个Event才flush到HDFS一次
a1.sinks.k1.hdfs.batchSize = 100
#设置文件类型,可支持压缩
a1.sinks.k1.hdfs.fileType = DataStream
#多久生成一个新的文件
a1.sinks.k1.hdfs.rollInterval = 60
#设置每个文件的滚动大小
a1.sinks.k1.hdfs.rollSize = 134217700
#文件的滚动与Event数量无关
a1.sinks.k1.hdfs.rollCount = 0
# 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
开始执行,保证hadoop集群的启动
flume-ng agent -c $FLUME_HOME/conf -f $FLUME_HOME/jobs/flume-exec-hdfs.conf -n a1 -Dflume.root.logger=INFO,console
打开node2:9820, 去看看,有没有创建/flume, 看看它里面的东西:通过前面的测试,原有数据的。

读数据写保存。看到

效果图

在这里插入图片描述

[itwise@node2 jobs]$ echo '我爱大数据' >> $FLUME_HOME/jobs/workdir/file1.txt

#代码跑的效果代码
2024-03-08 20:45:55,415 (hdfs-k1-call-runner-4) [INFO - org.apache.flume.sink.hdfs.BucketWriter$7.call(BucketWriter.java:681)] Renaming hdfs://node2:9820/flume/20240308/20/logs-.1709901895357.tmp to hdfs://node2:9820/flume/20240308/20/logs-.1709901895357

在这里插入图片描述
在这里插入图片描述

案例 3 实时监控目录下的新文件,将内容上传到HDFS中*

编写代码:

有一个意识: 现在需要source, 后面不动

创建一个要被监控的目录

 mkdir spooling
[itwise@node2 jobs]$ vim flume-spooling-hdfs.conf
vim flume-spooling-hdfs.conf内容:
# example.conf: A single-node Flume configuration
# Name the components on this agent
a1.sources = r1
a1.sinks = k1
a1.channels = c1
# Describe/configure the source
a1.sources.r1.type = spooldir
a1.sources.r1.spoolDir = /opt/module/flume-1.9.0/jobs/spooling
a1.sources.r1.fileSuffix = .COMPLETED
a1.sources.r1.ignorePattern = .*\.tmp
# Describe the sink
#Sink
a1.sinks.k1.type = hdfs
a1.sinks.k1.hdfs.path = hdfs://node2:9820/flume/%Y%m%d/%H
#上传文件的前缀
a1.sinks.k1.hdfs.filePrefix = logs-
#是否按照时间滚动文件夹
a1.sinks.k1.hdfs.round = true
#多少时间单位创建一个新的文件夹
a1.sinks.k1.hdfs.roundValue = 1
#重新定义时间单位
a1.sinks.k1.hdfs.roundUnit = hour
#是否使用本地时间戳
a1.sinks.k1.hdfs.useLocalTimeStamp = true
#积攒多少个Event才flush到HDFS一次
a1.sinks.k1.hdfs.batchSize = 100
#设置文件类型,可支持压缩
a1.sinks.k1.hdfs.fileType = DataStream
#多久生成一个新的文件
a1.sinks.k1.hdfs.rollInterval = 60
#设置每个文件的滚动大小
a1.sinks.k1.hdfs.rollSize = 134217700
#文件的滚动与Event数量无关
a1.sinks.k1.hdfs.rollCount = 0
# 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

启动命令:

flume-ng agent -c $FLUME_HOME/conf -f $FLUME_HOME/jobs/flume-spooling -hdfs.conf -n a1 -Dflume.root.logger=INFO,console

测试启动命令是否正常启动

 cp $FLUME_HOME/jobs/workdir/file1.txt $FLUME_HOME/jobs/spooling/

运行率结果截图

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

结论: 只要是新文件都会被监听上传到hdfs中,但是如果新文件的名字是带.COMPLETED扩展名,

flume不去处理。因为这个扩展名是我们用来告诉flume区分是否被上传的文件的。

4,实时监控目录下多个追加文件,将内容上传到HDFS中

# example.conf: A single-node Flume configuration
# Name the components on this agent

a1.sources = r1
a1.sinks = k1
a1.channels = c1
# Describe/configure the source
# 更改type类型 创建f1 f2组
a1.sources.r1.type = TAILDIR
a1.sources.r1.filegroups = f1 f2
a1.sources.r1.filegroups.f1 = /opt/module/flume-1.9.0/jobs/taildir/.*\.txt
a1.sources.r1.filegroups.f2 = /opt/module/flume-1.9.0/jobs/taildir/.*\.log
# 创建position文件夹来存放服务
a1.sources.r1.positionFile = /opt/module/flume-1.9.0/jobs/position/position.json

# Describe the sink
#Sink
# 存放path地址,并且按照自己指定的时间类型
a1.sinks.k1.type = hdfs
a1.sinks.k1.hdfs.path = hdfs://node2:9820/flume/%Y%m%d/%H
#上传文件的前缀区分文件
a1.sinks.k1.hdfs.filePrefix = logs-
#是否按照时间滚动文件夹
a1.sinks.k1.hdfs.round = true
#多少时间单位创建一个新的文件夹
a1.sinks.k1.hdfs.roundValue = 1
#重新定义时间单位以小时为创建hdfs目录
a1.sinks.k1.hdfs.roundUnit = hour
#是否使用本地时间戳为前缀+文件名
a1.sinks.k1.hdfs.useLocalTimeStamp = true
#积攒多少个Event才flush到HDFS一次
a1.sinks.k1.hdfs.batchSize = 100
#设置文件类型,可支持压缩
a1.sinks.k1.hdfs.fileType = DataStream
#多久生成一个新的文件
a1.sinks.k1.hdfs.rollInterval = 60
#设置每个文件的滚动大小
a1.sinks.k1.hdfs.rollSize = 134217700
#文件的滚动与Event数量无关
a1.sinks.k1.hdfs.rollCount = 0

# 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
                                      

执行命令

flume-ng agent -c $FLUME_HOME/conf -f $FLUME_HOME/jobs/flume-taildir-hdfs.conf -n a1 -Dflume.root.logger=INFO,console

5,Flume企业开发的案例讲解:

执行力

flume-ng agent -c $FLUME_HOME/conf -f $FLUME_HOME/jobs/group1/flume3.conf -n a3 -Dflume.root.logger=INFO,console

flume-ng agent -c $FLUME_HOME/conf -f $FLUME_HOME/jobs/group1/flume2.conf -n a3 -Dflume.root.logger=INFO,console

flume-ng agent -c $FLUME_HOME/conf -f $FLUME_HOME/jobs/group1/flume.conf -n a3 -Dflume.root.logger=INFO,console
#Flume1.conf
#Named
a1.sources = r1
a1.channels = c1 c2
a1.sinks = k1 k2
#Source
a1.sources.r1.type = TAILDIR
a1.sources.r1.filegroups = f1
a1.sources.r1.filegroups.f1 = /opt/module/flume-1.9.0/jobs/group1/taildir-flume1/.*\.txt
a1.sources.r1.positionFile = /opt/module/flume-1.9.0/jobs/group1/position-flume1/position.json
#channel selector
a1.sources.r1.selector.type = replicating
#Channel
a1.channels.c1.type = memory
a1.channels.c1.capacity = 10000
a1.channels.c1.transactionCapacity = 100
a1.channels.c2.type = memory
a1.channels.c2.capacity = 10000
a1.channels.c2.transactionCapacity = 100
#Sink
a1.sinks.k1.type = avro
a1.sinks.k1.hostname = localhost
a1.sinks.k1.port = 7777
a1.sinks.k2.type = avro
a1.sinks.k2.hostname = localhost
a1.sinks.k2.port = 8888
#Bind
a1.sources.r1.channels = c1 c2
a1.sinks.k1.channel = c1
a1.sinks.k2.channel = c2

#Flume2.conf
# example.conf: A single-node Flume configuration
# Name the components on this agent
a2.sources = r1
a2.sinks = k1
a2.channels = c1
# Describe/configure the source
a2.sources.r1.type = avro
a2.sources.r1.bind = localhost
a2.sources.r1.port = 7777
# Describe the sink
#Sink
a2.sinks.k1.type = hdfs
a2.sinks.k1.hdfs.path = hdfs://node2:9820/flume/%Y%m%d/%H
#上传文件的前缀
a2.sinks.k1.hdfs.filePrefix = logs-
#是否按照时间滚动文件夹
a2.sinks.k1.hdfs.round = true
#多少时间单位创建一个新的文件夹
a2.sinks.k1.hdfs.roundValue = 1
#重新定义时间单位
a2.sinks.k1.hdfs.roundUnit = hour
#是否使用本地时间戳
a2.sinks.k1.hdfs.useLocalTimeStamp = true
#积攒多少个Event才flush到HDFS一次
a2.sinks.k1.hdfs.batchSize = 100
#设置文件类型,可支持压缩
a2.sinks.k1.hdfs.fileType = DataStream
#多久生成一个新的文件
a2.sinks.k1.hdfs.rollInterval = 60
#设置每个文件的滚动大小
a2.sinks.k1.hdfs.rollSize = 134217700
#文件的滚动与Event数量无关
a2.sinks.k1.hdfs.rollCount = 0
# Use a channel which buffers events in memory
a2.channels.c1.type = memory
a2.channels.c1.capacity = 1000
a2.channels.c1.transactionCapacity = 100
# Bind the source and sink to the channel
a2.sources.r1.channels = c1
a2.sinks.k1.channel = c1

#Flume3.conf
#Named
a3.sources = r1
a3.channels = c1
a3.sinks = k1
#Source
a3.sources.r1.type = avro
a3.sources.r1.bind = localhost
a3.sources.r1.port = 8888
#Channel
a3.channels.c1.type = memory
a3.channels.c1.capacity = 10000
a3.channels.c1.transactionCapacity = 100
#Sink
a3.sinks.k1.type = file_roll
a3.sinks.k1.sink.directory = /opt/module/flume-1.9.0/jobs/group1/flume3
#Bind
a3.sources.r1.channels = c1
a3.sinks.k1.channel = c1

配置备注:

position-flume1 是 处理文本存储位置

taildir-flume1 是监控的文件夹

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值