Mysqlnd replication and load balancing plugin (
mysqlnd_ms
)
2614
List of filter arguments.
Keyword
Description
Version
weight
Assigns a load balancing weight/priority to a
server. Please, find a description
above
.
Since 1.4.0.
Filter:
user
object
The
user
replaces
mysqlnd_ms_set_user_pick_server
function, which was removed in 1.1.0-beta. The filter sets a callback
for user-defined read/write splitting and server selection.
The plugins built-in read/write query split mechanism
decisions can be overwritten in two ways. The easiest
way is to prepend a query string with the SQL hints
MYSQLND_MS_MASTER_SWITCH
,
MYSQLND_MS_SLAVE_SWITCH
or
MYSQLND_MS_LAST_USED_SWITCH
. Using SQL hints one can
control, for example, whether a query shall be send to the MySQL
replication master server or one of the slave servers. By help of
SQL hints it is not possible to pick a certain slave server for query
execution.
Full control on server selection can be gained using a callback
function. Use of a callback is recommended to expert users only
because the callback has to cover all cases otherwise handled by
the plugin.
The plugin will invoke the callback function for selecting a server
from the lists of configured master and slave servers. The callback
function inspects the query to run and picks a server for query
execution by returning the hosts URI, as found in the master and
slave list.
If the lazy connections are enabled and the callback chooses a
slave server for which no connection has been established so
far and establishing the connection to the slave fails, the plugin
will return an error upon the next action on the failed connection,
for example, when running a query. It is the responsibility of
the application developer to handle the error. For example, the
application can re-run the query to trigger a new server selection
and callback invocation. If so, the callback must make sure to select
a different slave, or check slave availability, before returning to the
plugin to prevent an endless loop.
Example 20.280. Setting a callback
{
"myapp": {
"master": {
"master_0": {
"host": "localhost"
}
},
"slave": {
"slave_0": {
"host": "192.168.78.136",
"port": "3306"
}
},
"filters": {
"user": {
"callback": "pick_server"
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 ...