User Tools

Site Tools


mysql:changemasters

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
mysql:changemasters [2015/06/24 18:13] – [First: make future-master to become an slave of master] rlunaromysql:changemasters [2015/06/24 18:59] rlunaro
Line 71: Line 71:
 make sure all the changes were updated. make sure all the changes were updated.
  
 +===== Second: make the slave to change the master =====
  
 +We have this:
  
-This explains how to change the master of a running mysql database by the mechanism of+{{ :mysql:20150623_mysql_step_1.png?200 |}}
  
-  - Create a new slave wihtout downtime +And now we want this:
-  - Stop the current master and start a new master (the last slave)+
  
 +{{:mysql:20150623_mysql_step_3.png?200|}}
  
 +For that, we have to: 
 +
 +  - Stop the master
 +  - Check that both slaves are up-to-date
 +  - issue a [[https://dev.mysql.com/doc/refman/5.0/en/replication-solutions-switch.html|change master to]] command to the old slave
 +
 +==== Stop the master ====
 +
 +Nothing new under the sun: 
 +
 +<code>
 +/etc/rc.d/mysql stop 
 +</code>
 +
 +or:
 +
 +<code>
 +net stop mysql 
 +</code>
 +
 +==== Check that both slaves are up-to-date ====
 +
 +Among the information that ''show slave status\G'' displays, I've chosen Read_Master_Log_Pos to make sure
 +both database servers are in the same position. 
 +
 +==== Create (if it does not exist) a replication user in future-master ====
 +
 +<code>
 +grant replication slave, replication client on *.* to YOUR-REPLICATION-USERNAME identified by 'YOUR-REPLICATION-PASSWORD';
 +</code>
 +
 +==== Issue a change master command ====
 +
 +In the slave server I've issued a ''change master to'' command:
 +
 +<code>
 +stop slave;
 +
 +change master to master_host='future-master', 
 +master_port=3306,
 +master_user='YOUR-REPLICATION-USERNAME',
 +master_password='YOUR-REPLICATION-PASSWORD';
 +</code>
 +
 +And I've stopped and started the slave. 
  
-https://dev.mysql.com/doc/refman/5.0/en/replication-solutions-switch.html 
  
mysql/changemasters.txt · Last modified: 2022/12/02 22:02 by 127.0.0.1