From 8e11df454485832673ff7ffe5dd0566244291d4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Fri, 10 Apr 2026 12:49:28 +0400 Subject: [PATCH] Update PG migration runbook --- doc/postgres/migration.md | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/doc/postgres/migration.md b/doc/postgres/migration.md index e9d24d2..d1f7d27 100644 --- a/doc/postgres/migration.md +++ b/doc/postgres/migration.md @@ -210,7 +210,7 @@ sudo -u postgres pg_list_replication_subscriptions #### 11.1 Stop writes on old primary -(app maintenance mode, stop app/daemons) +Put app(s) in maintenance mode, stop the app/daemons. --- @@ -242,13 +242,20 @@ sudo -u postgres pg_fix_sequences [db_name] #### 11.4 Point app to NEW_HOST -* Update pg.kosmos.local in /etc/hosts on app server(s) (maybe override - attribute for role and converge) -* Start app/daemons, deactivate maintenance mode +1. Update `pg.kosmos.local` in `/etc/hosts` on app server(s). For example: + + ```bash + export NEW_PG_PRIMARY=[private_ip] + bundle exec knife ssh roles:ejabberd -a knife_zero.host "sudo sed -r \"s/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\s(pg.kosmos.local)/$NEW_PG_PRIMARY\t\1/\" -i /etc/hosts" + ``` + + Or override node attribute(s) if necessary and/or approporiate. + +2. Start the app/daemons, and deactivate maintenance mode. --- -### 🧹 12. CLEANUP (NEW_HOST) +### 🧹 12. CLEANUP NEW_HOST ```bash sudo -u postgres pg_drop_replication_subscriptions @@ -256,7 +263,7 @@ sudo -u postgres pg_drop_replication_subscriptions --- -### 🧹 13. CLEANUP (PRIMARY) +### 🧹 13. CLEANUP PRIMARY TODO: Looks like slots are dropped automatically, when subscriptions are dropped @@ -266,6 +273,15 @@ sudo -u postgres pg_drop_replication_publications --- +### 🧹 13. CLEANUP Chef + +Once all apps/databases are migrated, update the role in the node +config of the new primary to 'postgres_primary' and converge it. + +Also delete the old primary node config from the Chef repo. + +--- + ### ✅ DONE ---