Master/Master (High availability)
Last updated on
30 April 2025
The following setup will preferably use master1 as master and master2 as slave. If one of them fails, it will use the remaining db as both master and slave retaining write capabilities.
<?php
$databases['default']['master1'] = array (
'database' => 'mydatabase',
'username' => 'readwrite',
'password' => 'readwrite',
'host' => 'master1',
'port' => '',
'driver' => 'mysql',
'prefix' => '',
);
$databases['default']['master2'] = array (
'database' => 'mydatabase',
'username' => 'readwrite',
'password' => 'readwrite',
'host' => 'master2',
'port' => '',
'driver' => 'mysql',
'prefix' => '',
);
$databases['default']['default'] = array (
'driver' => 'autoslave',
'master' => array('master1', 'master2'),
'slave' => array('master2', 'master1'),
);
?>
Help improve this page
Page status: Not set
You can:
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion