Think before you speak, read before you think.

mysql binlog参数设定

mysql使用binlog的好处就是很灵活的进行数据恢复

binlog设定不对会使磁盘用满报错,出现这种情况首先将数据库里的binlog清理

根据binlog名进行之前的删除

PURGE {MASTER | BINARY} LOGS TO 'log_name';

例:删除mysql-bin.000123之前的binlog

PURGE MASTER LOGS TO 'mysql-bin.000123';

根据binlog保留的时间进行删除

PURGE {MASTER | BINARY} LOGS BEFORE 'date';

例删除2014-02-19 22:46:26之前的binlog

PURGE MASTER LOGS BEFORE '2014-02-19 22:46:26';

删除7天前的binlog

PURGE MASTER LOGS BEFORE DATE_SUB( NOW( ), INTERVAL 7 DAY);

故障处理完了,现在要对mysql的binlog保留时间进行调整

可在my.cnf中设定参数,重启mysql

expire_logs_days = 7

不能重启mysql,则需要在mysql命令行中设置,需要flush logs,否则参数不生效过些天又会用满

mysql> set global expire_logs_days = 7;
mysql> flush logs;

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *