patternsqlMinor
Update MySQL slave when changing the hostname/IP of master
Viewed 0 times
theupdateslavemysqlmasterhostnamewhenchanging
Problem
I have one master and one slave replicating great, but the master is about to have both it's hostname and IP changed. In
If I used CHANGE MASTER queries instead it looks like it will require re-setting the binlog position etc?
master.info on the slave server I see the current hostname for the master, if I shutdown the slave server, change the hostname in that file and then restart MySQL will that be all I need? No usernames/passwords etc are changing. If I used CHANGE MASTER queries instead it looks like it will require re-setting the binlog position etc?
Solution
Once you change the
The "dark back-alley" approach you just suggested is exactly what to do.
On the Slave, run these four lines:
The last line echoes the number of lines in
Next,
Next, run
Next, start mysql without starting replication
Login to MySQL, and run
If the IP address you added appears, then run
If you see
Give it a Try !!!
MASTER_HOST, everything else needs to change with it.The "dark back-alley" approach you just suggested is exactly what to do.
Warning: Some systems use "mysqld" versus "mysql".
The --skip-slave-restart "option" may not available without editing your
/etc/init.d/mysqld script to include this as a new option.
If used, it will still start the slave upon startup.On the Slave, run these four lines:
cd /var/lib/mysql
service mysql stop
cp master.info master.info.bak
wc -l < master.infoThe last line echoes the number of lines in
master.infoNext,
vi master.info and change the IP address.Next, run
wc -l < master.info and make sure the linecount is still the sameNext, start mysql without starting replication
service mysql start --skip-slave-startLogin to MySQL, and run
SHOW SLAVE STATUS\GIf the IP address you added appears, then run
START SLAVE; SELECT SLEEP(5);
SHOW SLAVE STATUS\GIf you see
Slave_IO_Running : Yes and Slave_SQL_Running : Yes, Congratulations !!!Give it a Try !!!
Code Snippets
Warning: Some systems use "mysqld" versus "mysql".
The --skip-slave-restart "option" may not available without editing your
/etc/init.d/mysqld script to include this as a new option.
If used, it will still start the slave upon startup.</p>cd /var/lib/mysql
service mysql stop
cp master.info master.info.bak
wc -l < master.infoservice mysql start --skip-slave-startSHOW SLAVE STATUS\GSTART SLAVE; SELECT SLEEP(5);
SHOW SLAVE STATUS\GContext
StackExchange Database Administrators Q#30782, answer score: 6
Revisions (0)
No revisions yet.