Switching Masters During Failover
1494
Each MySQL Slave (
Slave 1
,
Slave 2
, and
Slave 3
) is a slave running with
--log-bin
[1467]
and without
--log-slave-updates
[1451]
. Because updates received by a slave from the master
are not logged in the binary log unless
--log-slave-updates
[1451]
is specified, the binary log on
each slave is empty initially. If for some reason
MySQL Master
becomes unavailable, you can pick
one of the slaves to become the new master. For example, if you pick
Slave 1
, all
Web Clients
should be redirected to
Slave 1
, which will log updates to its binary log.
Slave 2
and
Slave 3
should then replicate from
Slave 1
.
The reason for running the slave without
--log-slave-updates
[1451]
is to prevent slaves from
receiving updates twice in case you cause one of the slaves to become the new master. Suppose that
Slave 1
has
--log-slave-updates
[1451]
enabled. Then it will write updates that it receives from
Master
to its own binary log. When
Slave 2
changes from
Master
to
Slave 1
as its master, it may
receive updates from
Slave 1
that it has already received from
Master
Make sure that all slaves have processed any statements in their relay log. On each slave, issue
STOP
SLAVE IO_THREAD
, then check the output of
SHOW PROCESSLIST
until you see
Has read all
relay log
. When this is true for all slaves, they can be reconfigured to the new setup. On the slave
Slave 1
being promoted to become the master, issue
STOP SLAVE
and
RESET MASTER
.
On the other slaves
Slave 2
and
Slave 3
, use
STOP SLAVE
and
CHANGE MASTER TO
MASTER_HOST='Slave1'
(where
'Slave1'
represents the real host name of
Slave 1
). To use
CHANGE MASTER TO
, add all information about how to connect to
Slave 1
from
Slave 2
or
Slave
3
(
user
,
password
,
port
). In
CHANGE MASTER TO
, there is no need to specify the name of the
Slave 1
binary log file or log position to read from: We know it is the first binary log file and position 4,
which are the defaults for
CHANGE MASTER TO
. Finally, use
START SLAVE
on
Slave 2
and
Slave
3
.
Once the new replication is in place, you will then need to instruct each
Web Client
to direct its
statements to
Slave 1
. From that point on, all updates statements sent by
Web Client
to
Slave 1
are written to the binary log of
Slave 1
, which then contains every update statement sent to
Slave 1
since
Master
died.
The resulting server structure is shown in
Figure 16.5, “Redundancy Using Replication, After Master
Failure”
.
Содержание 5.0
Страница 1: ...MySQL 5 0 Reference Manual ...
Страница 18: ...xviii ...
Страница 60: ...40 ...
Страница 396: ...376 ...
Страница 578: ...558 ...
Страница 636: ...616 ...
Страница 844: ...824 ...
Страница 1234: ...1214 ...
Страница 1426: ...MySQL Proxy Scripting 1406 The following diagram shows an overview of the classes exposed by MySQL Proxy ...
Страница 1427: ...MySQL Proxy Scripting 1407 ...
Страница 1734: ...1714 ...
Страница 1752: ...1732 ...
Страница 1783: ...Configuring Connector ODBC 1763 ...
Страница 1793: ...Connector ODBC Examples 1773 ...
Страница 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Страница 1842: ...Connector Net Installation 1822 5 Once the installation has been completed click Finish to exit the installer ...
Страница 1864: ...Connector Net Visual Studio Integration 1844 Figure 20 24 Debug Stepping Figure 20 25 Function Stepping 1 of 2 ...
Страница 2850: ...2830 ...
Страница 2854: ...2834 ...
Страница 2928: ...2908 ...
Страница 3000: ...2980 ...
Страница 3122: ...3102 ...
Страница 3126: ...3106 ...
Страница 3174: ...3154 ...
Страница 3232: ...3212 ...