$ sudo tar -zxvf apache-flume-1.8.0-bin.tar.gz -C /usr/local/ $ sudo mv apache-flume-1.8.0-bin flume
$ sudo vim ~/.bashrc
export FLUME_HOME=/usr/local/flume export FLUME_CONF_DIR=$FLUME_HOME/conf export PATH=$PATH:$FLUME_HOME/bin
$ source ~/.bashrc
cd /usr/local/flume/conf cp flume-env.sh.template flume-env.sh sudo vim flume-env.sh
添加Java的環境變量java
export JAVA_HOME=/usr/local/java-8-openjdk-amd64
./flume/bin/flume-ng version
錯誤: 找不到或沒法加載主類 org.apache.flume.tools.GetJavaPropertyapache
若是系統裏安裝了hbase,會出現錯誤: 找不到或沒法加載主類 org.apache.flume.tools.GetJavaProperty。若是沒有安裝hbase,這一步能夠略過。vim
1. 建立agent配置文件bash
sudo vim ./flume/conf/avro.conf
a1.sources = r1 a1.sinks = k1 a1.channels = c1 # Describe/configure the source a1.sources.r1.type = avro a1.sources.r1.channels = c1 a1.sources.r1.bind = 0.0.0.0 a1.sources.r1.port = 4141 #注意這個端口名,在後面的教程中會用獲得 # 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
2. 啓動flume agent a1 啓動日誌窗口oop
/usr/local/flume/bin/flume-ng agent -c . -f /usr/local/flume/conf/avro.conf -n a1 -Dflume.root.logger=INFO,console
3. 建立指定文件測試
cd /usr/local/flume/conf/ sudo sh -c 'echo "hello world" > /usr/local/flume/log.00'
4. 打開另外一個窗口打印日誌this
./flume/bin/flume-ng avro-client --conf conf -H localhost -p 4141 -F /usr/local/flume/log.00
查看日誌窗口spa
1. 建立agent配置文件日誌
sudo vim ./flume/conf/example.conf
# 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 = 44444 #同上,記住該端口名 # 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
2. 啓動agent日誌窗口code
/usr/local/flume/bin/flume-ng agent -c . -f /usr/local/flume/conf/example.conf -n a1 -Dflume.root.logger=INFO,console
3. 打開另外一個窗口
telnet localhost 44444
輸入一些字符(不能輸入中文)
4. 日誌窗口顯示