Oracle 5.0 Reference Manual page 2624

Table of Contents

Advertisement

Mysqlnd replication and load balancing plugin (mysqlnd_ms)
configuration file. If the hostname and section name match, then the plugin will load the settings for that
section.
Example 20.265. Using section names example
{
"myapp": {
"master": {
"master_0": {
"host": "localhost"
}
},
"slave": {
"slave_0": {
"host": "192.168.2.27"
},
"slave_1": {
"host": "192.168.2.27",
"port": 3306
}
}
},
"localhost": {
"master": [
{
"host": "localhost",
"socket": "\/path\/to\/mysql.sock"
}
],
"slave": [
{
"host": "192.168.3.24",
"port": "3305"
},
{
"host": "192.168.3.65",
"port": "3309"
}
]
}
}
<?php
/* All of the following connections will be load balanced */
$mysqli = new mysqli("myapp", "username", "password", "database");
$pdo = new PDO('mysql:host=myapp;dbname=database', 'username', 'password');
$mysql = mysql_connect("myapp", "username", "password");
$mysqli = new mysqli("localhost", "username", "password", "database");
?>
Section names are strings. It is valid to use a section name such as 192.168.2.1,
localhost. If, for example, an application connects to
exists, the semantics of the connect operation are changed. The application will no longer
localhost
only use the MySQL server running on the host localhost, but the plugin will start to load balance
MySQL queries following the rules from the
balance queries from an application without changing the applications source code. Please keep in
mind, that such a configuration may not contribute to overall readability of your applications source
code. Using section names that can be mixed up with host names should be seen as a last resort.
Each configuration section contains, at a minimum, a list of master servers and a list of slave servers.
The master list is configured with the keyword master, while the slave list is configured with the
keyword. Failing to provide a slave list will result in a fatal
localhost
configuration section. This way you can load
localhost
E_ERROR
2604
127.0.0.1
and a plugin configuration section
level error, although a slave list
or
slave

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents