进入bin目录,输入命令flume-ng
[admin@master apache-flume-1.9.0-bin]$ ls
bin CHANGELOG conf DEVNOTES doap_Flume.rdf docs lib LICENSE NOTICE README.md RELEASE-NOTES tools
[admin@master apache-flume-1.9.0-bin]$ cd bin
[admin@master bin]$ ls
flume-ng flume-ng.cmd flume-ng.ps1
[admin@master bin]$ flume-ng
Error: Unknown or unspecified command ''
Usage: /home/admin/apache-flume-1.9.0-bin/bin/flume-ng <command> [options]...
commands:
help display this help text
agent run a Flume agent
avro-client run an avro Flume client
version show Flume version info
global options:
--conf,-c <conf> use configs in <conf> directory
--classpath,-C <cp> append to the classpath
--dryrun,-d do not actually start Flume, just print the command
--plugins-path <dirs> colon-separated list of plugins.d directories. See the
plugins.d section in the user guide for more details.
Default: $FLUME_HOME/plugins.d
-Dproperty=value sets a Java system property value
-Xproperty=value sets a Java -X option
agent options:
--name,-n <name> the name of this agent (required)
--conf-file,-f <file> specify a config file (required if -z missing)
--zkConnString,-z <str> specify the ZooKeeper connection to use (required if -f missing)
--zkBasePath,-p <path> specify the base path in ZooKeeper for agent configs
--no-reload-conf do not reload config file if changed
--help,-h display help text
avro-client options:
--rpcProps,-P <file> RPC client properties file with server connection params
--host,-H <host> hostname to which events will be sent
--port,-p <port> port of the avro source
--dirname <dir> directory to stream to avro source
--filename,-F <file> text file to stream to avro source (default: std input)
--headerFile,-R <file> File containing event headers as key/value pairs on each new line
--help,-h display help text
Either --rpcProps or both --host and --port must be specified.
Note that if <conf> directory is specified, then it is always included first
in the classpath.
[admin@master bin]$
Flume的命令有4种:
help:显示帮助文本
[admin@master ~]$ flume-ng help
agent:执行一个进程
[admin@master ~]$ flume-ng agent
agent options:
--name,-n <name> <name>这个agent的名称(必需的)
--conf-file,-f <file> <file>指定一个配置文件(如果缺少-z则需要)
--zkConnString,-z <str> 指定使用的ZooKeeper连接(如果缺少-f则需要)
--zkBasePath,-p <path> 指定agent configs在ZooKeeper中的基本路径
--no-reload-conf 如果变化,不重新加载配置文件
--help,-h 显示帮助文本
avro-client:运行一个avro Flume客户端
[admin@master ~]$ flume-ng avro-client
avro-client options:
--rpcProps,-P <file> RPC客户端属性文件与服务器连接参数
--host,-H <host> 事件将被发送到的主机名
--port,-p <port> avro源端口
--dirname <dir> 目录流到avro源
--filename,-F <file> text file to stream to avro source (default: std input)
--headerFile,-R <file> 每一行包含事件头作为键值对的文件
--help,-h 显示帮助文本
version:查看flume的版本
[admin@master ~]$ flume-ng version
(1)需要定义agent的名称,还需要定义Source、Channel、Sink(名称是什么?有几个?)
(2)需要对Source、Channel、Sink指明具体的类型和配置
(3)需要指明Source、Channel、Sink三者之间的依赖关系
如下是agent示例文件:netcatsource_to_loggersink.conf
#a1是agent的名称
#定义的source、channel、sink的个数可以是多个,中间使用空格隔开
#定义souece
a1.sources = r1
a1.channel = c1
a1.sink = k1
#声明source具体的类型和对应的一些配置(属性)
a1.sources.r1.type = netcat
a1.sources.r1.bind = master
a1.sources.r1.port = 44444
#声明channel具体的类型和对应的一些配置
a1.channels.c1.type = memory
#channel中event的数量
a1.channels.c1.capacity = 1000
#声明sink具体的类型和对应的一些配置
a1.sinks.k1.type = logger
#声明source、sink分别与channel之间的依赖关系(注意:一个sink只能对应一个channel,一个channel可以对应多个sink)
a1.sources.r1.channels = c1
a1.sinks.k1.channel = c1
flume-ng agent --name <agent名称> --conf <配置文件的目录> --conf-file <agent配置文件的存放目录>
[admin@master apache-flume-1.9.0-bin]$ flume-ng agent --name a1 --conf conf/ --conf-file /home/admin/flume_agent/netcatsource_to_loggersink.conf -Dflume.root.logger=INFO,console
注:-Dflume.root.logger=INFO,console指将日志文件写入到控制台上
flume-ng agent -n <agent名称> -c <配置文件的目录> -f <agent配置文件的存放目录>
[admin@master apache-flume-1.9.0-bin]$ flume-ng agent -n a1 -c conf/ -f /home/admin/flume_agent/netcatsource_to_loggersink.conf -Dflume.root.logger=INFO,console