7
6

More than 5 years have passed since last update.

logrotate でmysqlのquery.logを小さく保つ

Last updated at Posted at 2015-10-06

開発環境で、全queryをログ出力していた場合、気がついたら数百MBになっていることがあるので対応。

参考

設定

/etc/logrotate.d/mysql
/var/log/mysql/query.log {
    minsize 10M
    rotate 0
    missingok
    create 0666 mysql mysql
    postrotate
        /opt/mysql/bin/mysqladmin flush-logs
    endscript
}
  • これで深夜に /var/log/mysql/query.log が10Mを超えていたらローテーションしてくれる。

動作確認

dry-run
logrotate -d /etc/logrotate.d/mysql
即時実行
logrotate -f /etc/logrotate.d/mysql

ログ

cat /var/lib/logrotate.status
7
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
6