Oracle 5.0 Reference Manual page 2596

Table of Contents

Advertisement

Mysqlnd replication and load balancing plugin (mysqlnd_ms)
/* GTID as an identifier for the last write */
$gtid = mysqlnd_ms_get_last_gtid($mysqli);
/* Session consistency (read your writes): try to read from slaves not only master */
if (false == mysqlnd_ms_set_qos($mysqli, MYSQLND_MS_QOS_CONSISTENCY_SESSION, MYSQLND_MS_QOS_OPTION_GTID, $g
die(sprintf("[006] [%d] %s\n", $mysqli->errno, $mysqli->error));
}
/* Either run on master or a slave which has replicated the INSERT */
if (!($res = $mysqli->query("SELECT id FROM test"))) {
die(sprintf("[%d] %s\n", $mysqli->errno, $mysqli->error));
}
var_dump($res->fetch_assoc());
?>
A GTID returned from
mysqlnd_ms_get_last_gtid
consistency service level. Session consistency delivers read your writes. Session consistency can
be requested by calling mysqlnd_ms_set_qos. In the example, the plugin will execute the
statement either on the master or on a slave which has replicated the previous
PECL mysqlnd_ms will transparently check every configured slave if it has replicated the
checking the slaves GTID table. The check is done running the SQL set with the
option from the
global_transaction_id_injection
Please note, that this is a slow and expensive procedure. Applications should try to use it sparsely and
only if read load on the master becomes to high otherwise.
Use of the server-side global transaction ID feature
Starting with MySQL 5.6.5-m8 the MySQL Replication system features server-side global transaction
IDs. Transaction identifiers are automatically generated and maintained by the server. Users do not
need to take care of maintaining them. There is no need to setup any tables in advance, or for setting
on_commit. A client-side emulation is no longer needed.
Clients can continue to use global transaction identifier to achieve session consistency when reading
from MySQL Replication slaves. The algorithm works as described above. Different SQL statements
must be configured for
fetch_last_gtid
Please note, MySQL 5.6.5-m8 is a development version. Details of the server implementation may
change in the future and require adoption of the SQL statements shown.
Using the following configuration any of the above described functionality can be used together with the
server-side global transaction ID feature.
continue to work as described above. The only difference is that the server does not use a simple
sequence number but a string containing of a server identifier and a sequence number. Thus, users
cannot easily derive an order from GTIDs returned by mysqlnd_ms_get_last_gtid.
Example 20.245. Plugin config: using MySQL 5.6.5-m8 built-in GTID feature
{
"myapp": {
"master": {
"master_0": {
"host": "localhost",
"socket": "\/tmp\/mysql.sock"
}
},
"slave": {
"slave_0": {
"host": "127.0.0.1",
"port": "3306"
}
},
"global_transaction_id_injection":{
can be used as an option for the session
section of the plugins configuration file.
and check_for_gtid. The statements are given below.
mysqlnd_ms_get_last_gtid
2576
SELECT
already.
INSERT
by
INSERT
check_for_gtid
and
mysqlnd_ms_set_qos

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents