Update PG migration runbook

This commit is contained in:
2026-04-10 12:49:28 +04:00
parent 0020677ab2
commit 8e11df4544

View File

@@ -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
---