2016-03-25 17:51:22 +01:00
|
|
|
connect slave,127.0.0.1,root,,,$SERVER_MYPORT_3;
|
2013-01-30 15:11:36 +01:00
|
|
|
change master 'abc' to relay_log_file='';
|
|
|
|
ERROR HY000: Failed initializing relay log position: Could not find target log during relay log initialization
|
|
|
|
change master 'abc2' to master_host='';
|
|
|
|
ERROR HY000: Incorrect arguments to MASTER_HOST
|
2012-10-04 06:02:13 +02:00
|
|
|
change master 'master1' to
|
|
|
|
master_port=MYPORT_1,
|
|
|
|
master_host='127.0.0.1',
|
2023-09-04 15:32:36 +02:00
|
|
|
master_user='root',
|
|
|
|
master_ssl_verify_server_cert=0;
|
2012-10-04 06:02:13 +02:00
|
|
|
start slave 'master1';
|
|
|
|
set default_master_connection = 'master1';
|
|
|
|
include/wait_for_slave_to_start.inc
|
2016-03-25 17:51:22 +01:00
|
|
|
connect master1,127.0.0.1,root,,,$SERVER_MYPORT_1;
|
|
|
|
connection slave;
|
2015-03-09 01:07:47 +01:00
|
|
|
#
|
|
|
|
# Checking SHOW SLAVE 'master1' STATUS
|
|
|
|
#
|
|
|
|
Master_Port = 'MYPORT_1'
|
|
|
|
Relay_Log_File = 'mysqld-relay-bin-master1.000002'
|
|
|
|
Slave_IO_Running = 'Yes'
|
|
|
|
Slave_SQL_Running = 'Yes'
|
|
|
|
Last_Errno = '0'
|
|
|
|
Last_SQL_Errno = '0'
|
|
|
|
#
|
|
|
|
# Checking SHOW SLAVE STATUS
|
|
|
|
#
|
|
|
|
Master_Port = 'MYPORT_1'
|
|
|
|
Relay_Log_File = 'mysqld-relay-bin-master1.000002'
|
|
|
|
Slave_IO_Running = 'Yes'
|
|
|
|
Slave_SQL_Running = 'Yes'
|
|
|
|
Last_Errno = '0'
|
|
|
|
Last_SQL_Errno = '0'
|
|
|
|
#
|
|
|
|
# Checking SHOW ALL SLAVES STATUS
|
|
|
|
#
|
|
|
|
Connection_name = 'master1'
|
|
|
|
Master_Port = 'MYPORT_1'
|
|
|
|
Relay_Log_File = 'mysqld-relay-bin-master1.000002'
|
|
|
|
Slave_IO_Running = 'Yes'
|
|
|
|
Slave_SQL_Running = 'Yes'
|
|
|
|
Last_Errno = '0'
|
|
|
|
Last_SQL_Errno = '0'
|
|
|
|
Slave_heartbeat_period = '60.000'
|
|
|
|
#
|
2016-03-25 17:51:22 +01:00
|
|
|
connection master1;
|
2012-10-04 06:02:13 +02:00
|
|
|
drop database if exists db1;
|
|
|
|
create database db1;
|
|
|
|
use db1;
|
|
|
|
create table t1 (i int auto_increment, f1 varchar(16), primary key pk (i,f1)) engine=MyISAM;
|
2019-07-30 19:57:48 +02:00
|
|
|
Warnings:
|
|
|
|
Warning 1280 Name 'pk' ignored for PRIMARY key.
|
2012-10-04 06:02:13 +02:00
|
|
|
insert into t1 (f1) values ('one'),('two');
|
2016-03-25 17:51:22 +01:00
|
|
|
connection slave;
|
2012-10-04 06:02:13 +02:00
|
|
|
select * from db1.t1;
|
|
|
|
i f1
|
|
|
|
1 one
|
|
|
|
2 two
|
|
|
|
# List of relay log files in the datadir
|
|
|
|
mysqld-relay-bin-master1.000001
|
|
|
|
mysqld-relay-bin-master1.000002
|
|
|
|
mysqld-relay-bin-master1.index
|
2015-08-21 23:20:35 +02:00
|
|
|
include/show_events.inc
|
2012-10-04 06:02:13 +02:00
|
|
|
Log_name Pos Event_type Server_id End_log_pos Info
|
2015-08-21 23:20:35 +02:00
|
|
|
mysqld-relay-bin-master1.000001 # Format_desc # # SERVER_VERSION, BINLOG_VERSION
|
|
|
|
mysqld-relay-bin-master1.000001 # Rotate # # mysqld-relay-bin-master1.000002;pos=4
|
|
|
|
include/show_events.inc
|
2012-10-04 06:02:13 +02:00
|
|
|
Log_name Pos Event_type Server_id End_log_pos Info
|
2015-08-21 23:20:35 +02:00
|
|
|
mysqld-relay-bin-master1.000002 # Format_desc # # SERVER_VERSION, BINLOG_VERSION
|
|
|
|
mysqld-relay-bin-master1.000002 # Rotate # # master-bin.000001;pos=POS
|
|
|
|
mysqld-relay-bin-master1.000002 # Format_desc # # SERVER_VERSION, BINLOG_VERSION
|
|
|
|
mysqld-relay-bin-master1.000002 # Gtid_list # # []
|
|
|
|
mysqld-relay-bin-master1.000002 # Binlog_checkpoint # # master-bin.000001
|
|
|
|
mysqld-relay-bin-master1.000002 # Gtid # # GTID #-#-#
|
|
|
|
mysqld-relay-bin-master1.000002 # Query # # drop database if exists db1
|
|
|
|
mysqld-relay-bin-master1.000002 # Gtid # # GTID #-#-#
|
|
|
|
mysqld-relay-bin-master1.000002 # Query # # create database db1
|
|
|
|
mysqld-relay-bin-master1.000002 # Gtid # # GTID #-#-#
|
|
|
|
mysqld-relay-bin-master1.000002 # Query # # use `db1`; create table t1 (i int auto_increment, f1 varchar(16), primary key pk (i,f1)) engine=MyISAM
|
|
|
|
mysqld-relay-bin-master1.000002 # Gtid # # BEGIN GTID #-#-#
|
|
|
|
mysqld-relay-bin-master1.000002 # Intvar # # INSERT_ID=1
|
|
|
|
mysqld-relay-bin-master1.000002 # Query # # use `db1`; insert into t1 (f1) values ('one'),('two')
|
|
|
|
mysqld-relay-bin-master1.000002 # Query # # COMMIT
|
2012-10-04 06:02:13 +02:00
|
|
|
change master 'master1' to
|
|
|
|
master_port=MYPORT_2,
|
|
|
|
master_host='127.0.0.1',
|
|
|
|
master_user='root';
|
|
|
|
ERROR HY000: This operation cannot be performed as you have a running slave 'master1'; run STOP SLAVE 'master1' first
|
|
|
|
change master to
|
|
|
|
master_port=MYPORT_2,
|
|
|
|
master_host='127.0.0.1',
|
|
|
|
master_user='root';
|
|
|
|
ERROR HY000: This operation cannot be performed as you have a running slave 'master1'; run STOP SLAVE 'master1' first
|
|
|
|
change master 'master2' to
|
|
|
|
master_port=MYPORT_1,
|
|
|
|
master_host='127.0.0.1',
|
|
|
|
master_user='root';
|
|
|
|
ERROR HY000: Connection 'master2' conflicts with existing connection 'master1'
|
|
|
|
set default_master_connection = '';
|
|
|
|
change master to
|
|
|
|
master_port=MYPORT_2,
|
|
|
|
master_host='127.0.0.1',
|
MDEV-19801: Change defaults for CHANGE MASTER TO so that GTID-based replication is used by default if master supports it
This commit makes replicas crash-safe by default by changing the
Using_Gtid value to be Slave_Pos on a fresh slave start and after
RESET SLAVE is issued. If the primary server does not support GTIDs
(i.e., version < 10), the replica will fall back to Using_Gtid=No on
slave start and after RESET SLAVE.
The following additional informational messages/warnings are added:
1. When Using_Gtid is automatically changed. That is, if RESET
SLAVE reverts Using_Gtid back to Slave_Pos, or Using_Gtid is
inferred to No from a CHANGE MASTER TO given with log coordinates
without MASTER_USE_GTID.
2. If options are ignored in CHANGE MASTER TO. If CHANGE MASTER TO
is given with log coordinates, yet also specifies
MASTER_USE_GTID=Slave_Pos, a warning message is given that the log
coordinate options are ignored.
Additionally, an MTR macro has been added for RESET SLAVE,
reset_slave.inc, which provides modes/options for resetting a slave
in log coordinate or gtid modes. When in log coordinates mode, the
macro will execute CHANGE MASTER TO MASTER_USE_GTID=No after the
RESET SLAVE command. When in GTID mode, an extra parameter,
reset_slave_keep_gtid_state, can be set to reset or preserve the
value of gtid_slave_pos.
Reviewed By:
===========
Andrei Elkin <andrei.elkin@mariadb.com>
2022-05-23 22:14:00 +02:00
|
|
|
master_user='root',
|
2023-09-04 15:32:36 +02:00
|
|
|
master_ssl_verify_server_cert=0,
|
MDEV-19801: Change defaults for CHANGE MASTER TO so that GTID-based replication is used by default if master supports it
This commit makes replicas crash-safe by default by changing the
Using_Gtid value to be Slave_Pos on a fresh slave start and after
RESET SLAVE is issued. If the primary server does not support GTIDs
(i.e., version < 10), the replica will fall back to Using_Gtid=No on
slave start and after RESET SLAVE.
The following additional informational messages/warnings are added:
1. When Using_Gtid is automatically changed. That is, if RESET
SLAVE reverts Using_Gtid back to Slave_Pos, or Using_Gtid is
inferred to No from a CHANGE MASTER TO given with log coordinates
without MASTER_USE_GTID.
2. If options are ignored in CHANGE MASTER TO. If CHANGE MASTER TO
is given with log coordinates, yet also specifies
MASTER_USE_GTID=Slave_Pos, a warning message is given that the log
coordinate options are ignored.
Additionally, an MTR macro has been added for RESET SLAVE,
reset_slave.inc, which provides modes/options for resetting a slave
in log coordinate or gtid modes. When in log coordinates mode, the
macro will execute CHANGE MASTER TO MASTER_USE_GTID=No after the
RESET SLAVE command. When in GTID mode, an extra parameter,
reset_slave_keep_gtid_state, can be set to reset or preserve the
value of gtid_slave_pos.
Reviewed By:
===========
Andrei Elkin <andrei.elkin@mariadb.com>
2022-05-23 22:14:00 +02:00
|
|
|
master_use_gtid=no;
|
2012-10-04 06:02:13 +02:00
|
|
|
start slave;
|
|
|
|
include/wait_for_slave_to_start.inc
|
2015-03-09 01:07:47 +01:00
|
|
|
#
|
|
|
|
# Checking SHOW ALL SLAVES STATUS
|
|
|
|
#
|
|
|
|
Connection_name = ''
|
|
|
|
Connection_name = 'master1'
|
|
|
|
Master_Port = 'MYPORT_2'
|
|
|
|
Master_Port = 'MYPORT_1'
|
|
|
|
Relay_Log_File = 'mysqld-relay-bin.000002'
|
|
|
|
Relay_Log_File = 'mysqld-relay-bin-master1.000002'
|
|
|
|
Slave_IO_Running = 'Yes'
|
|
|
|
Slave_IO_Running = 'Yes'
|
|
|
|
Slave_SQL_Running = 'Yes'
|
|
|
|
Slave_SQL_Running = 'Yes'
|
|
|
|
Last_Errno = '0'
|
|
|
|
Last_Errno = '0'
|
|
|
|
Last_SQL_Errno = '0'
|
|
|
|
Last_SQL_Errno = '0'
|
|
|
|
Slave_heartbeat_period = '60.000'
|
|
|
|
Slave_heartbeat_period = '60.000'
|
|
|
|
#
|
2016-03-25 17:51:22 +01:00
|
|
|
connection master1;
|
2012-10-04 06:02:13 +02:00
|
|
|
insert into t1 (f1) values ('three');
|
2016-03-25 17:51:22 +01:00
|
|
|
connect master2,127.0.0.1,root,,,$SERVER_MYPORT_2;
|
2012-10-04 06:02:13 +02:00
|
|
|
drop database if exists db2;
|
|
|
|
create database db2;
|
|
|
|
use db2;
|
|
|
|
create table t1 (pk int auto_increment primary key, f1 int) engine=InnoDB;
|
|
|
|
begin;
|
|
|
|
insert into t1 (f1) values (1),(2);
|
2016-03-25 17:51:22 +01:00
|
|
|
connection slave;
|
|
|
|
connection master2;
|
|
|
|
connection slave;
|
2012-10-04 06:02:13 +02:00
|
|
|
select * from db1.t1;
|
|
|
|
i f1
|
|
|
|
1 one
|
|
|
|
2 two
|
|
|
|
3 three
|
|
|
|
select * from db2.t1;
|
|
|
|
pk f1
|
2016-03-25 17:51:22 +01:00
|
|
|
connection master2;
|
2012-10-04 06:02:13 +02:00
|
|
|
commit;
|
2016-03-25 17:51:22 +01:00
|
|
|
connection slave;
|
2012-10-04 06:02:13 +02:00
|
|
|
select * from db2.t1;
|
|
|
|
pk f1
|
|
|
|
1 1
|
|
|
|
2 2
|
2016-03-25 17:51:22 +01:00
|
|
|
connection master1;
|
2012-10-04 06:02:13 +02:00
|
|
|
flush logs;
|
2016-03-25 17:51:22 +01:00
|
|
|
connection slave;
|
|
|
|
connection master1;
|
2012-10-04 06:02:13 +02:00
|
|
|
purge binary logs to 'master-bin.000002';
|
|
|
|
show binary logs;
|
|
|
|
Log_name File_size
|
2015-08-21 23:20:35 +02:00
|
|
|
master-bin.000002 filesize
|
2012-10-04 06:02:13 +02:00
|
|
|
insert into t1 (f1) values ('four');
|
|
|
|
create table db1.t3 (f1 int) engine=InnoDB;
|
2016-03-25 17:51:22 +01:00
|
|
|
connection slave;
|
2015-03-09 01:07:47 +01:00
|
|
|
#
|
|
|
|
# Checking SHOW ALL SLAVES STATUS
|
|
|
|
#
|
|
|
|
Connection_name = ''
|
|
|
|
Connection_name = 'master1'
|
|
|
|
Master_Port = 'MYPORT_2'
|
|
|
|
Master_Port = 'MYPORT_1'
|
|
|
|
Relay_Log_File = 'mysqld-relay-bin.000002'
|
|
|
|
Relay_Log_File = 'mysqld-relay-bin-master1.000004'
|
|
|
|
Slave_IO_Running = 'Yes'
|
|
|
|
Slave_IO_Running = 'Yes'
|
|
|
|
Slave_SQL_Running = 'Yes'
|
|
|
|
Slave_SQL_Running = 'Yes'
|
|
|
|
Last_Errno = '0'
|
|
|
|
Last_Errno = '0'
|
|
|
|
Last_SQL_Errno = '0'
|
|
|
|
Last_SQL_Errno = '0'
|
|
|
|
Slave_heartbeat_period = '60.000'
|
|
|
|
Slave_heartbeat_period = '60.000'
|
|
|
|
#
|
2021-04-16 05:32:00 +02:00
|
|
|
#
|
|
|
|
# MDEV:16437: merge 5.7 P_S replication instrumentation and tables
|
|
|
|
#
|
|
|
|
SELECT * FROM performance_schema.replication_applier_status_by_coordinator;
|
|
|
|
CHANNEL_NAME master1
|
|
|
|
THREAD_ID #
|
|
|
|
SERVICE_STATE ON
|
|
|
|
LAST_ERROR_NUMBER 0
|
|
|
|
LAST_ERROR_MESSAGE
|
|
|
|
LAST_ERROR_TIMESTAMP 0000-00-00 00:00:00
|
|
|
|
LAST_SEEN_TRANSACTION 0-1-7
|
|
|
|
LAST_TRANS_RETRY_COUNT 0
|
|
|
|
CHANNEL_NAME
|
|
|
|
THREAD_ID #
|
|
|
|
SERVICE_STATE ON
|
|
|
|
LAST_ERROR_NUMBER 0
|
|
|
|
LAST_ERROR_MESSAGE
|
|
|
|
LAST_ERROR_TIMESTAMP 0000-00-00 00:00:00
|
|
|
|
LAST_SEEN_TRANSACTION 0-2-4
|
|
|
|
LAST_TRANS_RETRY_COUNT 0
|
2012-10-04 06:02:13 +02:00
|
|
|
select * from db1.t1;
|
|
|
|
i f1
|
|
|
|
1 one
|
|
|
|
2 two
|
|
|
|
3 three
|
|
|
|
4 four
|
2015-08-21 23:20:35 +02:00
|
|
|
include/show_events.inc
|
2012-10-04 06:02:13 +02:00
|
|
|
Log_name Pos Event_type Server_id End_log_pos Info
|
2015-08-21 23:20:35 +02:00
|
|
|
mysqld-relay-bin.000001 # Format_desc # # SERVER_VERSION, BINLOG_VERSION
|
|
|
|
mysqld-relay-bin.000001 # Rotate # # mysqld-relay-bin.000002;pos=4
|
|
|
|
include/show_events.inc
|
2012-10-04 06:02:13 +02:00
|
|
|
Log_name Pos Event_type Server_id End_log_pos Info
|
2015-08-21 23:20:35 +02:00
|
|
|
mysqld-relay-bin.000002 # Format_desc # # SERVER_VERSION, BINLOG_VERSION
|
|
|
|
mysqld-relay-bin.000002 # Rotate # # master-bin.000001;pos=POS
|
|
|
|
mysqld-relay-bin.000002 # Format_desc # # SERVER_VERSION, BINLOG_VERSION
|
|
|
|
mysqld-relay-bin.000002 # Gtid_list # # []
|
|
|
|
mysqld-relay-bin.000002 # Binlog_checkpoint # # master-bin.000001
|
|
|
|
mysqld-relay-bin.000002 # Gtid # # GTID #-#-#
|
|
|
|
mysqld-relay-bin.000002 # Query # # drop database if exists db2
|
|
|
|
mysqld-relay-bin.000002 # Gtid # # GTID #-#-#
|
|
|
|
mysqld-relay-bin.000002 # Query # # create database db2
|
|
|
|
mysqld-relay-bin.000002 # Gtid # # GTID #-#-#
|
|
|
|
mysqld-relay-bin.000002 # Query # # use `db2`; create table t1 (pk int auto_increment primary key, f1 int) engine=InnoDB
|
|
|
|
mysqld-relay-bin.000002 # Gtid # # BEGIN GTID #-#-#
|
|
|
|
mysqld-relay-bin.000002 # Intvar # # INSERT_ID=1
|
|
|
|
mysqld-relay-bin.000002 # Query # # use `db2`; insert into t1 (f1) values (1),(2)
|
|
|
|
mysqld-relay-bin.000002 # Xid # # COMMIT /* XID */
|
2016-03-25 17:51:22 +01:00
|
|
|
disconnect slave;
|
|
|
|
connect slave,127.0.0.1,root,,,$SERVER_MYPORT_3;
|
2012-10-04 06:02:13 +02:00
|
|
|
stop slave io_thread;
|
|
|
|
show status like 'Slave_running';
|
|
|
|
Variable_name Value
|
|
|
|
Slave_running OFF
|
|
|
|
set default_master_connection = 'master1';
|
|
|
|
show status like 'Slave_running';
|
|
|
|
Variable_name Value
|
|
|
|
Slave_running ON
|
|
|
|
drop database db1;
|
|
|
|
drop database db2;
|
|
|
|
include/reset_master_slave.inc
|
2016-03-25 17:51:22 +01:00
|
|
|
disconnect slave;
|
|
|
|
connection master1;
|
2012-10-04 06:02:13 +02:00
|
|
|
drop database db1;
|
|
|
|
include/reset_master_slave.inc
|
2016-03-25 17:51:22 +01:00
|
|
|
disconnect master1;
|
|
|
|
connection master2;
|
2012-10-04 06:02:13 +02:00
|
|
|
drop database db2;
|
|
|
|
include/reset_master_slave.inc
|
2016-03-25 17:51:22 +01:00
|
|
|
disconnect master2;
|