Active-Passive Setup
An active-passive setup provides redundancy by maintaining a secondary (passive) server that can take over if the primary (active) server fails. This guide explains how to configure a Surfly active-passive setup.
Implementation Steps
Section titled “Implementation Steps”1. Install Surfly on Passive Node
Section titled “1. Install Surfly on Passive Node”Install the exact same version of Surfly on the passive node by following the installation documentation. Ensure all configuration steps are identical except for any host-specific settings.
2. Create Database Dumps on Active Node
Section titled “2. Create Database Dumps on Active Node”On the active node, create dumps of both the Surfly and Console databases:
# Create Surfly database dumppg_dump -U surfly_app surfly > ~/surfly_$(date +"%Y-%m-%d").sql
# Create Console database dumppg_dump -U surfly_app console > ~/console_$(date +"%Y-%m-%d").sql3. Transfer Database Dumps to Passive Node
Section titled “3. Transfer Database Dumps to Passive Node”Copy the database dumps from the active to the passive node:
# From active node, replace PASSIVE_NODE_IP with your passive node's IP addressscp ~/surfly_*.sql ~/console_*.sql user@PASSIVE_NODE_IP:/tmp/4. Import Databases on Passive Node
Section titled “4. Import Databases on Passive Node”On the passive node, stop required services before database restoration:
systemctl --user stop ss-pgbouncersudo systemctl restart postgresqlImport the databases:
# For SQL filesdropdb -U postgres surfly && createdb -U postgres -O surfly_app -E UTF8 surfly && psql -U surfly_app surfly < /tmp/surfly_YYYY-MM-DD.sqldropdb -U postgres console && createdb -U postgres -O surfly_app -E UTF8 console && psql -U surfly_app console < /tmp/console_YYYY-MM-DD.sqlRestart services after restoration:
systemctl --user start ss-surfly.targetManual Failover
Section titled “Manual Failover”To manually switch to the passive node:
- Update your load balancer configuration to direct traffic to the passive node
- Verify the passive node is operating correctly
Automatic Failover
Section titled “Automatic Failover”For automatic failover, configure a load balancer as described in the Failover documentation.