今天邮件告警slave同步失败。
登录slave查询了下状态:
SHOW SLAVE status;
结果:
Slave_IO_Running:yes
Slave_SQL_Runing:no
Last_Errno:1418
Last_Error:Error 'This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)' on query. Default database: 'd_union_loan'. Query: 'CREATE DEFINER=`root`@`%` FUNCTION `currval`(seq_name VARCHAR(50)) RETURNS int(11)
BEGIN
DECLARE value int(11);
SET value = 0;
SELECT current_value INTO value
FROM t_enfo_sequence
WHERE name = seq_name;
RETURN value;
END'
查询了下这个问题是因为如果开启mysql的bin-log,创建函数时需要指定参数,
当初在主库加set global log_bin_trust_function_creators=TRUE;参数忽略掉这个问题,忘记在从库加了。
解决方案:
STOP SLAVE;
set global log_bin_trust_function_creators=TRUE;
START SLAVE;
然后查看状态:
SHOW SLAVE status;
结果:
Slave_IO_Running:yes
Slave_SQL_Runing:yes
解决问题