1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
|
include/master-slave.inc
[connection master]
#
# MDEV-15530 Variable replicate_rewrite_db cannot be found
# in "show global variables"
#
# Create DBs and verify that slave has to be stopped before setting sys var
connection slave;
select @@session.server_id;
@@session.server_id
2
create database replica_db1;
create database y;
create database test_replica;
SELECT @@GLOBAL.replicate_rewrite_db, 'primary_db1->replica_db1,x->y' as 'Replicate_Rewrite_DB from SHOW SLAVE STATUS';
@@GLOBAL.replicate_rewrite_db Replicate_Rewrite_DB from SHOW SLAVE STATUS
primary_db1->replica_db1,x->y primary_db1->replica_db1,x->y
# Create DBs and tables on primary
connection master;
create database primary_db1;
create database x;
use primary_db1;
create table my_table (t int);
insert into my_table values (2),(4);
use x;
create table my_table (t int);
insert into my_table values (654),(532);
include/save_master_gtid.inc
# Check replica
connection slave;
include/sync_with_master_gtid.inc
include/diff_tables.inc [master:primary_db1.my_table,slave:replica_db1.my_table]
include/diff_tables.inc [master:x.my_table,slave:y.my_table]
SELECT @@GLOBAL.replicate_rewrite_db;
@@GLOBAL.replicate_rewrite_db
primary_db1->replica_db1,x->y
show tables from replica_db1;
Tables_in_replica_db1
my_table
select * from replica_db1.my_table;
t
2
4
show tables from y;
Tables_in_y
my_table
select * from y.my_table;
t
654
532
# Set replica sys var replicate_rewrite_db
connection slave;
SET @@GLOBAL.replicate_rewrite_db="test_master->test_replica";
ERROR HY000: This operation cannot be performed as you have a running slave ''; run STOP SLAVE '' first
include/stop_slave.inc
SET @save_replicate_rewrite_db = @@GLOBAL.replicate_rewrite_db;
SELECT @@GLOBAL.replicate_rewrite_db;
@@GLOBAL.replicate_rewrite_db
primary_db1->replica_db1,x->y
SET @@GLOBAL.replicate_rewrite_db="test_master->test_replica";
SHOW DATABASES like 'test_replica';
Database (test_replica)
test_replica
include/start_slave.inc
SELECT @@GLOBAL.replicate_rewrite_db, 'test_master->test_replica' as 'Replicate_Rewrite_DB from SHOW SLAVE STATUS';
@@GLOBAL.replicate_rewrite_db Replicate_Rewrite_DB from SHOW SLAVE STATUS
test_master->test_replica test_master->test_replica
# Create DB and tables on primary
connection master;
create database test_master;
use test_master;
create table my_table (t int);
insert into my_table values (1),(3);
include/save_master_gtid.inc
# Ensure that the replica receives all of the primary's events without
# error
connection slave;
include/sync_with_master_gtid.inc
Last_SQL_Error =
Last_SQL_Errno = 0
SELECT @@GLOBAL.replicate_rewrite_db;
@@GLOBAL.replicate_rewrite_db
test_master->test_replica
SHOW tables from test_replica;
Tables_in_test_replica
my_table
select * from test_replica.my_table;
t
1
3
include/diff_tables.inc [master:test_master.my_table,slave:test_replica.my_table]
# Update of values on primary for DB not set in replication_rewrite_db
include/stop_slave.inc
include/reset_slave.inc
connection master;
use x;
insert into my_table values (314);
select * from my_table;
t
654
532
314
include/save_master_gtid.inc
connection slave;
include/start_slave.inc
SELECT @@GLOBAL.replicate_rewrite_db;
@@GLOBAL.replicate_rewrite_db
test_master->test_replica
include/sync_with_master_gtid.inc
select * from y.my_table;
t
654
532
# Dynamic updates to the replication filter should be lost after server restart
connection slave;
SELECT @@GLOBAL.replicate_rewrite_db;
@@GLOBAL.replicate_rewrite_db
test_master->test_replica
connection master;
use x;
insert into my_table values (1000);
select * from my_table;
t
654
532
314
1000
include/save_master_gtid.inc
connection slave;
include/stop_slave.inc
include/reset_slave.inc
include/rpl_restart_server.inc [server_number=2]
CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_MYPORT, MASTER_USER='root', MASTER_SSL_VERIFY_SERVER_CERT=0;
connection slave;
include/start_slave.inc
SELECT @@GLOBAL.replicate_rewrite_db;
@@GLOBAL.replicate_rewrite_db
primary_db1->replica_db1,x->y
include/sync_with_master_gtid.inc
select * from y.my_table;
t
654
532
314
1000
# Cleanup
connection master;
drop database test_master;
drop database primary_db1;
drop database x;
include/save_master_gtid.inc
connection slave;
include/sync_with_master_gtid.inc
drop database test_replica;
drop database replica_db1;
drop database y;
include/stop_slave.inc
include/start_slave.inc
include/rpl_end.inc
|