112 lines
3.5 KiB
Plaintext
112 lines
3.5 KiB
Plaintext
include/master-slave.inc
|
|
Warnings:
|
|
Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
|
|
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.
|
|
[connection master]
|
|
CREATE TABLE t1 (c1 CHAR(15), c2 CHAR(15), c3 INT, PRIMARY KEY (c3)) ENGINE = NDB ;
|
|
STOP SLAVE;
|
|
RESET MASTER;
|
|
RESET SLAVE;
|
|
START SLAVE;
|
|
INSERT INTO t1 VALUES ("row1","will go away",1);
|
|
SELECT * FROM t1 ORDER BY c3;
|
|
c1 c2 c3
|
|
row1 will go away 1
|
|
SELECT @the_epoch:=MAX(epoch) FROM mysql.ndb_apply_status;
|
|
@the_epoch:=MAX(epoch)
|
|
<the_epoch>
|
|
Warnings:
|
|
<the_epoch> 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'.
|
|
SELECT * FROM t1 ORDER BY c3;
|
|
c1 c2 c3
|
|
row1 will go away 1
|
|
INSERT INTO t1 VALUES ("row2","will go away",2),("row3","will change",3),("row4","D",4);
|
|
DELETE FROM t1 WHERE c3 = 1;
|
|
UPDATE t1 SET c2="should go away" WHERE c3 = 2;
|
|
UPDATE t1 SET c2="C" WHERE c3 = 3;
|
|
DELETE FROM t1 WHERE c3 = 2;
|
|
SELECT * FROM t1 ORDER BY c3;
|
|
c1 c2 c3
|
|
row3 C 3
|
|
row4 D 4
|
|
SELECT * FROM t1 ORDER BY c3;
|
|
c1 c2 c3
|
|
row3 C 3
|
|
row4 D 4
|
|
include/check_slave_is_running.inc
|
|
STOP SLAVE;
|
|
include/check_slave_no_error.inc
|
|
call mtr.add_suppression("NDB Slave: At SQL thread start applying epoch .*");
|
|
START SLAVE;
|
|
SELECT * FROM t1 ORDER BY c3;
|
|
c1 c2 c3
|
|
row3 C 3
|
|
row4 D 4
|
|
SELECT * FROM t1 ORDER BY c3;
|
|
c1 c2 c3
|
|
row3 C 3
|
|
row4 D 4
|
|
STOP SLAVE;
|
|
DROP TABLE t1;
|
|
RESET master;
|
|
DROP TABLE t1;
|
|
RESET slave;
|
|
START SLAVE;
|
|
CREATE TABLE t1 (c1 CHAR(15) NOT NULL, c2 CHAR(15) NOT NULL, c3 INT NOT NULL, PRIMARY KEY (c3)) ENGINE = NDB ;
|
|
INSERT INTO t1 VALUES ("row1","remove on slave",1);
|
|
DELETE FROM t1;
|
|
BEGIN;
|
|
UPDATE t1 SET c2="does not exist" WHERE c3=1;
|
|
INSERT INTO t1 VALUES ("row2","new on slave",2);
|
|
COMMIT;
|
|
SELECT * FROM t1;
|
|
c1 c2 c3
|
|
row2 new on slave 2
|
|
include/check_slave_is_running.inc
|
|
DROP TABLE IF EXISTS t1;
|
|
STOP SLAVE;
|
|
RESET MASTER;
|
|
RESET SLAVE;
|
|
START SLAVE;
|
|
Let's interleave some DDL and DML in the Binlog
|
|
Some DDL
|
|
create table t1(a int primary key) engine=ndb;
|
|
First epoch transaction
|
|
begin;
|
|
insert into t1 values (1), (2), (3);
|
|
commit;
|
|
Sync slave and retrieve epoch
|
|
SELECT @first_epoch:=MAX(epoch) FROM mysql.ndb_apply_status;
|
|
@first_epoch:=MAX(epoch)
|
|
<first_epoch>
|
|
Warnings:
|
|
<first_epoch> 1287 Setting user variables within expressions is deprecated and will be removed in a future release. Consider alternatives: 'SET variable=expression, ...', or 'SELECT expression(s) INTO variables(s)'.
|
|
Slave contents
|
|
select * from t1 ORDER by a;
|
|
a
|
|
1
|
|
2
|
|
3
|
|
Get the next master binlog pos from the epoch
|
|
Now let's do some more DDL and DML
|
|
create table t2 (a int primary key) engine=ndb;
|
|
begin;
|
|
insert into t2 values (1), (2), (3);
|
|
commit;
|
|
include/check_slave_is_running.inc
|
|
Stop slave and reset position to start of the applied epoch
|
|
STOP SLAVE;
|
|
include/check_slave_no_error.inc
|
|
call mtr.add_suppression("Slave: Table \'t2\' already exists .*");
|
|
call mtr.add_suppression("Slave SQL for channel '': Error \'Table \'t2\' already exists\' .*");
|
|
START SLAVE;
|
|
include/wait_for_slave_sql_error.inc [errno=1050]
|
|
Last_SQL_Error = 'Error 'Table 't2' already exists' on query. Default database: 'test'. Query: 'create table t2 (a int primary key) engine=ndb''
|
|
STOP SLAVE;
|
|
RESET MASTER;
|
|
RESET SLAVE;
|
|
START SLAVE;
|
|
DROP TABLE t1;
|
|
DROP TABLE t2;
|
|
include/rpl_end.inc
|