1、下载Flume
wget https://mirror-hk.koddos.net/apache/flume/1.9.0/apache-flume-1.9.0-bin.tar.gz
2、解压
tar -zxvf apache-flume-1.9.0-bin.tar.gz
mv apache-flume-1.9.0-bin apache-flume-1.9.0
cd apache-flume-1.9.0
3、配置
cd conf
cp flume-env.sh.template flume-env.sh
vim flume-env.sh
# 查看Jdk文件目录
echo $JAVA_HOME
如果echo $JAVA_HOME没有输出东西,可能是因为安装的是openjdk
可以通过以下命令查找
which java
ls -lrt /usr/bin/java
ls -lrt /etc/alternatives/java
进行查找,例如
红色框,框起来的就是jdk路径
将以下内容粘贴进去
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.282.b08-1.el7_9.x86_64
cd ..
mkdir job
vim job/flume-netcat-logger.conf
将以下内容添加到flume-netcat-logger.conf
# 创建 job/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
a1.sources.r1.port = 8011
# 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
## channel 与 sink 的关系是 1对多 的关系。1个sink只可以绑定1个channel,1个channel可以绑定多个sink。
a1.sinks.k1.channel = c1
启动
bin/flume-ng agent --conf conf --conf-file job/flume-netcat-logger.conf --name a1 -Dflume.root.logger=INFO,console
//查看端口时候通
// yum install -y telnet
telnet localhost 8011