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.

On the Slave we now issue the CHANGE MASTER TO <strong>com</strong>mand using the information we<br />

got from the Master <strong>MySQL</strong> Server above:<br />

mysql_Slave> CHANGE MASTER TO<br />

MASTER_HOST='127.0.0.1',MASTER_PORT=3306,<br />

MASTER_USER='repl',<br />

MASTER_LOG_FILE='master_A_binlog.000012',<br />

MASTER_LOG_POS=214;<br />

Start the Slave and check the status for any errors. The IO_Thread and SQL_Thread should<br />

be running, saying ‘Yes’:<br />

mysql_Slave> START SLAVE;<br />

mysql_Slave> SHOW SLAVE STATUS\G<br />

Creating table, inserting data, checking:<br />

mysql_A> CREATE TABLE attendees (<br />

id INT UNSIGNED NOT NULL AUTO_INCREMENT,<br />

email VARCHAR(200),<br />

PRIMARY KEY (id)<br />

) ENGINE=NDB<strong>Cluster</strong>;<br />

mysql_A> INSERT INTO attendees (email) VALUES ('geertv@localhost'),<br />

('andrewh@localhost'),('andrewm@localhost');<br />

Check the data in the table attendees on mysql_A and <strong>com</strong>pare it with the content<br />

of using mysql_Slave.<br />

Shut down <strong>MySQL</strong> from Master <strong>Cluster</strong><br />

For this exercise we just shutdown the mysql_A <strong>MySQL</strong> Server. This means that the Slave<br />

will not be able to read from the Master anymore:<br />

shell> mysqladmin -S /tmp/mysql shutdown<br />

We are not starting it again, but if you would, you’ll notice that the Slave side will have a<br />

LOST_EVENTS error.<br />

After the <strong>MySQL</strong> Server mysql_A is down, you can insert some data using mysql_B. This is<br />

a control. The Slave will not get it, but will when we switched it.<br />

mysql_B> insert into attendees (email) values ('marta@localhost');<br />

mysql_Slave> SELECT * FROM attendees;<br />

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

| id | email |<br />

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

| 3 | andrewm@localhost |<br />

| 1 | geertv@localhost |<br />

| 2 | andrewh@localhost |<br />

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

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

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

Saved successfully!

Ooh no, something went wrong!