Skip to content

Instantly share code, notes, and snippets.

@Fernan2
Last active August 29, 2015 14:24
Show Gist options
  • Select an option

  • Save Fernan2/0c4c8fc208503838314b to your computer and use it in GitHub Desktop.

Select an option

Save Fernan2/0c4c8fc208503838314b to your computer and use it in GitHub Desktop.
Promote A Database Replica
https://support.cloud.engineyard.com/hc/en-us/articles/205408228-Promote-a-Database-Replica
En la BD réplica, antes de parar máquinas, comprobar el tiempo de la última sincronización (debe ser menor que 1 minuto):
psql -U postgres -t -c "SELECT (now() - pg_last_xact_replay_timestamp()) AS time_lag;"
En el App Master:
/etc/init.d/vixie-cron status
sudo /etc/init.d/vixie-cron stop
UPDATE: You'll need to be careful with vixie-cron stop. Your instances have a "cron nanny" task that is designed to restart cron in the event it should stop and this does carry the potential that cron could restart during your promotion. Depending on your scheduling of course this might not impact anything. The cron_nanny task itself is managed by inittab so it will restart automatically if killed.
Typically I recommend just commenting out tasks beforehand and then restoring them when done. A better long term solution would be to setup your tasks so they check for the presence of a "cron_maintenance" file and exit quietly if that exists. Prior to a maintenance you could simply touch this file, and then remove it when things are complete.
En la BD réplica comprobar que no hay otras conexiones activas:
psql -c 'SELECT pid, datname, application_name, client_hostname, waiting, query
FROM pg_stat_activity;' rankia3
Panel de control -> Promote 13:34
13:36 promoción terminada, la antigua es utility y la nueva es Master Database. Empieza un apply automático
13:40 el apply se había terminado al darle a refrescar... deploy!
13:41 deploy terminado -> disable maintenance mode
Eliminar la instancia utility tras comprobar que la web ya va
En el App Master:
sudo /etc/init.d/vixie-cron start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment