Linux

Fluentd エージェントからAggregatorにApacheログをシンプルに出力

 

 

エージェント側

# vi /etc/security/limits.conf

root soft nofile 65536
root hard nofile 65536
* soft nofile 65536
* hard nofile 65536

 

# vi /etc/sysctl.conf

net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.ip_local_port_range = 10240    65535



※デフォルトで設定されていた


net.core.somaxconn = 1024
net.core.netdev_max_backlog = 5000
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_wmem = 4096 12582912 16777216
net.ipv4.tcp_rmem = 4096 12582912 16777216
net.ipv4.tcp_max_syn_backlog = 8096
net.ipv4.tcp_slow_start_after_idle = 0
net.ipv4.tcp_tw_reuse = 1
net.ipv4.ip_local_port_range = 10240 65535

 

# hostnamectl set-hostname Apache-Fluentd-Node
# reboot

 

# ulimit -n
65536

 

 

# yum install httpd
# systemctl start httpd
# systemctl enable httpd
# chmod o+x /var/log/httpd

 

 

# curl -L https://toolbelt.treasuredata.com/sh/install-redhat-td-agent2.5.sh | sh
# systemctl start td-agent

 

動作テスト

# curl -X POST -d 'json={"json":"優テスト"}' http://localhost:8888/debug.test

 

# tail -3 /var/log/td-agent/td-agent.log

2018-10-26 15:27:23 +0900 [info]: listening fluent socket on 0.0.0.0:24224
2018-10-26 15:27:23 +0900 [info]: listening dRuby uri="druby://127.0.0.1:24230" object="Engine"
2018-10-26 15:29:50 +0900 debug.test: {"json":"優テスト"}

 

# rm -rf /etc/td-agent/td-agent.conf

 

# vi /etc/td-agent/td-agent.conf
 
 
<source>
  type tail
  path /var/log/httpd/access_log
  tag log.yuulinux.tokyo-access
  pos_file /var/log/td-agent/.pos
  format apache2
</source>

<match **>
  type forward
  send_timeout 60s
  <server>
    host 133.130.116.232
    port 24224
  </server>
</match>

 

 

 

# systemctl restart td-agent
# systemctl enable td-agent

 

 

 

Aggregator側

# vi /etc/security/limits.conf

root soft nofile 65536
root hard nofile 65536
* soft nofile 65536
* hard nofile 65536

 

# vi /etc/sysctl.conf

net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.ip_local_port_range = 10240    65535



※デフォルトで設定されていた


net.core.somaxconn = 1024
net.core.netdev_max_backlog = 5000
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_wmem = 4096 12582912 16777216
net.ipv4.tcp_rmem = 4096 12582912 16777216
net.ipv4.tcp_max_syn_backlog = 8096
net.ipv4.tcp_slow_start_after_idle = 0
net.ipv4.tcp_tw_reuse = 1
net.ipv4.ip_local_port_range = 10240 65535

 

# hostnamectl set-hostname tdSrv
# reboot

 

# ulimit -n
65536

 

# curl -L https://toolbelt.treasuredata.com/sh/install-redhat-td-agent2.5.sh | sh
# systemctl start td-agent

 

動作テスト

# curl -X POST -d 'json={"json":"message"}' http://localhost:8888/debug.test

 

# tail -3 /var/log/td-agent/td-agent.log

2018-10-26 15:27:23 +0900 [info]: listening fluent socket on 0.0.0.0:24224
2018-10-26 15:27:23 +0900 [info]: listening dRuby uri="druby://127.0.0.1:24230" object="Engine"
2018-10-26 15:29:50 +0900 debug.test: {"json":"優テスト"}

 

# vi /etc/td-agent/td-agent.conf


<source>
    type forward
    port 24224
    bind 0.0.0.0
</source>


<match log.yuulinux.tokyo-access>
    type file
    path /var/log/fluentd/yuulinux.tokyo-access
  <buffer>
    type file
    path /var/log_buffer/apache-buffer
    flush_mode interval
    flush_interval 60s
  </buffer>
</match>

 

# mkdir /var/log/fluentd
# chown td-agent:td-agent /var/log/fluentd

 

# systemctl enable td-agent
# systemctl restart td-agent

 

# ls -laht /var/log/fluentd/

total 316K
-rw-r--r--   1 td-agent td-agent 308K Oct 28 22:56 yuulinux.tokyo-access.20181028.b5794a49412530255
drwxr-xr-x   2 td-agent td-agent 4.0K Oct 28 22:54 .
drwxr-xr-x. 12 root     root     4.0K Oct 28 22:22 ..

 

 

 

Amazonおすすめ

iPad 9世代 2021年最新作

iPad 9世代出たから買い替え。安いぞ!🐱 初めてならiPad。Kindleを外で見るならiPad mini。ほとんどの人には通常のiPadをおすすめします><

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

日本語が含まれない投稿は無視されますのでご注意ください。(スパム対策)