Mysqlnd replication and load balancing plugin (
mysqlnd_ms
)
2626
$mysqli->set_charset("latin1");
$mysqli->real_escape("this will be escaped using latin1");
/* server_charset implicitly set - utf8 connection */
$mysqli->query("SELECT 'This connection will be set to server_charset upon establishing' AS _msg FROM DUAL");
/* latin1 used from now on */
$mysqli->set_charset("latin1");
?>
master_on_write
bool
If set, the plugin will use the master server only after the first
statement has been executed on the master. Applications can
still send statements to the slaves using SQL hints to overrule the
automatic decision.
The setting may help with replication lag. If an application runs an
INSERT
the plugin will, by default, use the master to execute all
following statements, including
SELECT
statements. This helps to
avoid problems with reads from slaves which have not replicated the
INSERT
yet.
Example 20.289. Master on write for consistent reads
{
"myapp": {
"master": {
"master_0": {
"host": "localhost"
}
},
"slave": {
"slave_0": {
"host": "192.168.78.136",
"port": "3306"
}
},
"master_on_write": 1
}
}
Please, note the
quality_of_service
filter introduced in version
1.2.0-alpha. It gives finer control, for example, for achieving read-
your-writes and, it offers additional functionality introducing
service
levels
.
All
transaction stickiness
settings, including
trx_stickiness=on
,
are overruled by
master_on_write=1
.
trx_stickiness
string
Transaction stickiness policy. Supported policies:
disabled
(default),
master
.
The setting requires 5.4.0 or newer. If used with PHP older
than 5.4.0, the plugin will emit a warning like
(mysqlnd_ms)
trx_stickiness strategy is not supported before
PHP 5.3.99
.
If no transaction stickiness policy is set or, if setting
trx_stickiness=disabled
, the plugin is not transaction
aware. Thus, the plugin may load balance connections and switch
connections in the middle of a transaction. The plugin is not
transaction safe. SQL hints must be used avoid connection switches
during a transaction.
Summary of Contents for 5.0
Page 1: ...MySQL 5 0 Reference Manual ...
Page 18: ...xviii ...
Page 60: ...40 ...
Page 396: ...376 ...
Page 578: ...558 ...
Page 636: ...616 ...
Page 844: ...824 ...
Page 1234: ...1214 ...
Page 1427: ...MySQL Proxy Scripting 1407 ...
Page 1734: ...1714 ...
Page 1752: ...1732 ...
Page 1783: ...Configuring Connector ODBC 1763 ...
Page 1793: ...Connector ODBC Examples 1773 ...
Page 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Page 2850: ...2830 ...
Page 2854: ...2834 ...
Page 2928: ...2908 ...
Page 3000: ...2980 ...
Page 3122: ...3102 ...
Page 3126: ...3106 ...
Page 3174: ...3154 ...
Page 3232: ...3212 ...