Manual:$wgDBservers
| LoadBalancer settings: $wgDBservers | |
|---|---|
| Database load balancer. |
|
| Introduced in version: | 1.2.0 |
| Removed in version: | still in use |
| Allowed values: | (see below) |
| Default value: | false |
Other settings: Alphabetical | By Function
[edit] Details
Database load balancer. This is a two-dimensional array, an array of server info structures. Fields are:
- host
- Host name (see $wgDBserver)
- dbname
- Default database name (see $wgDBname)
- user
- DB user (see $wgDBuser)
- password
- DB password (see $wgDBpassword)
- type
- "mysql" or "pgsql" (see $wgDBtype)
- load
- ratio of DB_SLAVE load, must be >=0, the sum of all loads must be >0
- groupLoads
- array of load ratios, the key is the query group name. A query may belong to several groups, the most specific group defined here is used. (added in 1.4.3)
- flags
- bit field:
- DBO_DEFAULT -- turns on DBO_TRX only if $wgCommandLineMode != true (recommended)
- DBO_DEBUG -- equivalent of $wgDebugDumpSql
- DBO_TRX -- wrap entire request in a transaction
- DBO_IGNORE -- ignore errors (not useful in LocalSettings.php)
- DBO_NOBUFFER -- turn off buffering (not useful in LocalSettings.php)
Leave at false to use the single-server variables listed above.
The master must be the first entry in the array.
Example:
$wgDBservers = array( array( 'host' => "master.serv.er", 'dbname' => "wikidb", 'user' => "wikiuser", 'password' => "secret", 'type' => "mysql", 'flags' => DBO_DEFAULT, 'load' => 0, ), array( 'host' => "slave1.serv.er", 'dbname' => "wikidb", 'user' => "wikiuser", 'password' => "secret", 'type' => "mysql", 'flags' => DBO_DEFAULT, 'load' => 1, ), array( 'host' => "slave2.serv.er", 'dbname' => "wikidb", 'user' => "wikiuser", 'password' => "secret", 'type' => "mysql", 'flags' => DBO_DEFAULT, 'load' => 1, ), );
This would configure one master and two slaves, which each slave get an equal amount of read access load.
- max lag
- (optional) Maximum replication lag before a slave will be taken out of rotation
- max threads
- (optional) Maximum number of running threads
These and any other user-defined properties will be assigned to the mLBInfo member variable of the Database object.
[edit] Early versions
Versions of MediaWiki prior to 1.4.0 used a single-dimensional array, listing the server names, e.g. array("larousse", "pliny"), which was used in conjunction with $wgDBloads. From 1.4.0 onwards, $wgDBloads is deprecated and the above method must be used.
The groupLoads field was added in 1.4.3.
max lag and max threads (and the use of other user-defined properties) was added in 1.6.0
[edit] See also
- $wgDBloads
- $wgDBserver: for single-server setup
| Language: | English • Français • 日本語 |
|---|