![background image](http://html1.mh-extra.com/html/oracle/5-0/5-0_reference-manual_16461962669.webp)
Mysqlnd replication and load balancing plugin (
mysqlnd_ms
)
2649
$ret = mysqlnd_ms_set_qos($mysqli, MYSQLND_MS_QOS_CONSISTENCY_SESSION);
if (!$ret)
die(sprintf("[%d] %s\n", $mysqli->errno, $mysqli->error));
/* Will use master and return fresh data, client can see his last write */
if (!$res = $mysqli->query("SELECT item, price FROM orders WHERE order_id = 1"))
die(sprintf("[%d] %s\n", $mysqli->errno, $mysqli->error));
/* Back to default: use of all slaves and masters permitted, stale data can happen */
if (!mysqlnd_ms_set_qos($mysqli, MYSQLND_MS_QOS_CONSISTENCY_EVENTUAL))
die(sprintf("[%d] %s\n", $mysqli->errno, $mysqli->error));
?>
See Also
mysqlnd_ms_get_last_gtid
Service level and consistency concept
Filter concept
20.7.6.8.7.
mysqlnd_ms_set_user_pick_server
Copyright 1997-2012 the PHP Documentation Group. [2230]
•
mysqlnd_ms_set_user_pick_server
Sets a callback for user-defined read/write splitting
Description
bool mysqlnd_ms_set_user_pick_server(
string function);
Sets a callback for user-defined read/write splitting. The plugin will call the callback only if
pick[]=user
is the default rule for server picking in the relevant section of the plugins configuration
file.
The plugins built-in read/write query split mechanism decisions can be overwritten in two ways. The
easiest way is to prepend the 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.
Parameters
function
The function to be called. Class methods may also be invoked
statically using this function by passing
array($classname,
Содержание 5.0
Страница 1: ...MySQL 5 0 Reference Manual ...
Страница 18: ...xviii ...
Страница 60: ...40 ...
Страница 396: ...376 ...
Страница 578: ...558 ...
Страница 636: ...616 ...
Страница 844: ...824 ...
Страница 1234: ...1214 ...
Страница 1426: ...MySQL Proxy Scripting 1406 The following diagram shows an overview of the classes exposed by MySQL Proxy ...
Страница 1427: ...MySQL Proxy Scripting 1407 ...
Страница 1734: ...1714 ...
Страница 1752: ...1732 ...
Страница 1783: ...Configuring Connector ODBC 1763 ...
Страница 1793: ...Connector ODBC Examples 1773 ...
Страница 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Страница 1842: ...Connector Net Installation 1822 5 Once the installation has been completed click Finish to exit the installer ...
Страница 1864: ...Connector Net Visual Studio Integration 1844 Figure 20 24 Debug Stepping Figure 20 25 Function Stepping 1 of 2 ...
Страница 2850: ...2830 ...
Страница 2854: ...2834 ...
Страница 2928: ...2908 ...
Страница 3000: ...2980 ...
Страница 3122: ...3102 ...
Страница 3126: ...3106 ...
Страница 3174: ...3154 ...
Страница 3232: ...3212 ...