Skip to content

Commit 5cf155e

Browse files
AliSQLAliSQL
authored andcommitted
[Feature] Issue#36 Supply a way to upgrade MySQL instance to gtid mode
Summary: -------- Gtid_mode enabled slave instance can replicate from gtid_mode disabled master instance, such as MySQL 5.1/5.5. With that it is convenient to upgrade MySQL 5.6 gtid version from lower version.
1 parent 9d8b2a6 commit 5cf155e

8 files changed

Lines changed: 501 additions & 4 deletions

mysql-test/r/mysqld--help-notwin.result

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ The following options may be given as the first argument:
1616
without corresponding xxx_init() or xxx_deinit(). That
1717
also means that one can load any function from any
1818
library, for example exit() from libc.so
19+
--anonymous-in-gtid-out-enable
20+
If ON, gtid_mode enabled slave instance can replicate
21+
from gtid_mode disabled master instance, such as MySQL
22+
5.1/5.5 or MySQL 5.6 with gtid_mode=OFF. The default
23+
value is OFF.
1924
-a, --ansi Use ANSI SQL syntax instead of MySQL syntax. This mode
2025
will also set transaction isolation level 'serializable'.
2126
--auto-increment-increment[=#]
@@ -1183,6 +1188,7 @@ The following options may be given as the first argument:
11831188
Variables (--variable-name=value)
11841189
abort-slave-event-count 0
11851190
allow-suspicious-udfs FALSE
1191+
anonymous-in-gtid-out-enable FALSE
11861192
auto-increment-increment 1
11871193
auto-increment-offset 1
11881194
autocommit TRUE
@@ -1207,10 +1213,10 @@ block-encryption-mode aes-128-ecb
12071213
bulk-insert-buffer-size 8388608
12081214
character-set-client-handshake TRUE
12091215
character-set-filesystem binary
1210-
character-set-server gbk
1216+
character-set-server latin1
12111217
character-sets-dir MYSQL_CHARSETSDIR/
12121218
chroot (No default value)
1213-
collation-server gbk_chinese_ci
1219+
collation-server latin1_swedish_ci
12141220
completion-type NO_CHAIN
12151221
concurrent-insert AUTO
12161222
connect-timeout 10
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
include/master-slave.inc
2+
[connection master]
3+
call mtr.add_suppression("Slave I/O: The slave IO thread stops because the master has @@GLOBAL.GTID_MODE");
4+
call mtr.add_suppression("Error reading packet from server: Lost connection to MySQL");
5+
call mtr.add_suppression("Aborting");
6+
call mtr.add_suppression(".* Found a Gtid_log_event or Previous_gtids_log_event when @@GLOBAL.GTID_MODE = OFF.");
7+
call mtr.add_suppression("MASTER_AUTO_POSITION in the master info file was 1 but server is started with @@GLOBAL.GTID_MODE = OFF. Forcing MASTER_AUTO_POSITION to 0.");
8+
include/stop_slave.inc
9+
==== Master and slave have GTID_MODE = OFF ====
10+
---- Default value for GTID_MODE ----
11+
include/assert.inc [Default value for GTID_MODE should be OFF]
12+
---- GTID_MODE is read-only ----
13+
SET GTID_MODE = OFF;
14+
ERROR HY000: Variable 'gtid_mode' is a read only variable
15+
SET GTID_MODE = UPGRADE_STEP_1;
16+
ERROR HY000: Variable 'gtid_mode' is a read only variable
17+
SET GTID_MODE = UPGRADE_STEP_2;
18+
ERROR HY000: Variable 'gtid_mode' is a read only variable
19+
SET GTID_MODE = ON;
20+
ERROR HY000: Variable 'gtid_mode' is a read only variable
21+
---- GTID_NEXT must be ANONYMOUS or AUTOMATIC ----
22+
SET GTID_NEXT = 'AUTOMATIC';
23+
SET GTID_NEXT = 'ANONYMOUS';
24+
SET GTID_NEXT = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:1';
25+
ERROR HY000: @@SESSION.GTID_NEXT cannot be set to UUID:NUMBER when @@GLOBAL.GTID_MODE = OFF.
26+
---- CHANGE MASTER TO MASTER_AUTO_POSITION not supported ----
27+
CHANGE MASTER TO MASTER_AUTO_POSITION = 1;
28+
ERROR HY000: CHANGE MASTER TO MASTER_AUTO_POSITION = 1 can only be executed when @@GLOBAL.GTID_MODE = ON.
29+
CHANGE MASTER TO MASTER_AUTO_POSITION = 0;
30+
---- No GTIDs in binlog ----
31+
include/start_slave.inc
32+
SET GTID_NEXT = 'AUTOMATIC';
33+
CREATE TABLE t1 (a INT) ENGINE = InnoDB;
34+
SET GTID_NEXT = 'ANONYMOUS';
35+
INSERT INTO t1 VALUES (1);
36+
include/show_binlog_events.inc
37+
Log_name Pos Event_type Server_id End_log_pos Info
38+
master-bin.000001 # Query # # BEGIN
39+
include/show_binlog_events.inc
40+
Log_name Pos Event_type Server_id End_log_pos Info
41+
slave-bin.000001 # Query # # BEGIN
42+
include/show_relaylog_events.inc
43+
Log_name Pos Event_type Server_id End_log_pos Info
44+
slave-relay-bin.000002 # Rotate # # master-bin.000001;pos=POS
45+
==== Checks performed at server start when GTID_MODE = ON ====
46+
include/rpl_stop_server.inc [server_number=2]
47+
---- GTID_MODE = UPGRADE_STEP_[1|2] not supported ----
48+
include/assert_command_output.inc
49+
include/assert_command_output.inc
50+
---- GTID_MODE=ON requires --enforce-gtid-consistency ----
51+
include/assert_command_output.inc
52+
==== Master has GTID_MODE = OFF, slave has GTID_MODE = ON ====
53+
include/rpl_start_server.inc [server_number=2 gtids=on]
54+
---- Slave CAN connect ----
55+
include/assert.inc [Master GTID_MODE is OFF now.]
56+
include/assert.inc [Slave GTID_MODE is ON now.]
57+
CHANGE MASTER TO MASTER_AUTO_POSITION = 0;
58+
include/start_slave.inc
59+
include/stop_slave.inc
60+
==== Master and slave have GTID_MODE = ON ====
61+
include/rpl_stop_server.inc [server_number=1]
62+
---- GTID_MODE = ON requires --log-bin --log-slave-updates ----
63+
include/assert_command_output.inc
64+
include/rpl_start_server.inc [server_number=1 gtids=on]
65+
include/start_slave.inc
66+
include/assert.inc [GTID_MODE should be ON now.]
67+
---- GTID_NEXT must be SID:GNO or AUTOMATIC -----
68+
SET GTID_NEXT = 'AUTOMATIC';
69+
SET GTID_NEXT = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:1';
70+
SET GTID_NEXT = 'ANONYMOUS';
71+
ERROR HY000: @@SESSION.GTID_NEXT cannot be set to ANONYMOUS when @@GLOBAL.GTID_MODE = ON.
72+
ROLLBACK;
73+
SET SESSION GTID_NEXT='7805be8e-51ab-11e1-bacc-6706c20ad7ba:1';
74+
SET SESSION GTID_NEXT='7805be8e-51ab-11e1-bacc-6706c20ad7ba:1';
75+
ERROR HY000: @@SESSION.GTID_NEXT cannot be changed by a client that owns a GTID. The client owns 7805be8e-51ab-11e1-bacc-6706c20ad7ba:1. Ownership is released on COMMIT or ROLLBACK.
76+
ROLLBACK;
77+
SET SESSION GTID_NEXT='7805be8e-51ab-11e1-bacc-6706c20ad7ba:1';
78+
SET SESSION GTID_NEXT='7805be8e-51ab-11e1-bacc-6706c20ad7ba:1';
79+
ROLLBACK;
80+
---- GTIDs are in binlog ----
81+
SET GTID_NEXT = 'AUTOMATIC';
82+
INSERT INTO t1 VALUES (2);
83+
include/show_binlog_events.inc
84+
Log_name Pos Event_type Server_id End_log_pos Info
85+
master-bin.000002 # Previous_gtids # #
86+
include/show_binlog_events.inc
87+
Log_name Pos Event_type Server_id End_log_pos Info
88+
slave-bin.000002 # Previous_gtids # #
89+
include/show_relaylog_events.inc
90+
Log_name Pos Event_type Server_id End_log_pos Info
91+
slave-relay-bin.000004 # Previous_gtids # #
92+
---- CHANGE MASTER TO MASTER_AUTO_POSITION = 1 works ----
93+
include/stop_slave.inc
94+
CHANGE MASTER TO MASTER_AUTO_POSITION = 1;
95+
include/start_slave.inc
96+
INSERT INTO t1 VALUES (3);
97+
include/stop_slave.inc
98+
==== Checks performed at server start when GTID_MODE = OFF ====
99+
include/rpl_stop_server.inc [server_number=2]
100+
---- Fail to start replication with GTID_MODE = OFF and GTIDs in binlog/relay log ----
101+
include/rpl_start_server.inc [server_number=2]
102+
START SLAVE;
103+
include/rpl_restart_server.inc [server_number=2 gtids=on]
104+
RESET SLAVE;
105+
RESET MASTER;
106+
==== Master has GTID_MODE = ON, slave has GTID_MODE = OFF ====
107+
include/rpl_stop_server.inc [server_number=2]
108+
include/rpl_start_server.inc [server_number=2 parameters: --log-slave-updates]
109+
CHANGE MASTER TO MASTER_HOST = '127.0.0.1', MASTER_PORT = PORT, MASTER_USER = 'root', MASTER_LOG_FILE = 'FILE', MASTER_LOG_POS = POS, MASTER_CONNECT_RETRY = 1;
110+
Warnings:
111+
Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
112+
Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
113+
---- Slave CAN connect ----
114+
include/assert.inc [Master GTID_MODE is ON now.]
115+
include/assert.inc [Slave GTID_MODE is OFF now.]
116+
CHANGE MASTER TO MASTER_AUTO_POSITION = 0;
117+
include/start_slave.inc
118+
include/stop_slave.inc
119+
RESET SLAVE;
120+
include/rpl_end.inc
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--anonymous_in_gtid_out_enable=ON

0 commit comments

Comments
 (0)