我们在master数据库中创建了一个触发器,但触发器没有出现在slave数据库中。
以下是创建触发器的示例:
CREATE TRIGGER filter_pos_transaction_delivery_combo_details BEFORE INSERT ON `pos-transaction_delivery_combo_details`
for each row
begin
DECLARE msg VARCHAR(200);
SET @store_code = (SELECT value FROM `admin-settings` WHERE attribute = 'local_store_code' LIMIT 1);
if STRCMP(new.store_code,@store_code) != 0 then
if STRCMP( @store_code,'MAINDB') != 0 then
set msg = "SKIPPING INSERTION: THIS DATA IS NOT FOR THIS LOCAL DB - pos-transaction_delivery_combo_details ";
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = msg;
end if;
end if;
end;
这是cnf配置:
[mysqld]
user = mysql
port = 3306
datadir = /data/mysql/
pid-file = /data/mysql/fusion-maindb.pid
socket = /data/mysql/fusion-maindb.sock
log_error = /datalog/mysql_error_log/mysql_error.log
## Replication and Logging Settings ###
server_id = 11111111
log_bin = /datalog/rep_binlogs/maindb-bin.log
binlog_do_db = fusion
replicate_do_db = fusion
max_binlog_size = 1000M
slave-skip-errors = 1644,1007,1062,1449,1146,1062
innodb_buffer_pool_size = 8000M
log_slave_updates = 1
skip-external-locking
sync_binlog = 1
slave_net_timeout = 60
innodb_lock_wait_timeout = 120
binlog_format = STATEMENT
slave_compressed_protocol = 1
wait_timeout = 300
interactive_timeout = 300
答案 0 :(得分:-1)
检查您的binlog格式:
使用基于语句的复制时,从站上的触发器由在主站上执行的语句执行(并复制到从站)。
使用基于行的复制时,由于在主服务器上运行然后复制到从服务器的语句,因此不会在从服务器上执行触发器。相反,当使用基于行的复制时,在主服务器上执行触发器所引起的更改将应用于从服务器。