1. Install Netcat
Rpm-ivh./*.rpm
Restart xineted
./etc/rc.d/init.d/xineted Restart
2. Using the flume command
$ bin/flume-ng usage:bin/flume-ng <command> [options] ... commands:agent run a flume agent Global options:--conf,-c <conf> use configs in <conf> directory-dproperty=value sets A Java system property value Agent options:--name,-n <name> The name of this agent (required)--conf- File,-f <file> Specify a config file (required if-z missing) >>>>>>>>>>>> >>>>>>>>>>>>>> command Format bin/flume-ng agent--conf conf--name agent-test-- Conf-file test.conf bin/flume-ng agent-c conf-n agent-test-f test.conf —————————————————————— * * * Config file * * * * * * ————————— # The
Configuration file needs to define the sources, # The channels and the sinks. ### Define Agent a1.sources = R1 A1.channels = C1 A1.sinks = K1 ### define sources-A1.sources.r1.type = Netcat a1.sources . R1.bind = HADOOP-SENIOR-CDH A1.sources.r1.port = 44444 ### definels a1.channels.c1.type = Memory A1.channels.c1.capacity = 1000 a1.channels.c1.transactionCapacity = m ### define sink a 1.sinks.k1.type = Logger A1.sinks.k1.maxBytesToLog = 2014 ### bind the Soures and sink to the channel Nels = C1 A1.sinks.k1.channel = C1.
3. Run
(1) In the Flume directory execution
Bin/flume-ng Agent \-
c conf \
n A1 \
F conf/a1.conf \
-dflume.root.logger=debug,console
(2) View port, start 44444 port
NETSTAT-TNLP
TCP 0 0:: ffff:192.168.88.131:44444:::* LISTEN 3278/java
(3) sending data over 44444 ports
Telnet HADOOP-CDH 44444
trying 192.168.88.131 ...
Connected to HADOOP-CDH.
Escape character is ' ^] '.
AA
OK
Hello flume
ok
hi
ok
(4) received the message
2017-05-02 04:20:42,369 (sinkrunner-pollingrunner-defaultsinkprocessor) [INFO- Org.apache.flume.sink.LoggerSink.process (loggersink.java:70)] Event: {headers:{} body:68 6C 6C 6F 6C 6D 65 0 D Hello Flume.}