Oracle 5.0 Reference Manual page 2649

Table of Contents

Advertisement

Mysqlnd replication and load balancing plugin (mysqlnd_ms)
Upon connect the
mysqlnd
configuration file. If hostname and section name match, the plugin will load the sections settings.
Example 20.292. Using section names example
[myapp]
master[] = localhost
slave[] = 192.168.2.27
slave[] = 192.168.2.28:3306
[localhost]
master[] = localhost:/tmp/mysql/mysql.sock
slave[] = 192.168.3.24:3305
slave[] = 192.168.3.65: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
[localhost]
longer only use the MySQL server running on the host
balance MySQL queries following the rules from the
can load balance queries from an application without changing the applications source code.
The master[],
slave[]
directives supporting list-like syntax may appear multiple times in a configuration section. The plugin
maintains the order in which entries appear when interpreting them. For example, the below example
shows two
configuration directives in the configuration section [myapp]. If doing round-
slave[]
robin load balancing for read-only queries, the plugin will send the first read-only query to the MySQL
server
mysql_slave_1
to the MySQL server
mysql_slave_2
supporting list-like syntax result are ordered from top to bottom in accordance to their appearance
within a configuration section.
Example 20.293. List-like syntax
[myapp]
master[] = mysql_master_server
slave[] = mysql_slave_1
slave[] = mysql_slave_2
Here is a short explanation of the configuration directives that can be used.
string
master[]
plugin compares the hostname with all section names from the plugin
and
configuration directives use a list-like syntax. Configuration
pick[]
because it is the first in the list. The second read-only query will be send
because it is the second in the list. Configuration directives
URI of a MySQL replication master server. The URI follows the
syntax hostname[:port|unix_domain_socket].
The plugin supports using only one master server.
Setting a master server is mandatory. The plugin will report
a warning upon connect if the user has failed to provide a
master server for a configuration section. The warning may read
(mysqlnd_ms) Cannot find master section in
2629
and a plugin configuration section
localhost
but the plugin will start to load
localhost
configuration section. This way you
[localhost]
or
127.0.0.1
config.

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents