2001-10-08 03:58:07 +02:00
|
|
|
connect (master,localhost,root,,test,0,master.sock);
|
|
|
|
connect (slave,localhost,root,,test,0,slave.sock);
|
2000-12-15 01:43:13 +01: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-12-15 03:41:20 +01:00
|
|
|
--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT
|
2001-04-18 07:06:00 +02:00
|
|
|
!eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT,
|
|
|
|
master_user='root';
|
2000-12-15 01:43:13 +01:00
|
|
|
reset slave;
|
2001-12-15 03:41:20 +01:00
|
|
|
--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT
|
2001-04-18 07:06:00 +02:00
|
|
|
eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT,
|
|
|
|
master_user='root';
|
2001-01-22 20:35:16 +01:00
|
|
|
connection master;
|
|
|
|
reset master;
|
|
|
|
connection slave;
|
2000-12-15 01:43:13 +01:00
|
|
|
slave start;
|
|
|
|
connection master;
|
2001-01-03 01:15:48 +01:00
|
|
|
drop table if exists t1;
|
|
|
|
create table t1 (s text);
|
|
|
|
insert into t1 values('Could not break slave'),('Tried hard');
|
2001-01-17 13:47:33 +01:00
|
|
|
save_master_pos;
|
2000-12-15 01:43:13 +01:00
|
|
|
connection slave;
|
2001-01-17 13:47:33 +01:00
|
|
|
sync_with_master;
|
2001-12-15 03:41:20 +01:00
|
|
|
--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT
|
2001-01-22 20:35:16 +01:00
|
|
|
show slave status;
|
2001-01-03 01:15:48 +01:00
|
|
|
select * from t1;
|
2000-12-15 04:17:18 +01:00
|
|
|
connection master;
|
|
|
|
flush logs;
|
2001-01-03 01:15:48 +01:00
|
|
|
drop table if exists t2;
|
2001-11-28 02:20:24 +01:00
|
|
|
create table t2(m int not null auto_increment primary key);
|
2001-01-03 01:15:48 +01:00
|
|
|
insert into t2 values (34),(67),(123);
|
2001-01-24 17:15:34 +01:00
|
|
|
save_master_pos;
|
2000-12-15 04:17:18 +01:00
|
|
|
flush logs;
|
|
|
|
show master logs;
|
2001-01-24 20:47:09 +01:00
|
|
|
|
2001-01-24 17:15:34 +01:00
|
|
|
#now lets make some duplicate key mess and see if we can recover from it
|
2001-01-24 20:47:09 +01:00
|
|
|
|
2001-01-24 17:15:34 +01:00
|
|
|
#first insert a value on the slave
|
|
|
|
connection slave;
|
|
|
|
sync_with_master;
|
|
|
|
insert into t2 values(1234);
|
2001-01-24 20:47:09 +01:00
|
|
|
|
2001-01-24 17:15:34 +01:00
|
|
|
#same value on the master
|
|
|
|
connection master;
|
|
|
|
save_master_pos;
|
2001-11-28 02:20:24 +01:00
|
|
|
set insert_id=1234;
|
|
|
|
insert into t2 values(NULL);
|
2001-01-24 17:15:34 +01:00
|
|
|
connection slave;
|
|
|
|
sync_with_master;
|
2001-01-24 20:47:09 +01:00
|
|
|
|
2001-01-24 17:15:34 +01:00
|
|
|
#the slave may have already stopped, so we ignore the error
|
2001-11-05 23:05:45 +01:00
|
|
|
--error 0,1199
|
2001-01-24 17:15:34 +01:00
|
|
|
!slave stop;
|
2001-01-24 20:47:09 +01:00
|
|
|
|
2001-01-24 17:15:34 +01:00
|
|
|
#restart slave skipping one event
|
|
|
|
set sql_slave_skip_counter=1;
|
|
|
|
slave start;
|
2001-01-24 20:47:09 +01:00
|
|
|
|
2001-01-24 17:15:34 +01:00
|
|
|
connection master;
|
2001-01-23 16:20:51 +01:00
|
|
|
save_master_pos;
|
2001-01-24 20:47:09 +01:00
|
|
|
|
2001-01-23 16:20:51 +01:00
|
|
|
#let slave catch up
|
|
|
|
connection slave;
|
|
|
|
sync_with_master;
|
|
|
|
connection master;
|
2000-12-15 04:17:18 +01:00
|
|
|
purge master logs to 'master-bin.003';
|
|
|
|
show master logs;
|
2001-01-03 01:15:48 +01:00
|
|
|
insert into t2 values (65);
|
2001-01-17 13:47:33 +01:00
|
|
|
save_master_pos;
|
2000-12-15 04:17:18 +01:00
|
|
|
connection slave;
|
2001-01-17 13:47:33 +01:00
|
|
|
sync_with_master;
|
2001-12-15 03:41:20 +01:00
|
|
|
--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT
|
2001-01-22 20:35:16 +01:00
|
|
|
show slave status;
|
2001-01-03 01:15:48 +01:00
|
|
|
select * from t2;
|
2001-01-17 13:47:33 +01:00
|
|
|
connection master;
|
2001-01-24 17:15:34 +01:00
|
|
|
let $1=100;
|
|
|
|
drop table if exists t3;
|
|
|
|
create table t3 (n int);
|
2001-09-28 07:05:54 +02:00
|
|
|
disable_query_log;
|
2001-01-24 17:15:34 +01:00
|
|
|
while ($1)
|
|
|
|
{
|
2001-03-27 19:23:04 +02:00
|
|
|
#eval means expand $ expressions
|
|
|
|
eval insert into t3 values($1 + 4);
|
2001-01-24 17:15:34 +01:00
|
|
|
dec $1;
|
|
|
|
}
|
2001-09-28 07:05:54 +02:00
|
|
|
enable_query_log;
|
2001-01-24 17:15:34 +01:00
|
|
|
show master logs;
|
2001-02-20 07:08:24 +01:00
|
|
|
show master status;
|
2001-01-24 17:15:34 +01:00
|
|
|
save_master_pos;
|
|
|
|
connection slave;
|
2001-01-24 20:47:09 +01:00
|
|
|
slave stop;
|
|
|
|
slave start;
|
2001-01-24 17:15:34 +01:00
|
|
|
sync_with_master;
|
2001-12-15 03:41:20 +01:00
|
|
|
--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT
|
2001-02-20 07:08:24 +01:00
|
|
|
show slave status;
|
2001-03-27 06:03:08 +02: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 19:23:04 +02:00
|
|
|
select count(*) from t3 where n >= 4;
|
2001-03-27 06:03:08 +02:00
|
|
|
unlock tables;
|
2001-01-24 17:15:34 +01:00
|
|
|
#clean up
|
|
|
|
connection master;
|
|
|
|
drop table if exists t1,t2,t3;
|
|
|
|
save_master_pos;
|
|
|
|
connection slave;
|
|
|
|
sync_with_master;
|