dbTalk Databases Forums  

MySQL Replication - promote slave

comp.databases.mysql comp.databases.mysql


Discuss MySQL Replication - promote slave in the comp.databases.mysql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Radoulov, Dimitre
 
Posts: n/a

Default MySQL Replication - promote slave - 06-21-2011 , 10:54 AM






Hi all,
I need to document the switch between master and slave
and I want to double check if the outlined procedure is correct.

We have a simple master slave replication setup on OEL 5.5 and MySQL 5.5.13.


Original config: machineA master, machineB slave.
Target: machineB master, machineA not operational.

On the master:

1. flush logs (only if it's accessible, of course).

On the slave:

2. stop slave io_thread
3. Wait until show processlist reports "Has read all relay log".
4. stop slave
5. reset master
6. change master to master_host='' and reset slave (only to be sure that
the slave couldn't be started easily by mistake)
7. Start the application and check if everything's OK

Now I should have only machineB operational,
I don't care for the state of machineA at this point.

To restore the initial state: machineA master, machineB slave:

1. Stop the application (assuming that's not a problem).
2. Generate a consistent dump on machineB:

mysqldump -u username -ppassword -A -x > dump_file

3. Import on machineA

mysql -u username -ppassword < dump_file

4. On machineA after the import:

reset master;
change master to master_host=''; # just in case, I prefer to have
# all info reset for safety
reset slave; # see above
flush tables with read lock; # just in case, because there are
# no connections but mine at
# this time
show master status; # just in case, it should be 4,
# right after the reset master
# command

5. On machineB (the slave):

change master to
master_host='machineA',
master_user='<my_rep_usr>',
master_password='<password>',
master_log_file='mysql-bin.000001',
master_log_pos=<pos>;

master_log_file and master_log_pos should be unnecessary because after
the reset master their values should correspond to the default values
of the change master command, but again, it's just for safety.

Am I missing something?


Best regards
Dimitre

Reply With Quote
  #2  
Old   
Radoulov, Dimitre
 
Posts: n/a

Default Re: MySQL Replication - promote slave - 06-21-2011 , 01:14 PM






On 21/06/2011 17:54, Radoulov, Dimitre wrote:
Quote:
Hi all,
I need to document the switch between master and slave
and I want to double check if the outlined procedure is correct.

We have a simple master slave replication setup on OEL 5.5 and MySQL
5.5.13.


Original config: machineA master, machineB slave.
Target: machineB master, machineA not operational.

On the master:

1. flush logs (only if it's accessible, of course).

On the slave:

2. stop slave io_thread
3. Wait until show processlist reports "Has read all relay log".
4. stop slave
5. reset master
6. change master to master_host='' and reset slave (only to be sure that
the slave couldn't be started easily by mistake)
7. Start the application and check if everything's OK

Now I should have only machineB operational,
I don't care for the state of machineA at this point.

To restore the initial state: machineA master, machineB slave:

1. Stop the application (assuming that's not a problem).
2. Generate a consistent dump on machineB:

mysqldump -u username -ppassword -A -x > dump_file

3. Import on machineA

mysql -u username -ppassword < dump_file

4. On machineA after the import:

reset master;
change master to master_host=''; # just in case, I prefer to have
# all info reset for safety
reset slave; # see above
flush tables with read lock; # just in case, because there are
# no connections but mine at
# this time
show master status; # just in case, it should be 4,
# right after the reset master
# command

5. On machineB (the slave):

change master to
master_host='machineA',
master_user='<my_rep_usr>',
master_password='<password>',
master_log_file='mysql-bin.000001',
master_log_pos=<pos>;

master_log_file and master_log_pos should be unnecessary because after
the reset master their values should correspond to the default values
of the change master command, but again, it's just for safety.
And of course there are also:

on the slave:

start slave;
show slave status\G

on the master:

unlock tables;

And finally start the application.



Dimitre

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.