2001-01-04 02:56:38 +02:00
|
|
|
connect (master,localhost,root,,test,0,mysql-master.sock);
|
|
|
|
connect (slave,localhost,root,,test,0,mysql-slave.sock);
|
2000-12-14 17:43:13 -07:00
|
|
|
system cat /dev/null > var/slave-data/master.info;
|
|
|
|
system chmod 000 var/slave-data/master.info;
|
|
|
|
connection slave;
|
|
|
|
!slave start;
|
|
|
|
system chmod 600 var/slave-data/master.info;
|
|
|
|
!slave start;
|
2001-04-17 23:06:00 -06:00
|
|
|
!eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT,
|
|
|
|
master_user='root';
|
2000-12-14 17:43:13 -07:00
|
|
|
reset slave;
|
2001-04-17 23:06:00 -06:00
|
|
|
eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT,
|
|
|
|
master_user='root';
|
2001-01-22 12:35:16 -07:00
|
|
|
connection master;
|
|
|
|
reset master;
|
|
|
|
connection slave;
|
2000-12-14 17:43:13 -07:00
|
|
|
slave start;
|
|
|
|
connection master;
|
2001-01-03 02:15:48 +02:00
|
|
|
drop table if exists t1;
|
|
|
|
create table t1 (s text);
|
|
|
|
insert into t1 values('Could not break slave'),('Tried hard');
|
2001-01-17 05:47:33 -07:00
|
|
|
save_master_pos;
|
2000-12-14 17:43:13 -07:00
|
|
|
connection slave;
|
2001-01-17 05:47:33 -07:00
|
|
|
sync_with_master;
|
2001-04-20 15:18:46 +03:00
|
|
|
--replace_result 9306 9999 3334 9999 3335 9999
|
2001-01-22 12:35:16 -07:00
|
|
|
show slave status;
|
2001-01-03 02:15:48 +02:00
|
|
|
select * from t1;
|
2000-12-14 20:17:18 -07:00
|
|
|
connection master;
|
|
|
|
flush logs;
|
2001-01-03 02:15:48 +02:00
|
|
|
drop table if exists t2;
|
2001-01-24 09:15:34 -07:00
|
|
|
create table t2(m int not null primary key);
|
2001-01-03 02:15:48 +02:00
|
|
|
insert into t2 values (34),(67),(123);
|
2001-01-24 09:15:34 -07:00
|
|
|
save_master_pos;
|
2000-12-14 20:17:18 -07:00
|
|
|
flush logs;
|
|
|
|
show master logs;
|
2001-01-24 12:47:09 -07:00
|
|
|
|
2001-01-24 09:15:34 -07:00
|
|
|
#now lets make some duplicate key mess and see if we can recover from it
|
2001-01-24 12:47:09 -07:00
|
|
|
|
2001-01-24 09:15:34 -07:00
|
|
|
#first insert a value on the slave
|
|
|
|
connection slave;
|
|
|
|
sync_with_master;
|
|
|
|
insert into t2 values(1234);
|
2001-01-24 12:47:09 -07:00
|
|
|
|
2001-01-24 09:15:34 -07:00
|
|
|
#same value on the master
|
|
|
|
connection master;
|
|
|
|
save_master_pos;
|
|
|
|
insert into t2 values(1234);
|
|
|
|
connection slave;
|
|
|
|
sync_with_master;
|
2001-01-24 12:47:09 -07:00
|
|
|
|
2001-01-24 09:15:34 -07:00
|
|
|
#the slave may have already stopped, so we ignore the error
|
|
|
|
!slave stop;
|
2001-01-24 12:47:09 -07:00
|
|
|
|
2001-01-24 09:15:34 -07:00
|
|
|
#restart slave skipping one event
|
|
|
|
set sql_slave_skip_counter=1;
|
|
|
|
slave start;
|
2001-01-24 12:47:09 -07:00
|
|
|
|
2001-01-24 09:15:34 -07:00
|
|
|
connection master;
|
2001-01-23 08:20:51 -07:00
|
|
|
save_master_pos;
|
2001-01-24 12:47:09 -07:00
|
|
|
|
2001-01-23 08:20:51 -07:00
|
|
|
#let slave catch up
|
|
|
|
connection slave;
|
|
|
|
sync_with_master;
|
|
|
|
connection master;
|
2000-12-14 20:17:18 -07:00
|
|
|
purge master logs to 'master-bin.003';
|
|
|
|
show master logs;
|
2001-01-03 02:15:48 +02:00
|
|
|
insert into t2 values (65);
|
2001-01-17 05:47:33 -07:00
|
|
|
save_master_pos;
|
2000-12-14 20:17:18 -07:00
|
|
|
connection slave;
|
2001-01-17 05:47:33 -07:00
|
|
|
sync_with_master;
|
2001-04-20 15:18:46 +03:00
|
|
|
--replace_result 9306 9999 3334 9999 3335 9999
|
2001-01-22 12:35:16 -07:00
|
|
|
show slave status;
|
2001-01-03 02:15:48 +02:00
|
|
|
select * from t2;
|
2001-01-17 05:47:33 -07:00
|
|
|
connection master;
|
2001-01-24 09:15:34 -07:00
|
|
|
let $1=100;
|
|
|
|
drop table if exists t3;
|
|
|
|
create table t3 (n int);
|
|
|
|
while ($1)
|
|
|
|
{
|
2001-03-27 10:23:04 -07:00
|
|
|
#eval means expand $ expressions
|
|
|
|
eval insert into t3 values($1 + 4);
|
2001-01-24 09:15:34 -07:00
|
|
|
dec $1;
|
|
|
|
}
|
|
|
|
show master logs;
|
2001-02-19 23:08:24 -07:00
|
|
|
show master status;
|
2001-01-24 09:15:34 -07:00
|
|
|
save_master_pos;
|
|
|
|
connection slave;
|
2001-01-24 12:47:09 -07:00
|
|
|
slave stop;
|
|
|
|
slave start;
|
2001-01-24 09:15:34 -07:00
|
|
|
sync_with_master;
|
2001-04-20 15:18:46 +03:00
|
|
|
--replace_result 9306 9999 3334 9999 3335 9999
|
2001-02-19 23:08:24 -07:00
|
|
|
show slave status;
|
2001-03-26 21:03:08 -07:00
|
|
|
# because of concurrent insert, the table may not be up to date
|
|
|
|
# if we do not lock
|
|
|
|
lock tables t3 read;
|
2001-03-27 10:23:04 -07:00
|
|
|
select count(*) from t3 where n >= 4;
|
2001-03-26 21:03:08 -07:00
|
|
|
unlock tables;
|
2001-01-24 09:15:34 -07:00
|
|
|
#clean up
|
|
|
|
connection master;
|
|
|
|
drop table if exists t1,t2,t3;
|
|
|
|
save_master_pos;
|
|
|
|
connection slave;
|
|
|
|
sync_with_master;
|