fluentd主从配置
? ? ? ?fluentd是一個免費的、完全開源的日志管理工具,可以對日志進行收集、處理、存儲。對于一些高流量的網站或者特殊的架構,需要fluentd高可用配置。
? ? ? ?以下是在測試環境搭建模擬fluentd主從配置,模擬主從切換。
?
| 服務器 | 服務 | 
| 192.168.199.1 | elasticsearch | 
| 192.168.199.2 | kafka | 
| 192.168.199.3 | fluentd(主) | 
| 192.168.199.4 | fluentd(備) | 
fluentd(主)配置
1 <source> 2 @type kafka_group 3 brokers 192.168.199.2:9092 4 consumer_group testlog 5 topics testlog 6 format json 7 message_key message 8 add_prefix test 9 </source> 10 <match test.testlog> 11 type elasticsearch 12 hosts 192.168.199.1:9200 13 reload_connections false 14 time_key_format %Y-%m-%dT%H:%M:%S.%N%z 15 logstash_format true 16 logstash_prefix testlog 17 utc_index true 18 include_tag_key true 19 </match> 20 <source> 21 @type forward 22 port 24224 23 </source> 24 <source> 25 @type http 26 port 8888 27 </source> 28 <match mytag.test> 29 @type forward 30 <server> 31 host 192.168.199.3 32 port 24224 33 </server> 34 <server> 35 host 192.168.199.4 36 port 24224 37 standby 38 </server> 39 flush_interval 60s 40 </match> View Codefluentd(備)配置
1 <source> 2 @type kafka_group 3 brokers 192.168.199.2:9092 4 consumer_group testlog 5 topics testlog 6 format json 7 message_key message 8 add_prefix test 9 </source> 10 <match test.testlog> 11 type elasticsearch 12 hosts 192.168.199.1:9200 13 reload_connections false 14 time_key_format %Y-%m-%dT%H:%M:%S.%N%z 15 logstash_format true 16 logstash_prefix testlog 17 utc_index true 18 include_tag_key true 19 </match> 20 <source> 21 @type forward 22 port 24224 23 </source> 24 <match mytag.test> 25 @type forward 26 <server> 27 host 192.168.199.3 28 port 24224 29 </server> 30 <server> 31 host 192.168.199.4 32 port 24224 33 standby 34 </server> 35 flush_interval 60s 36 </match> View Code?
故障模擬:
? ?1.按主備順序啟動,查看日志,主節點日志會提示監聽本地24224端口,并連接ES;備節點日志會提示監聽本地24224端口
? ?2.模擬主宕(停止服務),備節點日志會提示獨立代理服務器(主),使用備節點,連接ES。
? ?3.當主節點恢復之后,備節點過一段時間(大概十分鐘左右),備節點日志提示主服務恢復,主節點日志會提示監聽本地24224端口。
?fluentd主備依次啟動后,顯示日志如下:
主日志: 2017-12-08 14:07:29 +0800 [info]: listening fluent socket on 0.0.0.0:24224 2017-12-08 14:08:30 +0800 [info]: Connection opened to Elasticsearch cluster => {:host=>"192.168.199.1", :port=>9200, :scheme=>"http"}備日志: 2017-12-08 14:07:40 +0800 [info]: listening fluent socket on 0.0.0.0:24224
?模擬將主節點宕掉,備節點會顯示如下日志:
2017-12-08 14:13:39 +0800 [warn]: detached forwarding server '192.168.199.3:24224' host="192.168.199.3" port=24224 phi=16.068447980484642 2017-12-08 14:13:39 +0800 [warn]: using standby node 192.168.199.4:24224 weight=60 2017-12-08 14:14:41 +0800 [info]: Connection opened to Elasticsearch cluster => {:host=>"192.168.199.1", :port=>9200, :scheme=>"http"}?當主節點恢復后,備節點會顯示如下日志:
2017-12-08 14:20:38 +0800 [warn]: recovered forwarding server '192.168.199.3:24224' host="192.168.199.3" port=24224?
主備流程架構圖:
?
?具體可參考:https://docs.fluentd.org/v0.12/articles/high-availability
轉載于:https://www.cnblogs.com/mliu/p/8600756.html
總結
以上是生活随笔為你收集整理的fluentd主从配置的全部內容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: 牛客网 牛客小白月赛1 H.写真がとどい
- 下一篇: CTS类型
