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 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
|
include/master-slave.inc
[connection master]
#
# MDEV-33342 Add a replication MTR test cloning the slave with mariadb-backup
#
connection slave;
stop slave;
change master to master_use_gtid=no;
start slave;
connection master;
connection slave;
##############################################################
### Initial block with some transactions
### Slave: Make sure replication is not using GTID
connection slave;
# Using_Gtid=No
### Master: Create and populate t1
connection master;
CREATE TABLE t1(a TEXT) ENGINE=InnoDB CHARSET=latin1;
START TRANSACTION;
INSERT INTO t1 VALUES ('tr#00:stmt#00 - slave run#0, before backup');
INSERT INTO t1 VALUES ('tr#00:stmt#01 - slave run#0, before backup');
INSERT INTO t1 VALUES ('tr#00:stmt#02 - slave run#0, before backup');
COMMIT;
connection slave;
##############################################################
### Run the last transaction before mariadb-backup --backup
### Remember SHOW MASTER STATUS and @@gtid_binlog_pos
### before and after the transaction.
### Master: Rember MASTER STATUS and @@gtid_binlog_pos before tr#01
connection master;
### Slave: Remember MASTER STATUS and @@gtid_binlog_pos before tr#01
connection slave;
### Master: Run the actual last transaction before the backup
connection master;
START TRANSACTION;
INSERT INTO t1 VALUES ('tr#01:stmt#00 - slave run#0, before backup');
INSERT INTO t1 VALUES ('tr#01:stmt#01 - slave run#0, before backup');
INSERT INTO t1 VALUES ('tr#01:stmt#02 - slave run#0, before backup');
COMMIT;
connection slave;
### Master: Remember MASTER STATUS and @@gtid_binlog_pos after tr#01
connection master;
### Slave: Remember MASTER STATUS and @@gtid_binlog_pos after tr#01
connection slave;
##############################################################
### Running `mariadb-backup --backup,--prepare` and checking
### that mariadb_backup_slave_info and mariadb_backup_binlog_info are OK
### Slave: Create a backup
### Slave: Prepare the backup
### Slave: xtrabackup files:
############################ mariadb_backup_slave_info
CHANGE MASTER TO MASTER_LOG_FILE='master_after_tr01_show_master_status_file', MASTER_LOG_POS=master_after_tr01_show_master_status_position;
############################ mariadb_backup_binlog_info
slave_after_tr01_show_master_status_file slave_after_tr01_show_master_status_position slave_after_tr01_gtid_binlog_pos
############################
##############################################################
### Run more transactions after the backup:
### - while the slave is still running, then
### - while the slave is shut down
### Master: Run another transaction while the slave is still running
connection master;
START TRANSACTION;
INSERT INTO t1 VALUES ('tr#02:stmt#00 - slave run#0, after backup');
INSERT INTO t1 VALUES ('tr#02:stmt#01 - slave run#0, after backup');
INSERT INTO t1 VALUES ('tr#02:stmt@02 - slave run#0, after backup');
COMMIT;
connection slave;
### Master: Remember MASTER STATUS and @@gtid_binlog_pos after tr#02
connection master;
### Slave: Remember MASTER STATUS and @@gtid_binlog_pos after tr#02
connection slave;
### Master: Checking SHOW BINLOG EVENTS
connection master;
SHOW BINLOG EVENTS IN 'master_after_tr01_show_master_status_file' FROM master_after_tr01_show_master_status_position LIMIT 0,1;
Log_name master_after_tr01_show_master_status_file
Pos master_after_tr01_show_master_status_position
Event_type Gtid
Server_id #
End_log_pos #
Info BEGIN GTID master_after_tr02_gtid_binlog_pos
SHOW BINLOG EVENTS IN 'master_after_tr01_show_master_status_file' FROM master_after_tr01_show_master_status_position LIMIT 1,1;
Log_name master_after_tr01_show_master_status_file
Pos #
Event_type Query_or_Annotate_rows
Server_id #
End_log_pos #
Info INSERT INTO t1 VALUES ('tr#02:stmt#00 - slave run#0, after backup')
### Slave: Checking SHOW BINLOG EVENTS
connection slave;
SHOW BINLOG EVENTS IN 'slave_after_tr01_show_master_status_file' FROM slave_after_tr01_show_master_status_position LIMIT 0,1;
Log_name slave_after_tr01_show_master_status_file
Pos #
Event_type Gtid
Server_id 1
End_log_pos #
Info BEGIN GTID slave_after_tr02_gtid_binlog_pos
SHOW BINLOG EVENTS IN 'slave_after_tr01_show_master_status_file' FROM slave_after_tr01_show_master_status_position LIMIT 1,1;
Log_name slave_after_tr01_show_master_status_file
Pos #
Event_type Query_or_Annotate_rows
Server_id #
End_log_pos #
Info INSERT INTO t1 VALUES ('tr#02:stmt#00 - slave run#0, after backup')
### Slave: Stop replication
connection slave;
STOP SLAVE;
include/wait_for_slave_to_stop.inc
RESET SLAVE;
Warnings:
Note 4190 RESET SLAVE is implicitly changing the value of 'Using_Gtid' from 'No' to 'Slave_Pos'
### Slave: Shutdown the server
include/rpl_stop_server.inc [server_number=2]
### Master: Run a transaction while the slave is shut down
connection master;
START TRANSACTION;
INSERT INTO t1 VALUES ('tr#03:stmt#00 - after slave run#0, slave is shut down, after backup');
INSERT INTO t1 VALUES ('tr#03:stmt#01 - after slave run#0, slave is shut down, after backup');
INSERT INTO t1 VALUES ('tr#03:stmt#02 - after slave run#0, slave is shut down, after backup');
COMMIT;
##############################################################
### Emulate starting a new virgin slave
### Slave: Remove the data directory
### Slave: Copy back the backup
### Slave: Restart the server
include/rpl_start_server.inc [server_number=2]
### Slave: Display the restored data before START SLAVE
connection slave;
SELECT * FROM t1 ORDER BY a;
a
tr#00:stmt#00 - slave run#0, before backup
tr#00:stmt#01 - slave run#0, before backup
tr#00:stmt#02 - slave run#0, before backup
tr#01:stmt#00 - slave run#0, before backup
tr#01:stmt#01 - slave run#0, before backup
tr#01:stmt#02 - slave run#0, before backup
### Slave: Execute the CHANGE MASTER statement to set up the host and port
CHANGE MASTER '' TO MASTER_USER='root', MASTER_HOST='127.0.0.1', MASTER_PORT=###, MASTER_CONNECT_RETRY=1, MASTER_SSL_VERIFY_SERVER_CERT=0;
### Slave: Execute the CHANGE MASTER statement from mariadb_backup_slave_info
CHANGE MASTER TO MASTER_LOG_FILE='master_after_tr01_show_master_status_file', MASTER_LOG_POS=master_after_tr01_show_master_status_position;
Warnings:
Note 4190 CHANGE MASTER TO is implicitly changing the value of 'Using_Gtid' from 'Slave_Pos' to 'No'
### Slave: Execute START SLAVE
include/start_slave.inc
### Master: Wait for the slave to apply all master events
connection master;
connection slave;
### Slave: Make sure replication is not using GTID after the slave restart
connection slave;
# Using_Gtid=No
### Slave: Display the restored data after START SLAVE
connection slave;
SELECT * FROM t1 ORDER BY a;
a
tr#00:stmt#00 - slave run#0, before backup
tr#00:stmt#01 - slave run#0, before backup
tr#00:stmt#02 - slave run#0, before backup
tr#01:stmt#00 - slave run#0, before backup
tr#01:stmt#01 - slave run#0, before backup
tr#01:stmt#02 - slave run#0, before backup
tr#02:stmt#00 - slave run#0, after backup
tr#02:stmt#01 - slave run#0, after backup
tr#02:stmt@02 - slave run#0, after backup
tr#03:stmt#00 - after slave run#0, slave is shut down, after backup
tr#03:stmt#01 - after slave run#0, slave is shut down, after backup
tr#03:stmt#02 - after slave run#0, slave is shut down, after backup
##############################################################
### Continue master transactions, check the new slave replicates well.
### Master: Run a transaction after restarting replication
connection master;
START TRANSACTION;
INSERT INTO t1 VALUES ('tr#04:stmt#00 - slave run#1');
INSERT INTO t1 VALUES ('tr#04:stmt#01 - slave run#1');
INSERT INTO t1 VALUES ('tr#04:stmt#02 - slave run#1');
COMMIT;
connection slave;
### Slave: Display the restored data + new transactions
connection slave;
SELECT * FROM t1 ORDER BY a;
a
tr#00:stmt#00 - slave run#0, before backup
tr#00:stmt#01 - slave run#0, before backup
tr#00:stmt#02 - slave run#0, before backup
tr#01:stmt#00 - slave run#0, before backup
tr#01:stmt#01 - slave run#0, before backup
tr#01:stmt#02 - slave run#0, before backup
tr#02:stmt#00 - slave run#0, after backup
tr#02:stmt#01 - slave run#0, after backup
tr#02:stmt@02 - slave run#0, after backup
tr#03:stmt#00 - after slave run#0, slave is shut down, after backup
tr#03:stmt#01 - after slave run#0, slave is shut down, after backup
tr#03:stmt#02 - after slave run#0, slave is shut down, after backup
tr#04:stmt#00 - slave run#1
tr#04:stmt#01 - slave run#1
tr#04:stmt#02 - slave run#1
##############################################################
### Cleanup
### Removing the backup directory
connection master;
DROP TABLE t1;
connection slave;
include/rpl_end.inc
|