flume開啓過程中出現RPC connection error異常

兩臺服務器master和slave的日誌採集過程出現RPC connection error的問題:

可能存在的配置問題:

  1. 檢查機器的防火牆是否關閉;
  2. 檢查配置文件ip地址的設置問題;
  3. 檢查自己flume服務器的開啓順序;
  4. 檢查自己配置文件的內容代碼是否正確。

可以按照順序依次排查自己的異常所在。

服務器防火牆的設置命令如下:

# 查看防火牆狀態
service iptables status
# 暫時啓動防火牆狀態
service iptables start
# 暫時關閉防火牆狀態
service iptables stop

# 查看開機防火牆狀態
chkconfig iptables --list
# 設置開機開啓防火牆
chkconfig iptables on
# 設置開機禁用防火牆
chkconfig iptables off

而我出現本次異常的問題是:master的IP設置爲localhost,slave也是localhost,slave監聽本機的IP,導致master不能正常的鏈接slave,正確的設置是master的下沉目標爲slave的ip,而slave監聽的也是自己IP。

出現的異常問題截圖:
在這裏插入圖片描述
本次異常兩臺服務器中flume中的配置介紹如下:

1.服務器master:從A服務器的日誌文件中採集日誌信息發送到B服務器

source:日誌
channel:內存channel
sink: avro源
在flume的安裝包下面conf文件夾下新建配置文件,內容如下:

# 新建配置文件
vim exec-memory-avro.conf

配置文件代碼內容:

# Name the components on this agent
exec-memory-avro.sources = exec-source
exec-memory-avro.channels = memory-channel
exec-memory-avro.sinks = avro-sink

# describe sources
# 目標源的類型是:exec 以執行命令的方式
exec-memory-avro.sources.exec-source.type = exec
# 採集日誌文件的路徑
exec-memory-avro.sources.exec-source.command = tail -F /root/bigdata/log/access.log
exec-memory-avro.sources.exec-source.shell = /bin/sh -c

# describe sink
exec-memory-avro.sinks.avro-sink.type = avro
# The hostname or IP address to bind to 綁定的主機名或IP
exec-memory-avro.sinks.avro-sink.hostname = 192.168.141.140
exec-memory-avro.sinks.avro-sink.port = 44444

# describe channel 通道爲內存型
exec-memory-avro.channels.memory-channel.type = memory

# bind the source and sink to the channel
exec-memory-avro.sources.exec-source.channels = memory-channel
exec-memory-avro.sinks.avro-sink.channel = memory-channel

2.服務器slave:從A服務器接收日誌信息記錄在B服務器日誌服務器中

source:avro源
channel:內存channel
sink: 日誌logger
在flume的安裝包下面conf文件夾下新建配置文件,內容如下:

vim avro-memory-logger.conf

配置文件代碼內容:

# source avro-source
# sink logger sink
# channel memory

# agent source
avro-memory-logger.sources = avro-source
avro-memory-logger.channels = memory-channel
avro-memory-logger.sinks = logger-sink

# describe source
avro-memory-logger.sources.avro-source.type=avro
# hostname or IP address to listen on 監聽的主機名或者ip
avro-memory-logger.sources.avro-source.bind=192.168.141.140
avro-memory-logger.sources.avro-source.port=44444

# describe channel
avro-memory-logger.channels.memory-channel.type = memory

# describe sinks
avro-memory-logger.sinks.logger-sink.type = logger

# bind the sources and sink to channel
avro-memory-logger.sources.avro-source.channels = memory-channel
avro-memory-logger.sinks.logger-sink.channel = memory-channel

3.先啓動slave服務器的配置文件,在啓動master服務器配置文件,進入到conf文件夾下,啓動命令如下:

# 啓動slave
../bin/flume-ng agent -n avro-memory-logger -c conf -f avro-memory-logger.conf -Dflume.root.logger=DEBUG,console
# 啓動master
../bin/flume-ng agent -n exec-memory-avro -c conf -f exec-memory-avro.conf -Dflume.root.logger=DEBUG,console

4.測試:向日志文件中寫入數據,觀察slave收到的信息,結果如圖所示:

在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章