一、安装 netcat 工具
[root@hadoop-master myproject]# sudo yum install -y nc
二、判断 66666端口是否被占用
[root@hadoop-master myproject]# netstat -nlp | grep 66666
三、创建 Flume Agent 配置文件
进入Flume安装目录创建文件夹job,添加配置文件
[root@hadoop-master flink-local]# mkdir job[root@hadoop-master conf]# touch flume-netcat-logger.conf
flume-netcat-logger.conf内容如下:
添加内容如下:# Name the components on this agenta1.sources = r1a1.sinks = k1a1.channels = c1# Describe/configure the sourcea1.sources.r1.type = netcata1.sources.r1.bind = 192.168.0.129a1.sources.r1.port = 66666# Describe the sinka1.sinks.k1.type = logger# Use a channel which buffers events in memorya1.channels.c1.type = memorya1.channels.c1.capacity = 1000a1.channels.c1.transactionCapacity = 100# Bind the source and sink to the channela1.sources.r1.channels = c1a1.sinks.k1.channel = c1
r1:表示a1的Source的名称
k1:表示a1的Sink的名称
c1:表示a1的Channel的名称
四、先开启 flume 监听端口
[root@hadoop-master bin]# ./flume-ng agent -n a1 -c conf/ -f ../job/flume-netcat-logger.conf -Dflume.root.logger=INFO,console
参数说明:
--conf/-c:表示配置文件存储在 conf/目录
--name/-n:表示给 agent 起名为 a1
--conf-file/-f:flume 本次启动读取的配置文件是在 job 文件夹下的 flume-telnet.conf
文件。
参数属性值,并将控制台日志打印级别设置为 INFO 级别。日志级别包括:log、info、warn、error。
五、使用 netcat 工具向本机的 44444 端口发送内容
[root@hadoop-master ~]# nc 192.168.0.129 44444
接收日志:
下一节我们进行flume对HDFS的实例演示,感谢继续关注
领取专属 10元无门槛券
私享最新 技术干货