セキュリティ要件等で、各サーバのログを長期保存しなければいけない場合、 サーバ上(EBS)に全ログを保存するとエライことになるので、S3に退避する 方法をメモ。 Linux標準の logrotate + s3cmd を駆使して実現できます。 # 巷で話題のfluentdやfluent-agent-liteも検討しましたが、やりたい事は # 単純で、EC2外に大量の過去ログを保存したいだけなので、logrotateでさく # っと実装。 /etc/logrotate.d/syslog の場合 /var/log/messages /var/log/xxxx { copytruncate sharedscripts postrotate /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true ends
![S3でログ収集(logrotate) - 雑多なインフラエンジニア日記](https://cdn-ak-scissors.b.st-hatena.com/image/square/66e8d3d9400c09ed2e1af2d0aebcec4abde4a317/height=288;version=1;width=512/http%3A%2F%2Fcdn-ak.f.st-hatena.com%2Fimages%2Ffotolife%2Fj%2Fjinjin252525%2F20130513%2F20130513182759.jpg)