こんにちは! JQです。
前回は『 OSS編~FluentdでForwardを試してみる~ 』と題して、Fluentdでフォワードを試してみました。
今回は『OSS編~FluentdでForwardのStandbyを試してみる~』と題して、FluentdでフォワードのStandbyを試してみたいと思います。
Fluentd設定
1.Standbyフォワード先EC2の設定
Standbyとして利用するフォワード先EC2のFluentdに対してPrimaryと同じ設定をします。
1<source>2 type forward3 port 242244 bind 0.0.0.05</source>67<match apache.**>8 type file9 path /var/log/td-agent/forward10 time_slice_format %Y%m%d%H%M11 time_slice_wait 5m12 time_format %Y%m%dT%H%M%S%z13 compress gzip14 utc15</match>同じように以下がログに出力されていれば設定されています。
12014-07-24 17:00:09 +0900 [info]: listening fluent socket on 0.0.0.0:242242.フォワード元EC2の設定
フォワード元EC2の設定を修正します。
フォワード先としてstandbyの情報を追加します。
1<source>2 type tail3 path /var/log/httpd/access_log4 format apache25 pos_file /var/log/td-agent/apache.pos6 tag apache.access7</source>89<match apache.**>10 type forward1112 <server>13 host 172.16.0.24614 port 2422415 </server>16 <server>17 host 172.16.0.8218 port 2422419 standby20 </server>2122 flush_interval 60s23</match>下記のように2つとも登録されていれば成功です。
12014-07-24 17:10:10 +0900 [info]: adding forwarding server '172.16.0.246:24224' host="172.16.0.246" port=24224 weight=6022014-07-24 17:10:10 +0900 [info]: adding forwarding server '172.16.0.82:24224' host="172.16.0.82" port=24224 weight=60確認
3.確認
それでは確認してみましょう。
実際にフォワード元のHTTPにアクセスしながらPrimaryのFluentdを停止してみます。
1# /etc/rc.d/init.d/td-agent stop2Shutting down td-agent: [ OK ]フォワード元でPrimaryが外され、Standbyが利用されるのが確認できます。
12014-07-24 17:19:01 +0900 [warn]: detached forwarding server '172.16.0.246:24224' host="172.16.0.246" port=24224 phi=16.1325983134695722014-07-24 17:19:01 +0900 [warn]: using standby node 172.16.0.82:24224 weight=60Standbyで処理が継続されているのが確認出来ます。
1# ls -l2total 203drwxrwxrwx 2 td-agent td-agent 4096 Jul 24 16:58 buffer4-rw-r--r-- 1 td-agent td-agent 286 Jul 24 17:24 forward.201407240818_0.log.gz5-rw-r--r-- 1 td-agent td-agent 4780 Jul 24 17:19 forward.201407240819.b4feec1d07a18f6d56-rw-r--r-- 1 td-agent td-agent 3678 Jul 24 17:00 td-agent.log再度PrimaryでFluentdを起動します。
1# /etc/rc.d/init.d/td-agent start2Starting td-agent: [ OK ]フォワード元で下記のように出力され復旧しているのがわかります。
12014-07-24 17:20:51 +0900 [warn]: recovered forwarding server '172.16.0.246:24224' host="172.16.0.246" port=24224いかがでしたでしょうか?
次回もお楽しみに!!!