31.07.2013 Views

MySQL Cluster Tutorial - cdn.oreillystatic.com

MySQL Cluster Tutorial - cdn.oreillystatic.com

MySQL Cluster Tutorial - cdn.oreillystatic.com

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

The Switch<br />

We now have to tell the Slave <strong>MySQL</strong> Server it has to use the other <strong>MySQL</strong> server of the<br />

Master to read changes from. We have to find out what was the last ‘epoch’ or event from<br />

the Master that it applied. You do this with the following query:<br />

mysql_Slave> SELECT MAX(epoch) FROM mysql.ndb_apply_status;<br />

+---------------+<br />

| MAX(epoch) |<br />

+---------------+<br />

| 1915555414023 |<br />

+---------------+<br />

mysql_B> SELECT<br />

SUBSTRING_INDEX(File, '/', -1) AS BinLog,<br />

Position<br />

FROM mysql.ndb_binlog_index<br />

WHERE epoch >= 1915555414023<br />

ORDER BY epoch ASC LIMIT 1;<br />

+------------------------+----------+<br />

| BinLog | Position |<br />

+------------------------+----------+<br />

| master_B_binlog.000006 | 405 |<br />

+------------------------+----------+<br />

Back to the Slave, we’re using the CHANGE MASTER TO <strong>com</strong>mand to point it to the mysql_B<br />

server:<br />

mysql_Slave> STOP SLAVE;<br />

mysql_Slave> CHANGE MASTER TO<br />

MASTER_LOG_FILE = 'master_B_binlog.000006',<br />

MASTER_LOG_POS = 405,<br />

MASTER_HOST='127.0.0.1',<br />

MASTER_PORT=3307;<br />

You should now be able to start the Slave and previously done changes should get<br />

replicated:<br />

mysql_Slave> START SLAVE;<br />

mysql_Slave> SELECT * FROM attendees;<br />

+----+-------------------+<br />

| id | email |<br />

+----+-------------------+<br />

| 3 | andrewm@localhost |<br />

| 1 | geertv@localhost |<br />

| 2 | andrewh@localhost |<br />

| 4 | marta@localhost |<br />

+----+-------------------+<br />

Copyright © 2010, Oracle and/or its affiliates. All rights reserved. 80/81

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!