❶ 什麼是 flume 日誌收集,flume的特性
您好,很高興為您解答。
Flume最早是Cloudera提供的日誌收集系統,目前是Apache下的一個孵化項目,Flume支持在日誌系統中定製各類數據發送方,用於收集數據;同時,Flume提供對數據進行簡單處理,並寫到各種數據接受方(可定製)的能力 Flume提供了從console(控制台)、RPC(Thrift-RPC)、text(文件)、tail(UNIX tail)、syslog(syslog日誌系統,支持TCP和UDP等2種模式),exec(命令執行)等數據源上收集數據的能力。
Flume採用了多Master的方式。為了保證配置數據的一致性,Flume引入了ZooKeeper,用於保存配置數據,ZooKeeper本身可保證配置數據的一致性和高可用,另外,在配置數據發生變化時,ZooKeeper可以通知Flume Master節點。Flume Master間使用gossip協議同步數據。
Flume是一個分布式、可靠、和高可用的海量日誌聚合的系統,支持在系統中定製各類數據發送方,用於收集數據;同時,Flume提供對數據進行簡單處理,並寫到各種數據接受方(可定製)的能力。
flume的特性:
(1) 可靠性
當節點出現故障時,日誌能夠被傳送到其他節點上而不會丟失。Flume提供了三種級別的可靠性保障,從強到弱依次分別為:end-to-end(收到數據agent首先將event寫到磁碟上,當數據傳送成功後,再刪除;如果數據發送失敗,可以重新發送。),Store on failure(這也是scribe採用的策略,當數據接收方crash時,將數據寫到本地,待恢復後,繼續發送),Best effort(數據發送到接收方後,不會進行確認)。
(2) 可擴展性
Flume採用了三層架構,分別為agent,collector和storage,每一層均可以水平擴展。其中,所有agent和collector由master統一管理,這使得系統容易監控和維護,且master允許有多個(使用ZooKeeper進行管理和負載均衡),這就避免了單點故障問題。
3) 可管理性
所有agent和colletor由master統一管理,這使得系統便於維護。多master情況,Flume利用ZooKeeper和gossip,保證動態配置數據的一致性。用戶可以在master上查看各個數據源或者數據流執行情況,且可以對各個數據源配置和動態載入。Flume提供了web 和shell script command兩種形式對數據流進行管理。
(4) 功能可擴展性
用戶可以根據需要添加自己的agent,collector或者storage。此外,Flume自帶了很多組件,包括各種agent(file, syslog等),collector和storage(file,HDFS等)。
如若滿意,請點擊右側【採納答案】,如若還有問題,請點擊【追問】
希望我的回答對您有所幫助,望採納!
~ O(∩_∩)O~
❷ flume怎麼採集遠程伺服器上的日誌
log4j.rootLogger=INFO,A1,R
# ConsoleAppender out
log4j.appender.A1= org. apache.log4j.ConsoleAppender
log4j.appender.A1.layout= org. apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%d{ yyyy/MM/ ddHH:mm:ss}%-5p%-10C {1} %m%n
# File out
//日誌Appender修改為flume提供的Log4jAppender
log4j.appender.R= org. apache. flume.clients.log4jappender.Log4jAppender
log4j.appender.R.File=${ catalina.home}/logs/ ultraIDCPServer.log
//日誌需要發送到的埠號,該埠要有ARVO類型的source在監聽
log4j.appender.R.Port =44444
//日誌需要發送到的主機ip,該主機運行著ARVO類型的source
log4j.appender.R.Hostname = localhost
log4j.appender.R.MaxFileSize=102400KB
# log4j.appender.R.MaxBackupIndex=5
log4j.appender.R.layout= org. apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d{ yyyy/MM/ ddHH\: mm\: ss}%-5p%-10C {1} %m%n
log4j.appender.R.encoding=UTF-8
log4j.logger.com.ultrapower.ultracollector.webservice.=INFO, webservice
log4j.appender.webservice= org. apache.log4j.FileAppender
log4j.appender.webservice.File=${ catalina.home}/logs/.log
log4j.appender.webservice.layout= org. apache.log4j.PatternLayout
log4j.appender.webservice.layout.ConversionPattern=%d{ yyyy/MM/ ddHH\: mm\: ss}%-5p[%t]%l%X-%m%n
log4j.appender.webservice.encoding=UTF-8
註:Log4jAppender繼承自AppenderSkeleton,沒有日誌文件達到特定大小,轉換到新的文件的功能
1.1.3. flume agent配置
agent1.sources = source1
agent1.sinks = sink1
agent1.channels = channel1
# Describe/configure source1
agent1.sources.source1.type = avro
agent1.sources.source1.bind = 192.168.0.141
agent1.sources.source1.port = 44444
# Describe sink1
agent1.sinks.sink1.type = FILE_ROLL
agent1.sinks.sink1.sink.directory = /home/yubojie/flume/apache-flume-1.2.0/flume-out
# Use a channel which buffers events in memory
agent1.channels.channel1.type = memory
agent1.channels.channel1.capacity = 1000
agent1.channels.channel1.transactionCapactiy = 100
# Bind the source and sink to the channel
agent1.sources.source1.channels = channel1
agent1.sinks.sink1.channel = channel1
註:生成的文件的規則為每隔固定時間間隔生成一個新的文件,文件裡面保存該時間段agent接收到的信息
1.2. 分析
1. 使用簡便,工作量小。
2. 用戶應用程序使用log4j作為日誌記錄jar包,而且項目中使用的jar包要在log4j-1.2.15版本以上,
3. 應用系統必須將flume所需jar包引入到項目中。如下所示為所有必須jar包:可能會存在jar沖突,影響應用運行
4. 能夠提供可靠的數據傳輸,使用flume log4jAppender採集日誌可以不在客戶機上啟動進程,而只通過修改logapppender直接把日誌信息發送到採集機(參見圖一),此種情況可以保證採集機接受到數據之後的數據可靠性,但是客戶機與採集機連接失敗時候數據會丟失。改進方案是在客戶機上啟動一個agent,這樣可以保證客戶機和採集機不能連通時,當能連通是日誌也被採集上來,不會發送數據的丟失(參見圖二),為了可靠性,需在客戶機上啟動進程
1.3. 日誌代碼
Log.info(「this message has DEBUG in it」);
1.4. 採集到的數據樣例
this message has DEBUG in it
this message has DEBUG in it
2. Exec source(放棄)
The problem with ExecSource and other asynchronous sources is that thesource can not guarantee that if there is a failure to put the event into theChannel the client knows about it. In such cases, the data will be lost. As afor instance, one of the most commonly requested features is thetail -F [file]-like use casewhere an application writes to a log file on disk and Flume tails the file,sending each line as an event. While this is possible, there』s an obviousproblem; what happens if the channel fills up and Flume can』t send an event?Flume has no way of indicating to the application writing the log file that itneeds to retain the log or that the event hasn』t been sent, for some reason. Ifthis doesn』t make sense, you need only know this: Your application can neverguarantee data has been received when using a unidirectional asynchronousinterface such as ExecSource! As an extension of this warning - and to becompletely clear - there is absolutely zero guarantee of event delivery whenusing this source. You have been warned.
註:即使是agent內部的可靠性都不能保證
2.1. 使用說明
2.1.1. flume agent配置
# The configuration file needs to define the sources,
# the channels and the sinks.
# Sources, channels and sinks are defined per agent,
# in this case called 'agent'
# example.conf: A single-node Flume configuration
# Name the components on this agent
agent1.sources = source1
agent1.sinks = sink1
agent1.channels = channel1
# Describe/configure source1
#agent1.sources.source1.type = avro
agent1.sources.source1.type = exec
agent1.sources.source1.command = tail -f /home/yubojie/logs/ultraIDCPServer.log
#agent1.sources.source1.bind = 192.168.0.146
#agent1.sources.source1.port = 44444
agent1.sources.source1.interceptors = a
agent1.sources.source1.interceptors.a.type = org.apache.flume.interceptor.HostInterceptor$Builder
agent1.sources.source1.interceptors.a.preserveExisting = false
agent1.sources.source1.interceptors.a.hostHeader = hostname
# Describe sink1
#agent1.sinks.sink1.type = FILE_ROLL
#agent1.sinks.sink1.sink.directory = /home/yubojie/flume/apache-flume-1.2.0/flume-out
agent1.sinks.sink1.type = hdfs
agent1.sinks.sink1.hdfs.path = hdfs://localhost:9000/user/
agent1.sinks.sink1.hdfs.fileType = DataStream
# Use a channel which buffers events in memory
agent1.channels.channel1.type = memory
agent1.channels.channel1.capacity = 1000
agent1.channels.channel1.transactionCapactiy = 100
# Bind the source and sink to the channel
agent1.sources.source1.channels = channel1
agent1.sinks.sink1.channel = channel1
2.2. 分析
1. tail方式採集日誌需要宿主主機能夠執行tail命令,應該是只有linux系統可以執行,不支持window系統日誌採集
2. EXEC採用非同步方式採集,會發生日誌丟失,即使在節點內的數據也不能保證數據的完整
3. tail方式採集需要宿主操作系統支持tail命令,即原始的windows操作系統不支持tail命令採集
2.3. 採集到的數據樣例
2012/10/26 02:36:34 INFO LogTest this message has DEBUG 中文 in it
2012/10/26 02:40:12 INFO LogTest this message has DEBUG 中文 in it
2.4. 日誌代碼
Log.info(「this message has DEBUG 中文 in it」);
3. Syslog
Passing messages using syslogprotocol doesn't work well for longer messages. The syslog appender forLog4j is hardcoded to linewrap around 1024 characters in order to comply withthe RFC. I got a sample program logging to syslog, picking it up with asyslogUdp source, with a JSON layout (to avoid new-lines in stack traces) onlyto find that anything but the smallest stack trace line-wrapped anyway. Ican't see a way to reliably reconstruct the stack trace once it is wrapped andsent through the flume chain.(註:內容不確定是否1.2版本)
Syslog TCP需要指定eventsize,默認為2500
Syslog UDP為不可靠傳輸,數據傳輸過程中可能出現丟失數據的情況。
❸ flume如何監聽日誌數
1.採集日誌文件時一個很常見的現象
採集需求:比如業務系統使用log4j生成日誌,日誌內容不斷增加,需要把追加到日誌文件中的數據實時採集到hdfs中。12
1.1.根據需求,首先定義一下3大要素:
採集源,即source—監控日誌文件內容更新:exec 『tail -F file』
下沉目標,即sink—HDFS文件系統:hdfs sink
Source和sink之間的傳遞通道—-channel,可用file channel也可以用 內存channel。
1.2.進入/home/tuzq/software/apache-flume-1.6.0-bin/agentconf,編寫配置文件tail-hdfs.conf,文件內容如下:
# Name the components on this agenta1.sources = r1a1.sinks = k1
a1.channels = c1# Describe/configure the source## exec表示flume回去調用給的命令,然後從給的命令的結果中去拿數據a1.sources.r1.type = exec## 使用tail這個命令來讀數據a1.sources.r1.command = tail -F /home/tuzq/software/flumedata/test.loga1.sources.r1.channels = c1# Describe the sink## 表示下沉到hdfs,類型決定了下面的參數a1.sinks.k1.type = hdfs## sinks.k1隻能連接一個channel,source可以配置多個a1.sinks.k1.channel = c1## 下面的配置告訴用hdfs去寫文件的時候寫到什麼位置,下面的表示不是寫死的,而是可以動態的變化的。表示輸出的目錄名稱是可變的a1.sinks.k1.hdfs.path = /flume/tailout/%y-%m-%d/%H%M/##表示最後的文件的前綴a1.sinks.k1.hdfs.filePrefix = events-## 表示到了需要觸發的時間時,是否要更新文件夾,true:表示要a1.sinks.k1.hdfs.round = true## 表示每隔1分鍾改變一次a1.sinks.k1.hdfs.roundValue = 1## 切換文件的時候的時間單位是分鍾a1.sinks.k1.hdfs.roundUnit = minute## 表示只要過了3秒鍾,就切換生成一個新的文件a1.sinks.k1.hdfs.rollInterval = 3## 如果記錄的文件大於20位元組時切換一次a1.sinks.k1.hdfs.rollSize = 20## 當寫了5個事件時觸發a1.sinks.k1.hdfs.rollCount = 5## 收到了多少條消息往dfs中追加內容a1.sinks.k1.hdfs.batchSize = 10## 使用本地時間戳a1.sinks.k1.hdfs.useLocalTimeStamp = true#生成的文件類型,默認是Sequencefile,可用DataStream:為普通文本a1.sinks.k1.hdfs.fileType = DataStream# Use a channel which buffers events in memory##使用內存的方式a1.channels.c1.type = memory
a1.channels.c1.capacity = 1000a1.channels.c1.transactionCapacity = 100# Bind the source and sink to the channela1.sources.r1.channels = c1
a1.sinks.k1.channel = 940414243444546474849
1.3.編寫完成之後,啟動flume,執行的命令是:
[root@hadoop1 flumedata]#cd /home/tuzq/software/apache-flume-1.6.0-bin/agentconf[root@hadoop1 flumedata]#bin/flume-ng agent -c conf -f agentconf/tail-hdfs.conf -n a112
1.4.通過寫一個死循環往test.log中寫數據的方式模式日誌文件增長
編寫shell腳本,模擬日誌增長變化。
[root@hadoop1 flumedata]# cd /home/tuzq/software/flumedata[root@hadoop1 flumedata]# while true>do> date >> test.log> sleep 2> done123456
查看日誌變化
[root@hadoop1 ~]# cd /home/tuzq/software/flumedata/[root@hadoop1 flumedata]# lsaccess.log error.log test.log[root@hadoop1 flumedata]# tail -f test.log 2017年 06月 13日 星期二 22:02:22 CST2017年 06月 13日 星期二 22:02:24 CST2017年 06月 13日 星期二 22:02:26 CST2017年 06月 13日 星期二 22:02:28 CST2017年 06月 13日 星期二 22:02:30 CST2017年 06月 13日 星期二 22:02:32 CST12345678910
通過上面的文件,可以看到test.log在不停的追加數據。
到hdfs中進行查看,效果如下:
[root@hadoop1 ~]# hdfs dfs -ls /Found 5 items
drwxr-xr-x - root supergroup 0 2017-06-13 12:01 /40000drwxr-xr-x - root supergroup 0 2017-06-13 22:01 /flume
-rw-r--r-- 3 root supergroup 3719 2017-06-10 12:11 /kms.sh
drwxrwxrwx - root supergroup 0 2017-06-10 22:06 /tmp
drwxr-xr-x - root supergroup 0 2017-06-10 22:27 /user
[root@hadoop1 ~]# hdfs dfs -ls /flumeFound 1 items
drwxr-xr-x - root supergroup 0 2017-06-13 22:01 /flume/tailout
[root@hadoop1 ~]# hdfs dfs -ls /flume/tailoutFound 1 items
drwxr-xr-x - root supergroup 0 2017-06-13 22:03 /flume/tailout/17-06-13[root@hadoop1 ~]# hdfs dfs -ls /flume/tailout/17-06-13Found 4 items
drwxr-xr-x - root supergroup 0 2017-06-13 22:01 /flume/tailout/17-06-13/2201drwxr-xr-x - root supergroup 0 2017-06-13 22:03 /flume/tailout/17-06-13/2202drwxr-xr-x - root supergroup 0 2017-06-13 22:04 /flume/tailout/17-06-13/2203drwxr-xr-x - root supergroup 0 2017-06-13 22:04 /flume/tailout/17-06-13/2204[root@hadoop1 ~]# hdfs dfs -ls /flume/tailout/17-06-13Found 5 items
drwxr-xr-x - root supergroup 0 2017-06-13 22:01 /flume/tailout/17-06-13/2201drwxr-xr-x - root supergroup 0 2017-06-13 22:03 /flume/tailout/17-06-13/2202drwxr-xr-x - root supergroup 0 2017-06-13 22:04 /flume/tailout/17-06-13/2203drwxr-xr-x - root supergroup 0 2017-06-13 22:05 /flume/tailout/17-06-13/2204drwxr-xr-x - root supergroup 0 2017-06-13 22:05 /flume/tailout/17-06-13/2205[root@hadoop1 /]# hdfs dfs -ls /flume/tailout/17-06-13Found 6 items
drwxr-xr-x - root supergroup 0 2017-06-13 22:01 /flume/tailout/17-06-13/2201drwxr-xr-x - root supergroup 0 2017-06-13 22:03 /flume/tailout/17-06-13/2202drwxr-xr-x - root supergroup 0 2017-06-13 22:04 /flume/tailout/17-06-13/2203drwxr-xr-x - root supergroup 0 2017-06-13 22:05 /flume/tailout/17-06-13/2204drwxr-xr-x - root supergroup 0 2017-06-13 22:06 /flume/tailout/17-06-13/2205drwxr-xr-x - root supergroup 0 2017-06-13 22:06 /flume/tailout/17-06-13/2206[root@hadoop1 /]
通過上面的案例可以知道,增加的日誌文件已經被寫入到HDFS中。
❹ 大數據分析應該掌握哪些基礎知識
Java基礎語法
· 分支結構if/switch
· 循環結構for/while/do while
· 方法聲明和調用
· 方法重載
· 數組的使用
· 命令行參數、可變參數
IDEA
· IDEA常用設置、常用快捷鍵
· 自定義模板
· 關聯Tomcat
· Web項目案例實操
面向對象編程
· 封裝、繼承、多態、構造器、包
· 異常處理機制
· 抽象類、介面、內部類
· 常有基礎API、集合List/Set/Map
· 泛型、線程的創建和啟動
· 深入集合源碼分析、常見數據結構解析
· 線程的安全、同步和通信、IO流體系
· 反射、類的載入機制、網路編程
Java8/9/10/11新特性
· Lambda表達式、方法引用
· 構造器引用、StreamAPI
· jShell(JShell)命令
· 介面的私有方法、Optional加強
· 局部變數的類型推斷
· 更簡化的編譯運行程序等
MySQL
· DML語言、DDL語言、DCL語言
· 分組查詢、Join查詢、子查詢、Union查詢、函數
· 流程式控制制語句、事務的特點、事務的隔離級別等
JDBC
· 使用JDBC完成資料庫增刪改查操作
· 批處理的操作
· 資料庫連接池的原理及應用
· 常見資料庫連接池C3P0、DBCP、Druid等
Maven
· Maven環境搭建
· 本地倉庫&中央倉庫
· 創建Web工程
· 自動部署
· 持續繼承
· 持續部署
Linux
· VI/VIM編輯器
· 系統管理操作&遠程登錄
· 常用命令
· 軟體包管理&企業真題
Shell編程
· 自定義變數與特殊變數
· 運算符
· 條件判斷
· 流程式控制制
· 系統函數&自定義函數
· 常用工具命令
· 面試真題
Hadoop
· Hadoop生態介紹
· Hadoop運行模式
· 源碼編譯
· HDFS文件系統底層詳解
· DN&NN工作機制
· HDFS的API操作
· MapRece框架原理
· 數據壓縮
· Yarn工作機制
· MapRece案例詳解
· Hadoop參數調優
· HDFS存儲多目錄
· 多磁碟數據均衡
· LZO壓縮
· Hadoop基準測試
Zookeeper
· Zookeeper數據結果
· 內部原理
· 選舉機制
· Stat結構體
· 監聽器
· 分布式安裝部署
· API操作
· 實戰案例
· 面試真題
· 啟動停止腳本
HA+新特性
· HDFS-HA集群配置
Hive
· Hive架構原理
· 安裝部署
· 遠程連接
· 常見命令及基本數據類型
· DML數據操作
· 查詢語句
· Join&排序
· 分桶&函數
· 壓縮&存儲
· 企業級調優
· 實戰案例
· 面試真題
Flume
· Flume架構
· Agent內部原理
· 事務
· 安裝部署
· 實戰案例
· 自定義Source
· 自定義Sink
· Ganglia監控
Kafka
· 消息隊列
· Kafka架構
· 集群部署
· 命令行操作
· 工作流程分析
· 分區分配策略
· 數據寫入流程
· 存儲策略
· 高階API
· 低級API
· 攔截器
· 監控
· 高可靠性存儲
· 數據可靠性和持久性保證
· ISR機制
· Kafka壓測
· 機器數量計算
· 分區數計算
· 啟動停止腳本
DataX
· 安裝
· 原理
· 數據一致性
· 空值處理
· LZO壓縮處理
Scala
· Scala基礎入門
· 函數式編程
· 數據結構
· 面向對象編程
· 模式匹配
· 高階函數
· 特質
· 註解&類型參數
· 隱式轉換
· 高級類型
· 案例實操
Spark Core
· 安裝部署
· RDD概述
· 編程模型
· 持久化&檢查點機制
· DAG
· 運算元詳解
· RDD編程進階
· 累加器&廣播變數
Spark SQL
· SparkSQL
· DataFrame
· DataSet
· 自定義UDF&UDAF函數
Spark Streaming
· SparkStreaming
· 背壓機制原理
· Receiver和Direct模式原理
· Window原理及案例實操
· 7x24 不間斷運行&性能考量
Spark內核&優化
· 內核源碼詳解
· 優化詳解
Hbase
· Hbase原理及架構
· 數據讀寫流程
· API使用
· 與Hive和Sqoop集成
· 企業級調優
Presto
· Presto的安裝部署
· 使用Presto執行數倉項目的即席查詢模塊
Ranger2.0
· 許可權管理工具Ranger的安裝和使用
Azkaban3.0
· 任務調度工具Azkaban3.0的安裝部署
· 使用Azkaban進行項目任務調度,實現電話郵件報警
Kylin3.0
· Kylin的安裝部署
· Kylin核心思想
· 使用Kylin對接數據源構建模型
Atlas2.0
· 元數據管理工具Atlas的安裝部署
Zabbix
· 集群監控工具Zabbix的安裝部署
DolphinScheler
· 任務調度工具DolphinScheler的安裝部署
· 實現數倉項目任務的自動化調度、配置郵件報警
Superset
· 使用SuperSet對數倉項目的計算結果進行可視化展示
Echarts
· 使用Echarts對數倉項目的計算結果進行可視化展示
Redis
· Redis安裝部署
· 五大數據類型
· 總體配置
· 持久化
· 事務
· 發布訂閱
· 主從復制
Canal
· 使用Canal實時監控MySQL數據變化採集至實時項目
Flink
· 運行時架構
· 數據源Source
· Window API
· Water Mark
· 狀態編程
· CEP復雜事件處理
Flink SQL
· Flink SQL和Table API詳細解讀
Flink 內核
· Flink內核源碼講解
· 經典面試題講解
Git&GitHub
· 安裝配置
· 本地庫搭建
· 基本操作
· 工作流
· 集中式
ClickHouse
· ClickHouse的安裝部署
· 讀寫機制
· 數據類型
· 執行引擎
DataV
· 使用DataV對實時項目需求計算結果進行可視化展示
sugar
· 結合Springboot對接網路sugar實現數據可視化大屏展示
Maxwell
· 使用Maxwell實時監控MySQL數據變化採集至實時項目
ElasticSearch
· ElasticSearch索引基本操作、案例實操
Kibana
· 通過Kibana配置可視化分析
Springboot
· 利用Springboot開發可視化介面程序
❺ 如何利用flume從syslog獲取日誌
可以用幾個命令能幫助呢
grep '查找關鍵欄位' /var/log/messages|head -n 行數
grep '查找關鍵欄位' /var/log/messages|tail -n 行數
可以用幾個命令能幫助呢
grep '查找關鍵欄位' /var/log/messages|head -n 行數
grep '查找關鍵欄位' /var/log/messages|tail -n 行數