Oracle 5.0 Reference Manual page 2634

Table of Contents

Advertisement

Mysqlnd replication and load balancing plugin (mysqlnd_ms)
Filter:
object
user
List of filter arguments.
Keyword
Description
A ssigns a load balancing weight/priority to a
weight
server. Please, find a description above.
The
replaces
user
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
or
MYSQLND_MS_LAST_USED_SWITCH
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"
2614
Version
Since 1.4.0.
,
MYSQLND_MS_SLAVE_SWITCH
. Using SQL hints one can

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents