MySQL Cluster Tutorial - cdn.oreillystatic.com
MySQL Cluster Tutorial - cdn.oreillystatic.com
MySQL Cluster Tutorial - cdn.oreillystatic.com
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
shell> mysql<br />
mysql_A:(none)> SHOW MASTER STATUS;<br />
+------------------------+----------+-..<br />
| File | Position | ..<br />
+------------------------+----------+-..<br />
| master_A_binlog.000012 | 214 | ..<br />
+------------------------+----------+-..<br />
Using this information we can go to the Slave and issue the CHANGE MASTER <strong>com</strong>mand.<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 />
Then start the slave, and use SHOW SLAVE STATUS to see if it is working:<br />
mysql_Slave> START SLAVE;<br />
mysql_Slave> SHOW SLAVE STATUS\G<br />
..<br />
Slave_IO_State: Waiting for master to send event<br />
..<br />
Slave_IO_Running: Yes<br />
Slave_SQL_Running: Yes<br />
..<br />
Master_Server_Id: 1<br />
You create the table on the Master side, using the NDB<strong>Cluster</strong> engine. It should get created<br />
on the Slave as well:<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 />
Now you can simply insert data and see it replicating.<br />
Handling LOST_EVENTS<br />
Lets see what happens when we shutdown the mysql_A server and start again.<br />
shell> mysqladmin -S /tmp/mysql shutdown<br />
shell> mysqld_safe --defaults-file=/opt/mysqlcluster/my_A.cnf &<br />
Now, check the Slave:<br />
shell> mysql -S /tmp/mysql_Slave<br />
mysql_Slave> SHOW SLAVE STATUS\G<br />
..<br />
Last_Errno: 1590<br />
Last_Error: The incident LOST_EVENTS occured on the master.<br />
Message: mysqld startup<br />
..<br />
It is now up to you do decide whether you can continue skipping the error, knowing that<br />
you might have lost data or switch to the other replication channel.<br />
Skipping can be done doing this:<br />
Copyright © 2010, Oracle and/or its affiliates. All rights reserved. 77/81