MySQL慢查询日志和错误日志按天轮询
MySQL慢查询日志和错误日志按天轮询
问题背景:
为便于问题排查和减小日志文件大小,需对慢查询日志和错误日志按天轮询
轮询脚本(/data/scripts/mysql-log-rotate):
"/data/dbdata/otherlog/slow_query.log" "/data/dbdata/otherlog/mysql_error.log" {
create 660 mysql mysql
dateext
notifempty
daily
maxage 60
rotate 30
missingok
compress
olddir /data/dbdata/otherlog
postrotate
if /usr/local/mysql/bin/mysqladmin ping -uroot -S /var/run/mysql/mysql.sock &>/dev/null; then
/usr/local/mysql/bin/mysqladmin flush-logs -uroot -S /var/run/mysql/mysql.sock
fi
endscript
}
CRONTAB信息:
00 00 * * * (/usr/sbin/logrotate -f /data/scripts/mysql-log-rotate >/dev/null 2>&1)
MySQL慢查询开启及分析方法
分析MySQL慢查询日志的好工具--mysqlsla
MySQL前缀索引导致的慢查询
【体系结构】MySQL 日志文件--慢查询日志
MySQL调优三步曲(慢查询、explain profile)
评论暂时关闭