Mysqlnd replication and load balancing plugin (
mysqlnd_ms
)
2561
"slave": {
"slave_0": {
"host": "127.0.0.1",
"port": "3306"
}
}
}
}
The plugin attempts to notify you of invalid configurations. Since 1.5.0 it will throw a warning during
PHP startup if the configuration file cannot be read, is empty or parsing the JSON failed. Depending
on your PHP settings those errors may appear in some log files only. Further validation is done when
a connection is to be established and the configuration file is searched for valid sections. Setting
mysqlnd_ms.force_config_usage
may help debugging a faulty setup. Please, see also
configuration file
debugging notes [2606]
.
20.7.6.4.2. Running statements
Copyright 1997-2012 the PHP Documentation Group. [2230]
The plugin can be used with any PHP MySQL extension (
mysqli
,
mysql
, and
PDO_MYSQL
) that is
compiled to use the
mysqlnd
library. PECL/mysqlnd_ms plugs into the
mysqlnd
library. It does not
change the API or behavior of those extensions.
Whenever a connection to MySQL is being opened, the plugin compares the host parameter value of
the connect call, with the section names from the plugin specific configuration file. If, for example, the
plugin specific configuration file has a section
myapp
then the section should be referenced by opening
a MySQL connection to the host
myapp
Example 20.219. Plugin specific configuration file (mysqlnd_ms_plugin.ini)
{
"myapp": {
"master": {
"master_0": {
"host": "localhost",
"socket": "\/tmp\/mysql.sock"
}
},
"slave": {
"slave_0": {
"host": "192.168.2.27",
"port": "3306"
}
}
}
}
Example 20.220. Opening a load balanced connection
<?php
/* Load balanced following "myapp" section rules from the plugins config file */
$mysqli = new mysqli("myapp", "username", "password", "database");
$pdo = new PDO('mysql:host=myapp;dbname=database', 'username', 'password');
$mysql = mysql_connect("myapp", "username", "password");
?>
The connection examples above will be load balanced. The plugin will send read-only statements to
the MySQL slave server with the IP
192.168.2.27
and will listen on port
3306
for the MySQL client
connection. All other statements will be directed to the MySQL master server running on the host
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 ...