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.
mysql_Slave> SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1;<br />
mysql_Slave> START SLAVE;<br />
Exercise: Switching Replication Channel<br />
Switching replication channels is needed when the <strong>MySQL</strong> Server from which the Slave is<br />
reading changes, went down. It is also useful when doing a rolling upgrade of <strong>Cluster</strong>.<br />
For the tutorial we will be starting a second <strong>MySQL</strong> <strong>Cluster</strong> which will be reading changes<br />
from the first (Master) <strong>MySQL</strong> <strong>Cluster</strong>. We will be switching the <strong>MySQL</strong> Server from which<br />
the Slave <strong>Cluster</strong> is reading from.<br />
Starting Master and Slave <strong>Cluster</strong><br />
Start the Master <strong>MySQL</strong> <strong>Cluster</strong>. We will start it empty for this exercise:<br />
shell> cd /opt/mysqlcluster<br />
shell> ndb_mgmd -f config.ini<br />
shell> ndbd -c localhost:1186 --initial<br />
shell> ndbd -c localhost:1186 --initial<br />
shell> mysqld_safe --defaults-file=my_A.cnf &<br />
shell> mysqld_safe --defaults-file=my_B.cnf &<br />
Lets start the Slave <strong>MySQL</strong> <strong>Cluster</strong>, note that it has only 1 data node:<br />
shell> cd /opt/mysqlcluster<br />
shell> ndb_mgmd -f config_Slave.ini --configdir=/opt/mysqlcluster/ndb_Slave<br />
shell> ndbd -c localhost:1187<br />
shell> mysqld_safe --defaults-file=my_Slave.cnf &<br />
You can check the Slave <strong>Cluster</strong> and connect to the <strong>MySQL</strong> Server using following:<br />
shell> ndb_mgm -c localhost:1187<br />
shell> mysql -S /tmp/mysql_Slave<br />
Setting up the Replication Users on the Master<br />
We have to create the replication users on both <strong>MySQL</strong> Servers. The grant tables are local<br />
to each <strong>MySQL</strong> Server and are not stored in the Data Nodes:<br />
shell> mysql<br />
mysql_A> GRANT REPLICATION SLAVE ON *.* TO repl@127.0.0.1;<br />
shell> mysql -S /tmp/mysql_B<br />
mysql_B> GRANT REPLICATION SLAVE ON *.* TO repl@127.0.0.1;<br />
Starting Replication<br />
To start the replication we will need the actual position of the binary log. Initially the Slave<br />
will be reading from the first <strong>MySQL</strong> Server of the master, mysql_A:<br />
shell> mysql<br />
mysql_A:(none)> SHOW MASTER STATUS;<br />
+------------------------+----------+-..<br />
| File | Position | ..<br />
+------------------------+----------+-..<br />
| master_A_binlog.000012 | 214 | ..<br />
+------------------------+----------+-..<br />
Copyright © 2010, Oracle and/or its affiliates. All rights reserved. 78/81