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 above picture shows one <strong>MySQL</strong> server doing binary logging. It does does by listening<br />

for events through NDB Injector-Thread.<br />

The above shown setup has one flaw, we’ll see later what.<br />

Enabling Binary Logging<br />

You can enable the binary logging in any SQL Node. Here is an example from the<br />

configuration files used in this tutorial:<br />

[mysqld]<br />

ndbcluster<br />

log_bin = master_A_binlog<br />

server_id = 1<br />

binlog_format = MIXED<br />

The --log-bin option enables the binary logging into files named master_A_binlog. The -binlog-format<br />

is not really needed, but it’s good to be explicit. Here is how the files look<br />

like:<br />

master_A_binlog.000011<br />

master_A_binlog.000012<br />

master_A_binlog.index<br />

Don’t forget to set the --server-id option to a value unique to each SQL Node<br />

participating in the <strong>MySQL</strong> <strong>Cluster</strong>. If you don’t do this, replication will not work.<br />

You can check the content of a binary log using the mysqlbinlog tool. Reading Row-Based<br />

or Mixed binary logs might be a bit difficult. Take for example the following table:<br />

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 />

Lets insert some data:<br />

INSERT INTO attendees (email) VALUES ('geert@localhost')<br />

Reading the binary log, you don’t get the SQL statement:<br />

shell> mysqlbinlog master_A_binlog.00001<br />

..<br />

BINLOG '<br />

Xz/CSxMBAAAAMwAAAO8DAAAAACUAAAAAAAEABHRlc3QACWF0dGVuZGVlcwACAw8CyAAC<br />

Xz/CSxMBAAAAPgAAAC0EAAAAABAAAAAAAAEABW15c3FsABBuZGJfYXBwbHlfc3RhdHVzAAUDCA8I<br />

CAL/AAA=<br />

Xz/CSxcBAAAAOwAAAGgEAAAAABAAAAAAAAAABR/gAQAAAA8AAACiAAAAAAAAAAAAAAAAAAAAAAAA<br />

AAA=<br />

Xz/CSxcBAAAAMgAAAJoEAAAQACUAAAAAAAEAAgP8AQAAAA9nZWVydEBsb2NhbGhvc3Q=<br />

'/*!*/;<br />

..<br />

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

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

Saved successfully!

Ooh no, something went wrong!