1
by brian
clean slate |
1 |
stop slave; |
2 |
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; |
|
3 |
reset master; |
|
4 |
reset slave; |
|
5 |
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; |
|
6 |
start slave; |
|
7 |
**** On Slave **** |
|
8 |
STOP SLAVE; |
|
9 |
**** On Master **** |
|
10 |
SET SESSION BINLOG_FORMAT=ROW; |
|
11 |
CREATE TABLE t1 (a INT, b INT); |
|
12 |
CREATE TABLE t2 (c INT, d INT); |
|
13 |
INSERT INTO t1 VALUES (1,1),(2,4),(3,9); |
|
14 |
INSERT INTO t2 VALUES (1,1),(2,8),(3,27); |
|
15 |
UPDATE t1,t2 SET b = d, d = b * 2 WHERE a = c; |
|
16 |
show binlog events from <binlog_start>; |
|
17 |
Log_name Pos Event_type Server_id End_log_pos Info |
|
18 |
master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT, b INT) |
|
19 |
master-bin.000001 # Query # # use `test`; CREATE TABLE t2 (c INT, d INT) |
|
20 |
master-bin.000001 # Query # # use `test`; BEGIN |
|
21 |
master-bin.000001 # Table_map # # table_id: # (test.t1) |
|
22 |
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F |
|
23 |
master-bin.000001 # Query # # use `test`; COMMIT |
|
24 |
master-bin.000001 # Query # # use `test`; BEGIN |
|
25 |
master-bin.000001 # Table_map # # table_id: # (test.t2) |
|
26 |
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F |
|
27 |
master-bin.000001 # Query # # use `test`; COMMIT |
|
28 |
master-bin.000001 # Query # # use `test`; BEGIN |
|
29 |
master-bin.000001 # Table_map # # table_id: # (test.t1) |
|
30 |
master-bin.000001 # Table_map # # table_id: # (test.t2) |
|
31 |
master-bin.000001 # Update_rows # # table_id: # |
|
32 |
master-bin.000001 # Update_rows # # table_id: # flags: STMT_END_F |
|
33 |
master-bin.000001 # Query # # use `test`; COMMIT |
|
34 |
SELECT * FROM t1; |
|
35 |
a b |
|
36 |
1 1 |
|
37 |
2 8 |
|
38 |
3 27 |
|
39 |
SELECT * FROM t2; |
|
40 |
c d |
|
41 |
1 2 |
|
42 |
2 16 |
|
43 |
3 54 |
|
44 |
**** On Slave **** |
|
45 |
START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=762; |
|
46 |
SHOW SLAVE STATUS; |
|
47 |
Slave_IO_State # |
|
48 |
Master_Host 127.0.0.1 |
|
49 |
Master_User root |
|
50 |
Master_Port MASTER_PORT |
|
51 |
Connect_Retry 1 |
|
52 |
Master_Log_File master-bin.000001 |
|
53 |
Read_Master_Log_Pos 1134 |
|
54 |
Relay_Log_File # |
|
55 |
Relay_Log_Pos # |
|
56 |
Relay_Master_Log_File master-bin.000001 |
|
57 |
Slave_IO_Running Yes |
|
58 |
Slave_SQL_Running No |
|
59 |
Replicate_Do_DB
|
|
60 |
Replicate_Ignore_DB
|
|
61 |
Replicate_Do_Table
|
|
62 |
Replicate_Ignore_Table
|
|
63 |
Replicate_Wild_Do_Table
|
|
64 |
Replicate_Wild_Ignore_Table
|
|
65 |
Last_Errno 0 |
|
66 |
Last_Error
|
|
67 |
Skip_Counter 0 |
|
68 |
Exec_Master_Log_Pos 763 |
|
69 |
Relay_Log_Space # |
|
70 |
Until_Condition Master |
|
71 |
Until_Log_File master-bin.000001 |
|
72 |
Until_Log_Pos 762 |
|
73 |
Master_SSL_Allowed No |
|
74 |
Master_SSL_CA_File
|
|
75 |
Master_SSL_CA_Path
|
|
76 |
Master_SSL_Cert
|
|
77 |
Master_SSL_Cipher
|
|
78 |
Master_SSL_Key
|
|
79 |
Seconds_Behind_Master # |
|
80 |
Master_SSL_Verify_Server_Cert No |
|
81 |
Last_IO_Errno # |
|
82 |
Last_IO_Error # |
|
83 |
Last_SQL_Errno 0 |
|
84 |
Last_SQL_Error
|
|
85 |
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; |
|
86 |
START SLAVE; |
|
87 |
SELECT * FROM t1; |
|
88 |
a b |
|
89 |
1 1 |
|
90 |
2 4 |
|
91 |
3 9 |
|
92 |
SELECT * FROM t2; |
|
93 |
c d |
|
94 |
1 1 |
|
95 |
2 8 |
|
96 |
3 27 |
|
97 |
STOP SLAVE; |
|
98 |
RESET SLAVE; |
|
99 |
RESET MASTER; |
|
100 |
SET SESSION BINLOG_FORMAT=STATEMENT; |
|
101 |
SET @foo = 12; |
|
102 |
INSERT INTO t1 VALUES(@foo, 2*@foo); |
|
103 |
show binlog events from <binlog_start>; |
|
104 |
Log_name Pos Event_type Server_id End_log_pos Info |
|
105 |
master-bin.000001 # User var # # @`foo`=12 |
|
106 |
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES(@foo, 2*@foo) |
|
107 |
START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=106; |
|
108 |
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; |
|
109 |
START SLAVE; |
|
110 |
SHOW SLAVE STATUS; |
|
111 |
Slave_IO_State # |
|
112 |
Master_Host 127.0.0.1 |
|
113 |
Master_User root |
|
114 |
Master_Port MASTER_PORT |
|
115 |
Connect_Retry 1 |
|
116 |
Master_Log_File master-bin.000001 |
|
117 |
Read_Master_Log_Pos 249 |
|
118 |
Relay_Log_File # |
|
119 |
Relay_Log_Pos # |
|
120 |
Relay_Master_Log_File master-bin.000001 |
|
121 |
Slave_IO_Running Yes |
|
122 |
Slave_SQL_Running Yes |
|
123 |
Replicate_Do_DB
|
|
124 |
Replicate_Ignore_DB
|
|
125 |
Replicate_Do_Table
|
|
126 |
Replicate_Ignore_Table
|
|
127 |
Replicate_Wild_Do_Table
|
|
128 |
Replicate_Wild_Ignore_Table
|
|
129 |
Last_Errno 0 |
|
130 |
Last_Error
|
|
131 |
Skip_Counter 0 |
|
132 |
Exec_Master_Log_Pos 249 |
|
133 |
Relay_Log_Space # |
|
134 |
Until_Condition None |
|
135 |
Until_Log_File
|
|
136 |
Until_Log_Pos 0 |
|
137 |
Master_SSL_Allowed No |
|
138 |
Master_SSL_CA_File
|
|
139 |
Master_SSL_CA_Path
|
|
140 |
Master_SSL_Cert
|
|
141 |
Master_SSL_Cipher
|
|
142 |
Master_SSL_Key
|
|
143 |
Seconds_Behind_Master # |
|
144 |
Master_SSL_Verify_Server_Cert No |
|
145 |
Last_IO_Errno # |
|
146 |
Last_IO_Error # |
|
147 |
Last_SQL_Errno 0 |
|
148 |
Last_SQL_Error
|
|
149 |
**** On Master **** |
|
150 |
DROP TABLE t1, t2; |
|
151 |
SET SESSION BINLOG_FORMAT=ROW; |
|
152 |
SET AUTOCOMMIT=0; |
|
153 |
CREATE TABLE t1 (a INT, b VARCHAR(20)) ENGINE=myisam; |
|
154 |
CREATE TABLE t2 (a INT, b VARCHAR(20)) ENGINE=myisam; |
|
155 |
CREATE TABLE t3 (a INT, b VARCHAR(20)) ENGINE=myisam; |
|
156 |
INSERT INTO t1 VALUES (1,'master/slave'); |
|
157 |
INSERT INTO t2 VALUES (1,'master/slave'); |
|
158 |
INSERT INTO t3 VALUES (1,'master/slave'); |
|
159 |
CREATE TRIGGER tr1 AFTER UPDATE on t1 FOR EACH ROW |
|
160 |
BEGIN
|
|
161 |
INSERT INTO t2 VALUES (NEW.a,NEW.b); |
|
162 |
DELETE FROM t2 WHERE a < NEW.a; |
|
163 |
END| |
|
164 |
CREATE TRIGGER tr2 AFTER INSERT on t2 FOR EACH ROW |
|
165 |
BEGIN
|
|
166 |
UPDATE t3 SET a =2, b = 'master only'; |
|
167 |
END| |
|
168 |
**** On Slave **** |
|
169 |
STOP SLAVE; |
|
170 |
**** On Master **** |
|
171 |
UPDATE t1 SET a = 2, b = 'master only' WHERE a = 1; |
|
172 |
DROP TRIGGER tr1; |
|
173 |
DROP TRIGGER tr2; |
|
174 |
INSERT INTO t1 VALUES (3,'master/slave'); |
|
175 |
INSERT INTO t2 VALUES (3,'master/slave'); |
|
176 |
INSERT INTO t3 VALUES (3,'master/slave'); |
|
177 |
SELECT * FROM t1 ORDER BY a; |
|
178 |
a b |
|
179 |
2 master only |
|
180 |
3 master/slave |
|
181 |
SELECT * FROM t2 ORDER BY a; |
|
182 |
a b |
|
183 |
2 master only |
|
184 |
3 master/slave |
|
185 |
SELECT * FROM t3 ORDER BY a; |
|
186 |
a b |
|
187 |
2 master only |
|
188 |
3 master/slave |
|
189 |
*** On Slave *** |
|
190 |
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; |
|
191 |
START SLAVE; |
|
192 |
SELECT * FROM t1 ORDER BY a; |
|
193 |
a b |
|
194 |
1 master/slave |
|
195 |
3 master/slave |
|
196 |
SELECT * FROM t2 ORDER BY a; |
|
197 |
a b |
|
198 |
1 master/slave |
|
199 |
3 master/slave |
|
200 |
SELECT * FROM t3 ORDER BY a; |
|
201 |
a b |
|
202 |
1 master/slave |
|
203 |
3 master/slave |
|
204 |
DROP TABLE t1, t2, t3; |
|
205 |
**** Case 2: Row binlog format and transactional tables **** |
|
206 |
*** On Master *** |
|
207 |
CREATE TABLE t4 (a INT, b VARCHAR(20)) ENGINE=innodb; |
|
208 |
CREATE TABLE t5 (a INT, b VARCHAR(20)) ENGINE=innodb; |
|
209 |
CREATE TABLE t6 (a INT, b VARCHAR(20)) ENGINE=innodb; |
|
210 |
**** On Slave **** |
|
211 |
STOP SLAVE; |
|
212 |
*** On Master *** |
|
213 |
BEGIN; |
|
214 |
INSERT INTO t4 VALUES (2, 'master only'); |
|
215 |
INSERT INTO t5 VALUES (2, 'master only'); |
|
216 |
INSERT INTO t6 VALUES (2, 'master only'); |
|
217 |
COMMIT; |
|
218 |
BEGIN; |
|
219 |
INSERT INTO t4 VALUES (3, 'master/slave'); |
|
220 |
INSERT INTO t5 VALUES (3, 'master/slave'); |
|
221 |
INSERT INTO t6 VALUES (3, 'master/slave'); |
|
222 |
COMMIT; |
|
223 |
SELECT * FROM t4 ORDER BY a; |
|
224 |
a b |
|
225 |
2 master only |
|
226 |
3 master/slave |
|
227 |
SELECT * FROM t5 ORDER BY a; |
|
228 |
a b |
|
229 |
2 master only |
|
230 |
3 master/slave |
|
231 |
SELECT * FROM t6 ORDER BY a; |
|
232 |
a b |
|
233 |
2 master only |
|
234 |
3 master/slave |
|
235 |
*** On Slave *** |
|
236 |
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; |
|
237 |
START SLAVE; |
|
238 |
SELECT * FROM t4 ORDER BY a; |
|
239 |
a b |
|
240 |
3 master/slave |
|
241 |
SELECT * FROM t5 ORDER BY a; |
|
242 |
a b |
|
243 |
3 master/slave |
|
244 |
SELECT * FROM t6 ORDER BY a; |
|
245 |
a b |
|
246 |
3 master/slave |
|
247 |
**** On Slave **** |
|
248 |
STOP SLAVE; |
|
249 |
*** On Master *** |
|
250 |
BEGIN; |
|
251 |
INSERT INTO t4 VALUES (6, 'master only'); |
|
252 |
INSERT INTO t5 VALUES (6, 'master only'); |
|
253 |
INSERT INTO t6 VALUES (6, 'master only'); |
|
254 |
COMMIT; |
|
255 |
BEGIN; |
|
256 |
INSERT INTO t4 VALUES (7, 'master only'); |
|
257 |
INSERT INTO t5 VALUES (7, 'master only'); |
|
258 |
INSERT INTO t6 VALUES (7, 'master only'); |
|
259 |
COMMIT; |
|
260 |
SELECT * FROM t4 ORDER BY a; |
|
261 |
a b |
|
262 |
2 master only |
|
263 |
3 master/slave |
|
264 |
6 master only |
|
265 |
7 master only |
|
266 |
SELECT * FROM t5 ORDER BY a; |
|
267 |
a b |
|
268 |
2 master only |
|
269 |
3 master/slave |
|
270 |
6 master only |
|
271 |
7 master only |
|
272 |
SELECT * FROM t6 ORDER BY a; |
|
273 |
a b |
|
274 |
2 master only |
|
275 |
3 master/slave |
|
276 |
6 master only |
|
277 |
7 master only |
|
278 |
*** On Slave *** |
|
279 |
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=10; |
|
280 |
START SLAVE; |
|
281 |
SELECT * FROM t4 ORDER BY a; |
|
282 |
a b |
|
283 |
3 master/slave |
|
284 |
SELECT * FROM t5 ORDER BY a; |
|
285 |
a b |
|
286 |
3 master/slave |
|
287 |
SELECT * FROM t6 ORDER BY a; |
|
288 |
a b |
|
289 |
3 master/slave |
|
290 |
STOP SLAVE; |
|
291 |
SET AUTOCOMMIT=0; |
|
292 |
INSERT INTO t4 VALUES (4, 'master only'); |
|
293 |
INSERT INTO t5 VALUES (4, 'master only'); |
|
294 |
INSERT INTO t6 VALUES (4, 'master only'); |
|
295 |
COMMIT; |
|
296 |
INSERT INTO t4 VALUES (5, 'master/slave'); |
|
297 |
INSERT INTO t5 VALUES (5, 'master/slave'); |
|
298 |
INSERT INTO t6 VALUES (5, 'master/slave'); |
|
299 |
COMMIT; |
|
300 |
SELECT * FROM t4 ORDER BY a; |
|
301 |
a b |
|
302 |
2 master only |
|
303 |
3 master/slave |
|
304 |
4 master only |
|
305 |
5 master/slave |
|
306 |
6 master only |
|
307 |
7 master only |
|
308 |
SELECT * FROM t5 ORDER BY a; |
|
309 |
a b |
|
310 |
2 master only |
|
311 |
3 master/slave |
|
312 |
4 master only |
|
313 |
5 master/slave |
|
314 |
6 master only |
|
315 |
7 master only |
|
316 |
SELECT * FROM t6 ORDER BY a; |
|
317 |
a b |
|
318 |
2 master only |
|
319 |
3 master/slave |
|
320 |
4 master only |
|
321 |
5 master/slave |
|
322 |
6 master only |
|
323 |
7 master only |
|
324 |
*** On Slave *** |
|
325 |
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; |
|
326 |
START SLAVE; |
|
327 |
SELECT * FROM t4 ORDER BY a; |
|
328 |
a b |
|
329 |
3 master/slave |
|
330 |
5 master/slave |
|
331 |
SELECT * FROM t5 ORDER BY a; |
|
332 |
a b |
|
333 |
3 master/slave |
|
334 |
5 master/slave |
|
335 |
SELECT * FROM t6 ORDER BY a; |
|
336 |
a b |
|
337 |
3 master/slave |
|
338 |
5 master/slave |
|
339 |
DROP TABLE t4, t5, t6; |
|
340 |
**** Case 3: Statement logging format and LOAD DATA with non-transactional table **** |
|
341 |
*** On Master *** |
|
342 |
CREATE TABLE t10 (a INT, b VARCHAR(20)) ENGINE=myisam; |
|
343 |
*** On Slave *** |
|
344 |
STOP SLAVE; |
|
345 |
*** On Master *** |
|
346 |
SET SESSION BINLOG_FORMAT=STATEMENT; |
|
347 |
LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/rpl_bug28618.dat' INTO TABLE t10 FIELDS TERMINATED BY '|'; |
|
348 |
SELECT * FROM t10 ORDER BY a; |
|
349 |
a b |
|
350 |
1 master only |
|
351 |
2 master only |
|
352 |
3 master only |
|
353 |
*** On Slave *** |
|
354 |
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; |
|
355 |
START SLAVE; |
|
356 |
SELECT * FROM t10 ORDER BY a; |
|
357 |
a b |
|
358 |
DROP TABLE t10; |