Oracle 5.0 Reference Manual page 2600

Table of Contents

Advertisement

"slave": {
},
"filters": { "roundrobin": [] }
}
}
Example 20.251. Manual failover
<?php
$mysqli = new mysqli("myapp", "username", "password", "database");
if (!$mysqli)
/* Of course, your error handling is nicer... */
die(sprintf("[%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()));
$sql = "SELECT 1 FROM DUAL";
/* error handling as it should be done regardless of the plugin */
if (!($res = $link->query($sql))) {
/* plugin specific: check for connection error */
switch ($link->errno) {
case 2002:
case 2003:
case 2005:
printf("Connection error - trying next slave!\n");
/* load balancer will pick next slave */
$res = $link->query($sql);
break;
default:
/* no connection error, failover is unlikely to help */
die(sprintf("SQL error: [%d] %s", $link->errno, $link->error));
break;
}
}
if ($res) {
var_dump($res->fetch_assoc());
}
?>
20.7.6.4.10. Partitioning and Sharding
Copyright 1997-2012 the PHP Documentation Group. [2230]
Database clustering is done for various reasons. Clusters can improve availability, fault tolerance, and
increase performance by applying a divide and conquer approach as work is distributed over many
machines. Clustering is sometimes combined with partitioning and sharding to further break up a large
complex task into smaller, more manageable units.
The mysqlnd_ms plugin aims to support a wide variety of MySQL database clusters. Some flavors
of MySQL database clusters have built-in methods for partitioning and sharding, which could be
transparent to use. The plugin supports the two most common approaches: MySQL Replication table
filtering, and Sharding (application based partitioning).
MySQL Replication supports partitioning as filters that allow you to create slaves that replicate all or
specific databases of the master, or tables. It is then in the responsibility of the application to choose a
slave according to the filter rules. You can either use the mysqlnd_ms
support this, or use the experimental table filter.
Mysqlnd replication and load balancing plugin (mysqlnd_ms)
"slave_0": {
"host": "simulate_slave_failure",
"port": "0"
},
"slave_1": {
"host": "127.0.0.1",
"port": 3311
}
2580
filter to manually
node_groups

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents