fastdoctor-manager PG16: Blue/Green の Green 側 instance class / storage 変更 検証手順書(合成データ・最小構成)
fastdoctor-manager.md §C-a の 実施順 ⑤【Green】green db5 class→m8g.2xlarge、db1(primary)/db3 の target class を modify が 本番で一度も実行されたことがないため、本番前に「仕組みとして成立するか」を確定させるための手順。
位置づけ: これは "仕組み" の検証であり "データ規模" の検証ではない。 本番データを一切持ち込まず(=PHI を持たない)、設定とトポロジだけを再現した合成 DB で実施する。 追跡: fastdoctor-jp/mental-online-karte#20479 / 基準案: fastdoctor-jp/mental-online-karte#19794 / 親: fastdoctor-jp/mental-online-karte#12730
手順書3本の役割分担
| 手順書 | 目的 | データ | 実行頻度 | |
|---|---|---|---|---|
| ① | fastdoctor-manager.md | 本番実施の正本 | — | 本番1回 |
| ② | fastdoctor-manager-production-rehearsal.md | 本番データ規模での BG 完走検証・所要時間実測 | 232GB クローン | 大きな変更時のみ |
| ③ | 本手順書 | Green 側 class/storage 変更の仕組み検証 | 合成・最小 | 何度でも |
なぜ②(フルクローン)を使わないのか
下表のとおり、本手順書が検証する項目は V6b 以外すべてデータ量に依存しない。
| 検証 | 内容 | 本番データ量が必要か |
|---|---|---|
| V1 | green replica の storage が green primary に自動一致するか | ❌ 構造的挙動 |
| V2 | green replica の class 変更成功・Blue 無影響 | ❌ 構造的 |
| V3 | green primary の class 変更方式(BG 作成時指定 vs 後 modify) | ❌ 構造的 |
| V4 | class 変更時の ReplicaLag / StatusDetails への影響 | △ レプリ活動は要るが合成負荷で足りる |
| V5 | class 変更後に switchover が完走するか | ❌ 構造的 |
| V6a | class 変更の所要時間(modify〜available) | ❌ インスタンス置換+reboot=データ量にほぼ非依存 |
| V6b | BG 作成 / switchover の所要時間 | ✅ データ量依存 → ②で測る。本手順書では測れない |
| V7 | t4g→m8g で CPU クレジットの概念が消えること | ❌ class 挙動 |
| V8 | max_connections(class 依存)が現ピークを上回るか | ❌ パラメータを見るだけ |
⚠️ 「軽量=ストレージが安い」ではない。 RDS のストレージ/プロビジョンド IOPS 料金は
AllocatedStorageとIopsの値で決まり、実データ量とは無関係。400GiB/12,000 IOPS を確保すれば中身が 232GB でも 1GB でも同額。 本手順書で節約されるのは 時間(スナップショット復元・BG 作成が数時間 → 数分。結果としてインスタンス稼働時間=費用)と PHI リスク。
③でしかできないこと:db3 相当の 321GiB 再現
②(スナップショット復元)では db3 の 321GiB を再現できない(復元元が 400GiB で、--allocated-storage は拡大のみ・縮小不可。replica は source を継承)。
本手順書は 新規作成なので、primary を 321GiB で作る → db3 replica 作成 → primary を 400GiB へ拡張 の順で本番構成を再現できる。
★本番そのものがこの手順の実例(2026-10-09 実測):
インスタンス 作成 Class Storage IOPS fastdoctor-manager-db12021-10-14 db.t4g.2xlarge400 GiB 12,000 fastdoctor-manager-db32024-08-23 db.t4g.large321 GiB 3,000 fastdoctor-manager-db52025-06-24 db.t4g.2xlarge400 GiB 12,000 db3 は db1 が 321GiB だった時期に作られ、その後 db1 が 400GiB へ拡張された。 = 「primary を拡張しても既存 replica は元のサイズのまま」 が本番で成立している証拠。
⚠️ 大原則
- 本番 DB からデータを一切持ち込まない。 スナップショット復元を使わない = PHI(実医療データ)を持たない。
- 本番からコピーするのは parameter group の設定値のみ(
copy-db-parameter-group= read-only)。 - 本物の共有PG
postgres12-fastdoctor-manager/postgres12-fastdoctor-manager-bgはcopy(read) のみ。modifyは絶対にしない(共有PGを変更すると本物 db3 まで pending-reboot になる)。 - 専用の別名
fdm-greenresize-*(②のfdm-rehearsal-*と混同しない)・専用 CPG・専用 SG を使う。 - 本物
fastdoctor-manager-db1/db3/db4/db5には一切コマンドを打たない。 - 検証完了後は Step 7 で一式を全削除する(コスト停止)。
共通の環境変数
export AWS_PROFILE=fdsys-admin ; R=us-east-1
aws sts get-caller-identity --query Account --output text # → 913831226605 を必ず確認
PFX=fdm-greenresize
TGT_VER=16.15 # 当日 live 確認で確定(16.9〜16.15)全体の流れ
Step 0. 本番の「設定」だけ収集(read-only・データは取らない)
Step 1. 専用 SG / 専用 CPG を作成(CPG は本番 -bg から copy)
Step 2. トポロジ構築(★primary 321 → db3 作成 → primary 400 へ拡張 → db5 作成)
Step 3. 合成データ投入 + 継続的な書き込み負荷(V4 の観測用)
Step 4. Blue/Green 作成(target PG16)
Step 5. ★V1〜V5 / V6a / V7 / V8 の検証
Step 6. switchover(V5)
Step 7. 全削除Step 0. 本番の「設定」だけ収集(read-only)
# 現行の class / storage / IOPS / engine / parameter group
aws rds describe-db-instances --region $R \
--query "DBInstances[?contains(DBInstanceIdentifier,'fastdoctor-manager')].{Id:DBInstanceIdentifier,\
Role:ReadReplicaSourceDBInstanceIdentifier,Class:DBInstanceClass,Engine:EngineVersion,\
Alloc:AllocatedStorage,Iops:Iops,Throughput:StorageThroughput,MultiAZ:MultiAZ,\
PG:DBParameterGroups[0].DBParameterGroupName}" --output table
# db1 が使っている parameter group の user パラメータ(★copy 元の確認)
aws rds describe-db-parameters --region $R \
--db-parameter-group-name postgres12-fastdoctor-manager-bg --source user \
--query 'Parameters[].[ParameterName,ParameterValue]' --output text
# 目標 class が PG16 で利用可能か(★PG12 では m8g が選べないことの確認も兼ねる)
for v in 12.22 $TGT_VER; do
echo "--- postgres $v ---"
aws rds describe-orderable-db-instance-options --region $R --engine postgres --engine-version $v \
--query "OrderableDBInstanceOptions[?starts_with(DBInstanceClass,'db.m8g')].DBInstanceClass" \
--output text | tr '\t' '\n' | sort -u | tr '\n' ' '; echo
done2026-10-09 実測の期待値
| 項目 | 値 |
|---|---|
| db1 | db.t4g.2xlarge / 12.22 / 400GiB / 12,000 IOPS / 500MiB / MultiAZ=true / PG=postgres12-fastdoctor-manager-bg |
| db3 | db.t4g.large / 321GiB / 3,000 IOPS / PG=postgres12-fastdoctor-manager |
| db5 | db.t4g.2xlarge / 400GiB / 12,000 IOPS / PG=postgres12-fastdoctor-manager-replica |
-bg の user パラメータ | rds.logical_replication=1 / wal_sender_timeout=0 / rds.force_ssl=1 ほか |
| m8g × PG 12.22 | 出力が空(=選べない) |
| m8g × PG 16.15 | db.m8g.2xlarge / db.m8g.xlarge ほかが出る |
- [ ] 上記を収集し、以降のコマンドの値を確定した
- [ ] 🛑 m8g が PG12 で空になることを自分の目で確認した(これが ⑤ を Green でしかできない理由)
Step 1. 専用 SG / 専用 CPG を作成
# 1-1. 専用 SG(踏み台 NAT の2本だけ許可。本物 sg-018407e4d8bf95620 は流用しない)
GR_SG=$(aws ec2 create-security-group --region $R \
--group-name ${PFX}-db-sg \
--description "green-resize verification SG (bastion only)" \
--vpc-id vpc-fe806583 \
--tag-specifications "ResourceType=security-group,Tags=[{Key=Name,Value=${PFX}-db-sg},{Key=ManagedBy,Value=manual},{Key=Issue,Value=20479}]" \
--query 'GroupId' --output text)
aws ec2 authorize-security-group-ingress --region $R --group-id "$GR_SG" \
--ip-permissions 'IpProtocol=tcp,FromPort=5432,ToPort=5432,IpRanges=[{CidrIp=3.113.154.169/32,Description="fd-platform tokyo NAT 1a - bastion"},{CidrIp=18.178.147.64/32,Description="fd-platform tokyo NAT 1c - bastion"}]'
echo "GR_SG=$GR_SG"
# 1-2. PG12 用 CPG(★本番 -bg から copy。read-only)
# 🛑 copy 元を postgres12-fastdoctor-manager(-bg なし)にしてはいけない。
# rds.logical_replication=1 / wal_sender_timeout=0 が無く BG 作成が失敗する。
aws rds copy-db-parameter-group --region $R \
--source-db-parameter-group-identifier postgres12-fastdoctor-manager-bg \
--target-db-parameter-group-identifier postgres12-${PFX} \
--target-db-parameter-group-description "green-resize verification PG12 (copied from prod -bg)"
# 1-3. copy 結果に BG 前提パラメータが入っているか(★入っていなければ先へ進まない)
aws rds describe-db-parameters --region $R --db-parameter-group-name postgres12-${PFX} --source user \
--query "Parameters[?ParameterName=='rds.logical_replication'||ParameterName=='wal_sender_timeout'].[ParameterName,ParameterValue]" --output text
# 期待: rds.logical_replication 1 / wal_sender_timeout 0
# 1-4. PG16 用 CPG(BG の target 用。family は TGT_VER に合わせる)
aws rds create-db-parameter-group --region $R \
--db-parameter-group-name postgres16-${PFX} --db-parameter-group-family postgres16 \
--description "green-resize verification PG16 target"
aws rds create-db-parameter-group --region $R \
--db-parameter-group-name postgres16-${PFX}-replica --db-parameter-group-family postgres16 \
--description "green-resize verification PG16 replica"- [ ]
${PFX}-db-sg作成済み・inbound は踏み台 NAT の2本のみ - [ ]
postgres12-${PFX}にrds.logical_replication=1/wal_sender_timeout=0が入っている - [ ]
postgres16-${PFX}/postgres16-${PFX}-replica作成済み
Step 2. トポロジ構築(★Method E・本番の履歴を再現)
要点: 本番の
db1=400 / db3=321 / db5=400は「db1 が 321 の時に db3 を作り、その後 db1 を 400 へ拡張し、さらに後で db5 を作った」結果。 同じ順序をたどることで、スナップショット復元では不可能な storage 非対称トポロジを再現する。
# 2-1. primary を ★321GiB / 3,000 IOPS で新規作成(空DB・PG 12.22・MultiAZ)
aws rds create-db-instance --region $R \
--db-instance-identifier ${PFX}-db1 \
--db-instance-class db.t4g.2xlarge \
--engine postgres --engine-version 12.22 \
--master-username fdadmin --manage-master-user-password \
--allocated-storage 321 --storage-type gp3 --iops 3000 --storage-throughput 125 \
--multi-az --no-publicly-accessible \
--db-subnet-group-name default-vpc-fe806583 \
--vpc-security-group-ids "$GR_SG" \
--db-parameter-group-name postgres12-${PFX} \
--backup-retention-period 1 \
--tags Key=ManagedBy,Value=manual Key=Issue,Value=20479
aws rds wait db-instance-available --region $R --db-instance-identifier ${PFX}-db1
# 2-2. ★db3 相当 replica を作成(この時点の source は 321GiB → 321 を継承)
aws rds create-db-instance-read-replica --region $R \
--db-instance-identifier ${PFX}-db3 \
--source-db-instance-identifier ${PFX}-db1 \
--db-instance-class db.t4g.large --no-multi-az --no-publicly-accessible \
--vpc-security-group-ids "$GR_SG" \
--tags Key=ManagedBy,Value=manual Key=Issue,Value=20479
aws rds wait db-instance-available --region $R --db-instance-identifier ${PFX}-db3
# 2-3. ★primary を 400GiB / 12,000 IOPS / 500MiB へ拡張(online・reboot なし)
# gp3 の 1→4 volume striping 閾値(400GiB)を跨ぐ。I/O 集中するが instance は稼働継続。
aws rds modify-db-instance --region $R --db-instance-identifier ${PFX}-db1 \
--allocated-storage 400 --iops 12000 --storage-throughput 500 --apply-immediately
aws rds wait db-instance-available --region $R --db-instance-identifier ${PFX}-db1
# 2-4. ★★ここが本手順書の肝: db3 が 321GiB のままであることを確認
aws rds describe-db-instances --region $R \
--query "DBInstances[?starts_with(DBInstanceIdentifier,'${PFX}')].{Id:DBInstanceIdentifier,\
Class:DBInstanceClass,Alloc:AllocatedStorage,Iops:Iops,Throughput:StorageThroughput}" --output table
# 期待: ${PFX}-db1 = 400/12000/500 / ${PFX}-db3 = 321/3000/125
# 2-5. db5 相当 replica を作成(この時点の source は 400GiB → 400 を継承)
aws rds create-db-instance-read-replica --region $R \
--db-instance-identifier ${PFX}-db5 \
--source-db-instance-identifier ${PFX}-db1 \
--db-instance-class db.t4g.2xlarge --no-multi-az --no-publicly-accessible \
--vpc-security-group-ids "$GR_SG" \
--tags Key=ManagedBy,Value=manual Key=Issue,Value=20479
aws rds wait db-instance-available --region $R --db-instance-identifier ${PFX}-db5完成形(本番と同一トポロジ)
${PFX}-db1 (primary) db.t4g.2xlarge 400 GiB / 12,000 IOPS / 500 MiB MultiAZ
├─ ${PFX}-db3 (replica) db.t4g.large 321 GiB / 3,000 IOPS / 125 MiB ← db3 相当
└─ ${PFX}-db5 (replica) db.t4g.2xlarge 400 GiB / 12,000 IOPS / 500 MiB ← db5 相当db4(大阪・cross-region replica)は作らない。 V1〜V8 の検証に不要で、コストと時間だけ増えるため。 cross-region replica が BG に与える影響は②(フルクローン)で検証済み/または本番手順書 §C-a-5 で扱う。
- [ ]
${PFX}-db1= 400GiB / 12,000 IOPS - [ ] 🛑
${PFX}-db3= 321GiB / 3,000 IOPS(primary 拡張後も変わっていないこと) - [ ]
${PFX}-db5= 400GiB / 12,000 IOPS - [ ] class が
2xlarge / large / 2xlargeの非対称になっていること - [ ] storage 拡張(2-3)で reboot / フェイルオーバーのイベントが出ていないこと
aws rds describe-events --region $R --source-identifier ${PFX}-db1 --source-type db-instance --duration 60
Step 3. 合成データ投入 + 継続的な書き込み負荷
目的: V4(class 変更時の ReplicaLag /
Replication degradedへの影響)を観測可能にすること。 本番データは使わない。pgbenchの合成データで十分。
接続は踏み台経由の SSM ポートフォワード(②手順書「踏み台経由の psql 接続」と同じ方式)。
# 3-1. 踏み台経由でトンネル(production アカウントの踏み台 i-0f44005c3f7259513)
DB_EP=$(aws rds describe-db-instances --region $R --db-instance-identifier ${PFX}-db1 \
--query 'DBInstances[0].Endpoint.Address' --output text)
LP=15440
AWS_PROFILE=production-admin aws ssm start-session --region ap-northeast-1 \
--target i-0f44005c3f7259513 --document-name AWS-StartPortForwardingSessionToRemoteHost \
--parameters "{\"host\":[\"$DB_EP\"],\"portNumber\":[\"5432\"],\"localPortNumber\":[\"$LP\"]}" &
# 3-2. マスタパスワードは Secrets Manager 管理(--manage-master-user-password)
# ★値は標準出力に出さない。PGPASSWORD へ直接流す。
SEC_ARN=$(aws rds describe-db-instances --region $R --db-instance-identifier ${PFX}-db1 \
--query 'DBInstances[0].MasterUserSecret.SecretArn' --output text)
PGPW="$(aws secretsmanager get-secret-value --region $R --secret-id "$SEC_ARN" \
--query SecretString --output text | python3 -c 'import sys,json;print(json.load(sys.stdin)["password"])')"
# 3-3. 合成データ投入(scale 50 ≒ 750MB。WAL を生むのが目的でデータ量自体は重要でない)
PGPASSWORD="$PGPW" pgbench -h 127.0.0.1 -p $LP -U fdadmin -d postgres -i -s 50
# 3-4. 継続的な書き込み負荷(★Step 5 の class 変更中も流し続ける)
PGPASSWORD="$PGPW" pgbench -h 127.0.0.1 -p $LP -U fdadmin -d postgres -c 4 -j 2 -T 7200 -P 30 &
unset PGPW- [ ]
pgbench -i完了(合成データ投入済み) - [ ] 書き込み負荷が流れており、
${PFX}-db3/${PFX}-db5のReplicaLagが計測できる状態 - [ ] 本番データを一切投入していないこと
Step 4. Blue/Green 作成
SRC_ARN=$(aws rds describe-db-instances --region $R --db-instance-identifier ${PFX}-db1 \
--query 'DBInstances[0].DBInstanceArn' --output text)
aws rds create-blue-green-deployment --region $R \
--blue-green-deployment-name ${PFX}-pg16 \
--source "$SRC_ARN" \
--target-engine-version $TGT_VER \
--target-db-parameter-group-name postgres16-${PFX} \
--tags Key=ManagedBy,Value=manual Key=Issue,Value=20479
BG_ID=$(aws rds describe-blue-green-deployments --region $R \
--query "BlueGreenDeployments[?BlueGreenDeploymentName=='${PFX}-pg16'].BlueGreenDeploymentIdentifier" --output text)
# AVAILABLE まで待つ(★合成データなので数分〜十数分の想定。232GB の②とは桁が違う)
for i in $(seq 1 120); do
aws rds describe-blue-green-deployments --region $R --blue-green-deployment-identifier $BG_ID \
--query 'BlueGreenDeployments[0].{Status:Status,Details:StatusDetails}' --output json
sleep 30
done
# green 側メンバーの identifier を取得
aws rds describe-blue-green-deployments --region $R --blue-green-deployment-identifier $BG_ID \
--query 'BlueGreenDeployments[0].SwitchoverDetails[].[SourceMember,TargetMember,Status]' --output table- [ ] BG が
AVAILABLE - [ ] green primary / green replica ×2 が生成されている
- [ ] 各 green の identifier を控えた(
GREEN_DB1/GREEN_DB3/GREEN_DB5)
Step 5. ★検証 V1〜V5 / V6a / V7 / V8
V1. green replica の storage が green primary に自動一致するか
本手順書の最大の検証項目。 blue は db1=400 / db3=321 / db5=400 の非対称。green でどうなるか。
for g in $GREEN_DB1 $GREEN_DB3 $GREEN_DB5; do
aws rds describe-db-instances --region $R --db-instance-identifier $g \
--query 'DBInstances[0].{Id:DBInstanceIdentifier,Class:DBInstanceClass,Engine:EngineVersion,\
Alloc:AllocatedStorage,Iops:Iops,Throughput:StorageThroughput,MultiAZ:MultiAZ}' --output table
done- [ ] V1 green primary / green replica の
AllocatedStorage/Iops/StorageThroughputを記録 - [ ] 判定:
fastdoctor-manager.md§C-a は「green replica の割当ストレージが green primary(400GiB) に自動一致する」と書いている。 - 一致した場合 → 前提が正しい。321GiB の db3 相当も 400GiB になる= storage 拡張が BG で自動的に済む - 一致しなかった場合(321 のまま) → §C-a の前提が誤り。db3 相当は 別途 storage 拡張が必要になるため、 実施順 ⑤ に「green db3 の storage を 400GiB へ modify」を追加する必要がある。手順書を訂正すること
V2 / V3. class 変更(★ここが ⑤ の本体)
# 事前: PendingModifiedValues が空であることを確認(空でなければ巻き込みリスク)
for g in $GREEN_DB1 $GREEN_DB3 $GREEN_DB5; do
aws rds describe-db-instances --region $R --db-instance-identifier $g \
--query 'DBInstances[0].{Id:DBInstanceIdentifier,Status:DBInstanceStatus,Pending:PendingModifiedValues}' --output json
done
# blue 側のベースライン(V2 の「Blue 無影響」判定用)
aws rds describe-db-instances --region $R \
--query "DBInstances[?starts_with(DBInstanceIdentifier,'${PFX}-db')].{Id:DBInstanceIdentifier,Status:DBInstanceStatus,Class:DBInstanceClass}" --output table
date -u '+%Y-%m-%dT%H:%M:%SZ' # ★class 変更開始時刻を記録(V6a 用)
# green replica から変更(影響が小さい方から)
aws rds modify-db-instance --region $R --db-instance-identifier $GREEN_DB5 \
--db-instance-class db.m8g.2xlarge --apply-immediately
aws rds wait db-instance-available --region $R --db-instance-identifier $GREEN_DB5
date -u '+%Y-%m-%dT%H:%M:%SZ'
aws rds modify-db-instance --region $R --db-instance-identifier $GREEN_DB3 \
--db-instance-class db.m8g.xlarge --apply-immediately
aws rds wait db-instance-available --region $R --db-instance-identifier $GREEN_DB3
date -u '+%Y-%m-%dT%H:%M:%SZ'
# green primary
aws rds modify-db-instance --region $R --db-instance-identifier $GREEN_DB1 \
--db-instance-class db.m8g.2xlarge --apply-immediately
aws rds wait db-instance-available --region $R --db-instance-identifier $GREEN_DB1
date -u '+%Y-%m-%dT%H:%M:%SZ'- [ ] V2 green replica の class 変更が成功した
- [ ] V2 Blue 側が無影響であること - blue の
DBInstanceStatus/DBInstanceClassが不変 - blue の RDS イベントにfailover/rebootが無いaws rds describe-events --region $R --source-identifier ${PFX}-db1 --source-type db-instance --duration 60-pgbenchが止まっていない(書き込みが継続している) - [ ] V3 green primary の class 変更が成功した
- [ ] V3 代替案の検討:
create-blue-green-deployment --target-db-instance-classで BG 作成時に指定する方式も試すか、 片方を選んだ理由を記録する。どちらが安全かを本番手順書へ反映する
V4. class 変更が BG のレプリケーションに与える影響
# class 変更の最中〜収束まで並行して回す
for i in $(seq 1 60); do
aws rds describe-blue-green-deployments --region $R --blue-green-deployment-identifier $BG_ID \
--query 'BlueGreenDeployments[0].{Status:Status,Details:StatusDetails}' --output json
for g in $GREEN_DB3 $GREEN_DB5; do
aws cloudwatch get-metric-statistics --region $R --namespace AWS/RDS --metric-name ReplicaLag \
--dimensions Name=DBInstanceIdentifier,Value=$g \
--start-time "$(date -u -v-10M '+%Y-%m-%dT%H:%M:%SZ')" --end-time "$(date -u '+%Y-%m-%dT%H:%M:%SZ')" \
--period 60 --statistics Average Maximum --output text
done
sleep 30
done- [ ] V4
StatusDetailsにReplication degradedが出たか/出た場合に自動収束したか - [ ] V4 green
ReplicaLagのピーク値と収束までの時間を記録 - [ ] V4 blue 側の
ReplicaLagが影響を受けていないこと
V6a. class 変更の所要時間
- [ ] V6a 記録する
| 対象 | class 変更 | 開始 | 完了 | 所要 |
|---|---|---|---|---|
| green db5 相当 | t4g.2xlarge → m8g.2xlarge | |||
| green db3 相当 | t4g.large → m8g.xlarge | |||
| green primary | t4g.2xlarge → m8g.2xlarge |
V6b(BG 作成 / switchover の本番データ規模での所要時間)は本手順書では測れない。②または過去実測を使う。
V7. t4g → m8g で CPU クレジットの概念が消えること
for g in $GREEN_DB1 $GREEN_DB5; do
aws cloudwatch list-metrics --region $R --namespace AWS/RDS --metric-name CPUCreditBalance \
--dimensions Name=DBInstanceIdentifier,Value=$g --query 'Metrics' --output json
done- [ ] V7 class 変更後に
CPUCreditBalanceが出力されなくなることを確認 - [ ] V7 →
fastdoctor-manager-preflight.mdの「⑦-b CPUクレジット余力(t4g)」チェックが BG 後は不要になるかを判定し、必要なら preflight 手順書を訂正する
V8. max_connections(class 依存)
# green primary へ接続して確認(Step 3 と同じトンネル方式。ポートは別番号)
# SHOW max_connections;
# SELECT current_setting('max_connections')::int;- [ ] V8 変更後の
max_connectionsを記録 - [ ] V8 本番の現ピーク接続を上回ること (参考: 2026-10-09 実測 db4 のピーク接続 = 57。db1 のピークは別途 CloudWatch で取得)
V9 / V10 は別手順書へ移した(2026-10-21・#21466)
ストレージ初期化(V9: Case A / Case B)と、切り替えでキャッシュが残るか(V10)、warm-up の比較試験は fastdoctor-manager-coldstart-rehearsal.md で行う。 本手順書(V1〜V8)とは目的が違い、データ量(数十 GB)と db6 相当の Multi-AZ レプリカが要るため分けた。 ⚠️ 本手順書の Step 2〜3・Step 7 には、#2915(未マージ)で直したブロッカー(managed master password・--no-publicly-accessible・切り替え後の --delete-target)が残っている。別手順書はそれらを反映済み。
Step 6. switchover(V5)
date -u '+%Y-%m-%dT%H:%M:%SZ'
aws rds switchover-blue-green-deployment --region $R \
--blue-green-deployment-identifier $BG_ID --switchover-timeout 300
for i in $(seq 1 60); do
aws rds describe-blue-green-deployments --region $R --blue-green-deployment-identifier $BG_ID \
--query 'BlueGreenDeployments[0].{Status:Status,Details:StatusDetails}' --output json
sleep 10
done
date -u '+%Y-%m-%dT%H:%M:%SZ'- [ ] V5
SWITCHOVER_COMPLETEDに到達した - [ ] V5 switchover 後の構成を確認(class が m8g のまま引き継がれているか)
bash aws rds describe-db-instances --region $R \ --query "DBInstances[?starts_with(DBInstanceIdentifier,'${PFX}')].{Id:DBInstanceIdentifier,\ Class:DBInstanceClass,Engine:EngineVersion,Alloc:AllocatedStorage,Iops:Iops}" --output table - [ ]
pgbenchの書き込みが switchover 中にどう振る舞ったかを記録(エラー/再接続の挙動)
Step 7. 全削除(★コスト停止・必ず実施)
# 7-1. BG を削除(green を残さない)
aws rds delete-blue-green-deployment --region $R \
--blue-green-deployment-identifier $BG_ID --delete-target
# 7-2. replica → primary の順に削除(replica は final snapshot 不可)
for id in ${PFX}-db3 ${PFX}-db5; do
aws rds delete-db-instance --region $R --db-instance-identifier $id --skip-final-snapshot
done
for id in ${PFX}-db3 ${PFX}-db5; do
aws rds wait db-instance-deleted --region $R --db-instance-identifier $id
done
aws rds delete-db-instance --region $R --db-instance-identifier ${PFX}-db1 \
--skip-final-snapshot --delete-automated-backups
aws rds wait db-instance-deleted --region $R --db-instance-identifier ${PFX}-db1
# 7-3. CPG / SG を削除
for pg in postgres12-${PFX} postgres16-${PFX} postgres16-${PFX}-replica; do
aws rds delete-db-parameter-group --region $R --db-parameter-group-name $pg
done
aws ec2 delete-security-group --region $R --group-id "$GR_SG"
# 7-4. 残骸が無いことを確認(★ここまでやって完了)
aws rds describe-db-instances --region $R \
--query "DBInstances[?starts_with(DBInstanceIdentifier,'${PFX}')].DBInstanceIdentifier" --output text
aws rds describe-db-parameter-groups --region $R \
--query "DBParameterGroups[?contains(DBParameterGroupName,'${PFX}')].DBParameterGroupName" --output text
aws rds describe-db-snapshots --region $R --snapshot-type manual \
--query "DBSnapshots[?contains(DBSnapshotIdentifier,'${PFX}')].DBSnapshotIdentifier" --output text
aws ec2 describe-security-groups --region $R \
--query "SecurityGroups[?GroupName=='${PFX}-db-sg'].GroupId" --output text
# すべて空であること- [ ] インスタンス / CPG / SG / snapshot すべて削除済み(上記4コマンドが空)
- [ ] 自動バックアップも削除済み(
--delete-automated-backups)
完了条件
- [ ] V1〜V5 / V6a / V7 / V8 の結果を fastdoctor-jp/mental-online-karte#20479 に記録
- [ ] V1 の結果に応じて
fastdoctor-manager.md§C-a の実施順 ⑤ を訂正/補強(PR 作成) - [ ] V3 の結論(green primary の class 変更方式)を §C-a に明記
- [ ] V7 の結論を
fastdoctor-manager-preflight.mdの ⑦-b に反映 - [ ] Step 7 で全削除し、コストが停止している
- [ ] 本番当日に初見で実行する工程が ⑤ に残っていない
コストと時間の目安
- インスタンスは blue 3台(primary は MultiAZ =実質4台分)+ green 3台 で最大 7台相当。
- ストレージ/IOPS 料金は合成データでも本番クローンでも同額(
AllocatedStorageとIopsで決まるため)。 本手順書で節約されるのは時間(スナップショット復元・BG 作成が数時間 → 数分)と PHI リスク。 - 想定所要: 2〜4時間(②のフルクローンは半日〜1日)。
- ⇒ 半日の枠で収まる。終了後は必ず Step 7 を実施する。