Skip to content

eligibility-verification PG16 Clone リハーサル手順・記録(staging/✅ 実施済み)

2026-06-16〜17 に staging で実施済み(mental-online-karte #13719)。本書は実施記録+再現手順。 調査・固有値は → preflight.md。staging 実DB 適用は → staging.md。本番は → production.md。 汎用手順の背景は ../../procedure-clone-rehearsal.md


前提・対象

  • 対象: stagingeligibility-verification クラスタを Clone(copy-on-write)した破棄可能なクラスタ。
  • EVS は非-GlobalGlobalClusterIdentifier=null)→ dr-work-record / mental-appointment の リハで必要な「Global 化 → 削除 → standalone 化」の素振りは 不要。 そのまま「CPG 付替 → 標準 BG → Switchover → 事後」を素振りするだけでよい=最も単純なパターン
  • 踏み台は i-0cefcd4a25e8703e5(fd-office-connection)。fd-platform 踏み台では EVS DB に届かない。
  • 本体クラスタ(eligibility-verification)は無操作
bash
export AWS_PROFILE=staging-admin
R=ap-northeast-1
SRC=eligibility-verification
CL=eligibility-verification-bgtest-blue        # clone(=リハの blue)
BG_NAME=eligibility-verification-bgtest
TARGET_VER=16.13
BASTION=i-0cefcd4a25e8703e5

手順

bash
# (1) Clone 作成(copy-on-write)+ Writer 作成
#     ※ restore-...-to-point-in-time は --engine 不可(source から継承)。SG/subnet は source と同一。
aws rds restore-db-cluster-to-point-in-time --region $R \
  --source-db-cluster-identifier $SRC --db-cluster-identifier $CL \
  --restore-type copy-on-write --use-latest-restorable-time
aws rds wait db-cluster-available --region $R --db-cluster-identifier $CL
#     ★EVS は本番も Writer 1台 / Reader 無し → clone も 1台でよい(class は source と同じ db.t3.medium)
aws rds create-db-instance --region $R \
  --db-instance-identifier ${CL}-0 --db-cluster-identifier $CL \
  --engine aurora-postgresql --db-instance-class db.t3.medium
aws rds wait db-instance-available --region $R --db-instance-identifier ${CL}-0

# (2) source(PG13) custom Cluster PG(logical=1) を clone に付替 → Writer 再起動
#     logical_replication は static → 反映に再起動が必要。Reader が無いので Writer 1台のみ。
aws rds modify-db-cluster --region $R --db-cluster-identifier $CL \
  --db-cluster-parameter-group-name eligibility-verification --apply-immediately
aws rds reboot-db-instance --region $R --db-instance-identifier ${CL}-0
aws rds wait db-instance-available --region $R --db-instance-identifier ${CL}-0
#     踏み台 psql で SHOW rds.logical_replication;=on / SHOW wal_level;=logical / SHOW wal_sender_timeout;=0 を確認

# (2.5) ★BG 作成前に blue(clone) で pg_stat_statements 拡張を作成
#       (Green は同期中 read-only のため後からでは不可)
#   psql: CREATE EXTENSION IF NOT EXISTS pg_stat_statements;  → \dx で installed 確認
#   BG 作成前チェック(clone に対して): available / global=null / CPG in-sync /
#     SHOW rds.logical_replication=on / 長時間tx=0 / SHOW default_transaction_read_only=off /
#     pg_replication_slots・pg_publication が 0 行(外部CDC なし)

# (3) 標準 BG 作成(非-Global・target PG16 は cluster/instance 両方指定)
SRC_ARN=$(aws rds describe-db-clusters --region $R --db-cluster-identifier $CL --query 'DBClusters[0].DBClusterArn' --output text)
aws rds create-blue-green-deployment --region $R \
  --blue-green-deployment-name $BG_NAME --source "$SRC_ARN" \
  --target-engine-version $TARGET_VER \
  --target-db-cluster-parameter-group-name eligibility-verification-pg16 \
  --target-db-parameter-group-name eligibility-verification-pg16
BG=$(aws rds describe-blue-green-deployments --region $R \
  --query "BlueGreenDeployments[?BlueGreenDeploymentName=='$BG_NAME'].BlueGreenDeploymentIdentifier | [0]" --output text)

# (4) Green 検証 → ★Switchover 前ゲート(GO/NO-GO・production.md §5 と同じ)→ Switchover → 事後
#     Green: SHOW server_version;=16.13 / 3テーブルの件数が blue と一致 / ANALYZE VERBOSE
#     事後 : ALTER EXTENSION pg_stat_statements UPDATE; / slot 0 / ★verify script でシーケンス継続性

★検証チェックリスト(リハで確認すること)

  • [ ] logical_replication が Writer 1台の reboot で on になる(=本番の瞬断は Writer 1台分だけ)
  • [ ] BG 作成が external replication で失敗しない(EVS は publication/slot 0 で問題なし)
  • [ ] Green が 16.13 になり、3テーブルの件数が blue と一致する
  • [ ] Switchover 後にシーケンスがずれていない(★EVS 最大のリスク・preflight.md §5bash bash docs/sre/scripts/pg16-verify-eligibility-verification.sh --env staging --label post
  • [ ] ALTER EXTENSION pg_stat_statements UPDATE が 1.10 になる
  • [ ] Switchover の書込断が数秒であること(RDS events で実測)
  • [ ] ★db.t3.mediumCPUCreditBalance が BG 中に枯渇しないこと(preflight.md §2-1

★実測所要時間(2026-06-16〜17 staging clone・#13719)

工程実測
Green 作成(BG AVAILABLE まで)約33分(内訳: Read Replica 作成 約16分 + PG16 化 約14分)
Green offline(Blue は無停止)約12分
Switchover 書込断約2秒

後始末(全削除・課金停止)

bash
# BG レコード削除 → clone の instance/cluster を全削除(--skip-final-snapshot)
aws rds delete-blue-green-deployment --region $R --blue-green-deployment-identifier $BG --delete-target

# instance → cluster の順に削除(green/old も)
for I in $(aws rds describe-db-instances --region $R \
  --query "DBInstances[?starts_with(DBInstanceIdentifier,'eligibility-verification-bgtest')].DBInstanceIdentifier" --output text); do
  aws rds delete-db-instance --region $R --db-instance-identifier "$I" --skip-final-snapshot
done
for C in $(aws rds describe-db-clusters --region $R \
  --query "DBClusters[?starts_with(DBClusterIdentifier,'eligibility-verification-bgtest')].DBClusterIdentifier" --output text); do
  aws rds delete-db-cluster --region $R --db-cluster-identifier "$C" --skip-final-snapshot
done

# describe で eligibility-verification-bgtest-* が 0 件になるまで確認
aws rds describe-db-clusters --region $R \
  --query "DBClusters[?starts_with(DBClusterIdentifier,'eligibility-verification-bgtest')].DBClusterIdentifier" --output text