Spec-Zone .ru
спецификации, руководства, описания, API

14.2.9.6. Using the InnoDB memcached Plugin with Replication

Because the InnoDB memcached daemon plugin supports the MySQL binary log, any updates made on a master server through the memcached interface can be replicated for backup, balancing intensive read workloads, and high availability. All memcached commands are supported for binlogging.

You do not need to set up the InnoDB memcached plugin on the slave servers. In this configuration, the primary advantage is increased write throughput on the master. The speed of the replication mechanism is not affected.

The following sections show how to use the binlog capability, to use the InnoDB memcached plugin along with MySQL replication. It assumes you have already done the basic setup described in Section 14.2.9.3, "Getting Started with InnoDB Memcached Plugin".

Enable InnoDB Memcached Binary Log with innodb_api_enable_binlog:

Test with the memcached telnet interface:

To test the server with the above replication setup, we use the memcached telnet interface, and also query the master and slave servers using SQL to verify the results.

In our configuration setup SQL, one example table demo_test is created in the test database for use by memcached. We will use this default table for the demonstrations:

In the master server, you can see that the row is inserted. c1 maps to the key, c2 maps to the value, c3 is the flag, c4 is the cas value, and c5 is the expiration.

mysql> select * from test.demo_test;
c1 c2 c3 c4 c5
test1 t1 10 2 0
1 row in set (0.00 sec)

In the slave server, you will see the same record is inserted by replication:

mysql> select * from test.demo_test;
c1 c2 c3 c4 c5
test1 t1 10 2 0
1 row in set (0.00 sec)
Connected to 127.0.0.1.Escape character is '^]'.set test1 10 0 3newSTORED

From the slave server, the update is replicated (notice the cas value also updated):

mysql> select * from test.demo_test;
c1 c2 c3 c4 c5
test1 new 10 3 0
1 row in set (0.00 sec)
Connected to 127.0.0.1.Escape character is '^]'.delete test1DELETED

When the delete is replicated to the slave, the record on the slave is also deleted:

mysql> select * from test.demo_test;Empty set (0.00 sec)

First, insert two records by telnetting to the master server:

Connected to 127.0.0.1.Escape character is '^]'set test2 10 0 5againSTOREDset test3 10 0 6again1STORED

In the slave server, confirm these two records are replicated:

mysql> select * from test.demo_test;
c1 c2 c3 c4 c5
test2 again 10 5 0
test3 again1 10 6 0
2 rows in set (0.00 sec)

Call flush_all in the telnet interface to truncate the table:

Connected to 127.0.0.1.Escape character is '^]'.flush_allOK

Then check that the truncation operation is replicated on the slave server:

mysql> select * from test.demo_test;Empty set (0.00 sec)

All memcached commands are supported in terms of replication.

Notes for the InnoDB Memcached Binlog:

Binlog Format:

Transactions: