Fail over to a standby database
This task is for administrators during a database outage when a standby exists. Exponential has no automatic database failover for PostgreSQL, MariaDB or MySQL: the standby is promoted with the database vendor's tools, and Exponential is then pointed at it. Background: Database high availability.
Contents
Before you start
- The incident lead decided to fail over (Database unreachable).
- The database team promoted the standby and gave you its host name; the site's database user exists there with the same rights.
- Know how far behind the standby was: content edited after that point is lost.
Steps
Maintenance mode, so nothing writes during the switch:
php bin/php/maintenance.php on --message="This service is temporarily unavailable." --allow-admin --allow-root-userPoint the site at the new primary in
settings/override/site.ini.append.php:[DatabaseSettings] Server=db-standby.internal.example.govIf replicas are configured (
UseSlaveServer), check they follow the new primary, or switch read splitting off. With the DFS cluster, the cluster's metadata database (file.ini [eZDFSClusteringSettings]) needs the same attention.Clear the INI cache and make PHP read it:
php bin/php/ezcache.php --clear-tag=ini --allow-root-user ./console exp:velocity deploy --allow-root-userOn several web servers, do steps 2 and 3 on each, or deploy the settings to all.
Check it worked
- From an allowed address: the administration loads, a page renders from the database, a test publish works.
./console exp:logs --tail=var/log/error.log --lines=20shows no connection errors.- Switch maintenance off and clear the page caches (Bring the site back online).
Afterwards
- Tell content owners which period may be lost and ask them to check recent changes.
- Rebuild a new standby with the database team; the settings change goes into version control.
- Record the failover and its duration for your continuity reporting.
Related pages
- Add a read replica
- Disaster recovery plan
- Databases in the official order (hosting)
- PostgreSQL for hosts
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
Become an Exponential Partner
Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.