mirror of
https://github.com/percona/percona-toolkit.git
synced 2026-04-30 01:01:51 +08:00
make slaves set themselves read_only. Fix problem with replication_filters.t that is possibly not starting slaves after their masters are restarted.
This commit is contained in:
+12
-7
@@ -47,6 +47,11 @@ make_sandbox() {
|
||||
echo "skip-innodb" >> /tmp/$port/my.sandbox.cnf
|
||||
fi
|
||||
|
||||
# If the sandbox is a slave, set it read_only.
|
||||
if [ "$type" = "slave" ]; then
|
||||
echo "read_only" >> /tmp/$port/my.sandbox.cnf
|
||||
fi
|
||||
|
||||
# Start the sandbox and check that it has InnoDB.
|
||||
/tmp/$port/start
|
||||
if [ $? -eq 0 ]; then
|
||||
@@ -65,6 +70,12 @@ make_sandbox() {
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# If the sandbox is a slave, start the slave.
|
||||
if [ "$type" = "slave" ]; then
|
||||
/tmp/$port/use -e "change master to master_host='127.0.0.1', master_user='msandbox', master_password='msandbox', master_port=$master_port"
|
||||
/tmp/$port/use -e "start slave"
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -149,13 +160,7 @@ if [ -f $PIDFILE ]; then
|
||||
echo "Sandbox $port already started (found pid file $PIDFILE)"
|
||||
else
|
||||
make_sandbox
|
||||
|
||||
# If the sandbox is a slave, start the slave.
|
||||
if [ "$type" = "slave" ]; then
|
||||
/tmp/$port/use -e "change master to master_host='127.0.0.1', master_user='msandbox', master_password='msandbox', master_port=$master_port"
|
||||
/tmp/$port/use -e "start slave"
|
||||
/tmp/$port/use -e "set global read_only=1"
|
||||
fi
|
||||
# make_sandbox has started slave and set read_only if necessary.
|
||||
|
||||
# If the sandbox is a master-master, start the second master and slave the
|
||||
# two together.
|
||||
|
||||
@@ -272,6 +272,16 @@ is(
|
||||
"USE only --replicate-database (binlog dump)"
|
||||
);
|
||||
|
||||
# #############################################################################
|
||||
# Stop and start slaves to avoid sandbox breakage caused by restarting servers.
|
||||
# #############################################################################
|
||||
$slave1_dbh = $sb->get_dbh_for('slave1');
|
||||
$slave2_dbh = $sb->get_dbh_for('slave2');
|
||||
$slave1_dbh->do('STOP SLAVE');
|
||||
$slave2_dbh->do('STOP SLAVE');
|
||||
$slave1_dbh->do('START SLAVE');
|
||||
$slave2_dbh->do('START SLAVE');
|
||||
|
||||
# #############################################################################
|
||||
# Done.
|
||||
# #############################################################################
|
||||
|
||||
Reference in New Issue
Block a user