We created a trigger in the master database but the trigger does not show up in the slave database.
Here is an example of the create trigger:
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;
Here is the cnf configuration:
[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
Check your binlog format:
When using statement-based replication, triggers on the slave are executed by statements that are executed on the master (and replicated to the slave).
When using row-based replication, triggers are not executed on the slave due to statements that were run on the master and then replicated to the slave. Instead, when using row-based replication, the changes caused by executing the trigger on the master are applied on the slave.