首页 > 技术文章 > binlog_format日志错误

steven9898 2018-05-31 10:28 原文

客户磁盘空间不够用,发现mysql的err日志文件已每天大概600M-800M的速度增长,开头考虑作日志切割,打开发现,整个7.8G的文件里面百分之99的文件全部是如下所示的warning警告信息

180531 9:21:01 [Warning] Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. INSERT... ON DUPLICATE KEY UPDATE on a table with more than one UNIQUE KEY is unsafe Statement: insert into log_user_active_degree(corp_id,user_id,statistic_time,startTime,endTime,login_count) values(1001,'archive@globalegrow.com','2018-05-31 09:20:44','2018-05-31 08:00:00','2018-05-31 10:00:00','1') on duplicate key update login_count=login_count+1
180531 9:21:01 [Warning] Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. INSERT... ON DUPLICATE KEY UPDATE on a table with more than one UNIQUE KEY is unsafe Statement: insert into log_user_active_degree(corp_id,user_id,statistic_time,startTime,endTime,login_count) values(1001,'dongzhao@globalegrow.com','2018-05-31 09:20:44','2018-05-31 08:00:00','2018-05-31 10:00:00','1') on duplicate key update login_count=login_count+1
180531 9:21:01 [Warning] Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. INSERT... ON DUPLICATE KEY UPDATE on a table with more than one UNIQUE KEY is unsafe Statement: insert into log_user_active_degree(corp_id,user_id,statistic_time,startTime,endTime,login_count) values(1001,'diana_lee@globalegrow.com','2018-05-31 09:20:44','2018-05-31 08:00:00','2018-05-31 10:00:00','1') on duplicate key update login_count=login_count+1
180531 9:21:02 [Warning] Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave. Statement: insert into rm_popmail_mid (userMailName,mail_addr,isAutoPop,status,days,createtime,appId,id,starttime) select userMailName,mail_addr,isAutoPop,9,if(flag=0, 0, if(flag=1, 7, 30)) as days,sysdate(),appId,id,sysdate() from rm_user_popmail a where appid=1 and isAutoPop=1 and lastrecvtime<='2018-05-31 09:11:17' and authenticated in (0,1) and not exists (select 'X' from rm_popmail_mid b where b.id = a.id)

将binlog_fomat进行修改

set session binlog_format='row';

set global binlog_format=row;

发现仍然不起作用,只能变相的去做改变了,要么修改存储过程,要么写个脚本凌晨清空,

推荐阅读