Laurent Laborde kerdezixe at gmail.com
Wed May 13 06:11:03 PDT 2009
Friendly greetings !

i did a switchover today, here is the plan :
- 4 set on 1 cluster
- many slave
- no cascading
- changing master from 1 to 2

slonik (all name, numbers changed or hidden) :
-------------------------------------------------------------
cluster name : foo
node 1 admin conninfo='blablabla';
node 2 admin conninfo='blablabla';
node 3 admin conninfo='blablabla';
node 4 admin conninfo='blablabla';
etc ...

echo 'Locking down set 1 on node 1';
lock set (id = 1, origin = 1);
echo 'Locked down - moving it';
move set (id = 1, old origin = 1, new origin = 2);
echo 'move set 1 done.';
# note : move set automatically do the "unlock set"

echo 'Locking down set 2 on node 1';
lock set (id = 2, origin = 1);
echo 'Locked down - moving it';
move set (id = 2, old origin = 1, new origin = 2);
echo 'move set 2 done.';
etc ...

#at this point. the new master is node 2, but all slave are still
subscribing to 1.
#replication still works because node 1 (old origin) is cascading the
replication to all slaves.

#time to resubscribe from node 2 now, so we can shutdown node 1
#some node (node 5 in the exemple) are not forwarding because they
will never become master (not powerfull enough)
#note : you don't need to resubscribe the old master, because the
"move set" automatically change the provider for this one
echo 'resubscribing all node';
subscribe set (id = 4, provider = 2, receiver = 3, forward = yes);
subscribe set (id = 3, provider = 2, receiver = 3, forward = yes);
subscribe set (id = 2, provider = 2, receiver = 3, forward = yes);
subscribe set (id = 1, provider = 2, receiver = 3, forward = yes);
subscribe set (id = 4, provider = 2, receiver = 4, forward = yes);
subscribe set (id = 3, provider = 2, receiver = 4, forward = yes);
subscribe set (id = 2, provider = 2, receiver = 4, forward = yes);
subscribe set (id = 1, provider = 2, receiver = 4, forward = yes);
subscribe set (id = 4, provider = 2, receiver = 5, forward = no);
subscribe set (id = 3, provider = 2, receiver = 5, forward = no);
subscribe set (id = 2, provider = 2, receiver = 5, forward = no);
subscribe set (id = 1, provider = 2, receiver = 5, forward = no);
etc ...

echo 'all done. Time to relax';

in fact, i did that in 2 step (and 2 files).
1) move set first, check in table foo.sl_subscribe if everything is ok
2) then resubscribe, and check again foo.sl_subscribe

Hope that help !

BIG PS : That was my biggest concern. i wasn't 100% that lock set will
or will not lock the slave too.
it never lock the slaves, so you can keep your slave in production
while moving the master :)
yay \o/

-- 
Laurent Laborde
Sysadmin & DBA at jfg://jfg-networks
http://www.over-blog.com/


More information about the Slony1-general mailing list