mirror of
https://github.com/MariaDB/server.git
synced 2025-01-28 17:54:16 +01:00
202 lines
8.3 KiB
Text
202 lines
8.3 KiB
Text
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;
|
|
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 xtrabackup_slave_info and xtrabackup_binlog_info are OK
|
|
### Slave: Create a backup
|
|
### Slave: Prepare the backup
|
|
### Slave: xtrabackup files:
|
|
############################ xtrabackup_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;
|
|
############################ xtrabackup_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;
|
|
### Slave: Execute the CHANGE MASTER statement from xtrabackup_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
|