Share
Embed
こわくないRDS B/Gデプロイ
RDS B/Gデプロイで本番環境のDBをMySQL5.7から8.0にアップグレードしたので知⾒を共有します。2023年のペパボテックカンファレンス「夏のSREまつり」で喋ったときの資料です。
kesompochy
September 14, 2023
Transcript
48 slides
-
1 RDS B/Gデプロイで本番環境のDB をMySQL5.7から8.0にアップグ レードしたので知⾒を共有します こわくないRDS B/Gデプロイ 染⽮健⼈ on 2023.09.14
Pepabo Tech Conference #21 夏のSREまつり -
2 こんにちは GMOペパボ 技術部プラットフォームグループ 2022年 新卒⼊社 染⽮ 健⼈ Someya Kento
• ペパボでいろんなサービスのプラットフォームを 壊したり直したりしています • 社内ではpochy(そめやポチ)と呼ばせています • 好きなアザラシはワモンアザラシです • 各種サービスでのID : @kesompochy -
6 https://aws.amazon.com/jp/about-aws/whats-new/2023/09/amazon-aurora-rds-extended-support-mysql-postgresql-databases/ > Amazon Relational Database Service (RDS) は、MySQL 5.7、PostgreSQL
11、およびそれ以降のメジャーバージョンを 実行している Amazon Aurora および Amazon RDS データ ベースインスタンスの Amazon RDS 延長サポートを、コミュニ ティのサポート終了後も継続いたします。 -
7 https://docs.aws.amazon.com/ja_jp/AmazonRDS/latest/UserGuide/extended-support.html > With Amazon RDS Extended Support, you can
continue running your database on a major engine version past the RDS end of standard support date for an additional cost. -
8 https://docs.aws.amazon.com/ja_jp/AmazonRDS/latest/UserGuide/extended-support.html > With Amazon RDS Extended Support, you can
continue running your database on a major engine version past the RDS end of standard support date for an additional cost. -
10 今⽇話すこと 1. MySQLのサポート終了について 2. 対象サービス「minne」のDBについて 3. よくあるDBアップグレード戦略 4. RDS
B/Gデプロイの説明 5. RDS B/Gデプロイを試してみて分かったこと、分からなかったこと -
今回DBバージョンが上がったサービス 13 - ハンドメイドマーケットサービス - readもwriteも常時そこそこある - 新機能の開発が盛ん - スキーマ変更も頻繁にある
- INSTANT DDL (MySQL 8.0.12 ~)が使えると嬉しい - DBはRDS for MySQL - Primary - Replica minneについて \オフラインイベントやるよ/ -
よくあるDBアップグレード戦略 15 - ⽂字通り「その場で」DBエンジンをアップグレードする - pros - ⼿順が単純 - アップグレードに伴うリソースの追加使⽤はない
- cons - ダウンタイムが⻑く発⽣する インプレースアップグレード -
よくあるDBアップグレード戦略 16 - Replicaインスタンスを先にアップグレードしておき、そのReplicaインスタンスを Primaryに「昇格」する - pros - ダウンタイムが短めで済む -
cons - ⼿順が複雑 - DBの接続情報が変更される Replicaのプロモーション -
RDS B/Gデプロイ 18 - DBでBGデプロイができる - 本番環境と同期するステージング環境が作られる - ステージング環境でのreadの検証ができる -
ダウンタイム少なく切り替えができる - 公式ドキュメントによると通常1分以内 - 切り替え時に接続先情報を変更する必要がない - GUIポチポチで済むので楽ちん - 2022年12⽉に提供が開始された機能 RDSのB/Gデプロイについて -
実際にやってみて初めて気づいた挙動の紹介 36 - BGデプロイ識別⼦のステータスが「無効な設定」となる - その状態での切り替えはできない - それぞれのDBに接続はできる - 同じスナップショットから作ったインスタンスで、この現象が起きる場合と起きない場
合があった - 同じスナップショットから作ったインスタンスでのインプレースでのアップグレードはできた - インスタンスサイズは原因ではなさそう - パラメータグループは原因ではなさそう - 原因不明...... 「切り替え可能」にならないときがある -
実際にやってみて初めて気づいた挙動の紹介 38 - Replicaインスタンスのbinlog retention hoursを⼿動で変更していた MySQLの設定値に引き継がれないものがある mysql> call mysql.rds_set_configuration('binlog
retention hours', 72); Query OK, 0 rows affected (0.00 sec) mysql> call mysql.rds_show_configuration; +------------------------+-------+-----------------------------------------------------------------------------------------------------------+ | name | value | description | +------------------------+-------+-----------------------------------------------------------------------------------------------------------+ | binlog retention hours | 72 | binlog retention hours specifies the duration in hours before binary logs are automatically deleted. | | source delay | 0 | source delay specifies replication delay in seconds between current instance and its master. | | target delay | 0 | target delay specifies replication delay in seconds between current instance and its future read-replica. | +------------------------+-------+-----------------------------------------------------------------------------------------------------------+ 3 rows in set (0.01 sec) Query OK, 0 rows affected (0.01 sec) -
実際にやってみて初めて気づいた挙動の紹介 39 - Green環境のReplicaインスタンスではNULLになっていた...... MySQLの設定値に引き継がれないものがある mysql> call mysql.rds_show_configuration; +------------------------+-------+-----------------------------------------------------------------------------------------------------------+ |
name | value | description | +------------------------+-------+-----------------------------------------------------------------------------------------------------------+ | binlog retention hours | NULL | binlog retention hours specifies the duration in hours before binary logs are automatically deleted. | | source delay | 0 | source delay specifies replication delay in seconds between current instance and its master. | | target delay | 0 | target delay specifies replication delay in seconds between current instance and its future read-replica. | +------------------------+-------+-----------------------------------------------------------------------------------------------------------+ 3 rows in set (0.00 sec) Query OK, 0 rows affected (0.00 sec) -
実際にやってみて初めて気づいた挙動の紹介 - Debezium ServerによるCDC(Change Data Capture)を実施している - binlogを読んで変更内容をBigQueryへ送る - インスタンスが変わると読むbinlogも別になる
- 切り替え後もCDCを続けるならDebezium Server側での初期化処理が必要 「BlueとGreenとでインスタンスは別物」で引っかかった事例 45 Debezium ServerによるChange Data Captureの事例紹介 -
まとめ - ダウンタイムが少ない - コンソール上の操作で完結する - 接続情報に変更がない - ChatGPTに聞いても教えてくれない RDS
BGデプロイ、便利。だけどインターネット上に知⾒が少ないので苦労するね。 47 -
We're hiring! We're hiring! We're hiring! We're hiring! We're hiring!
We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring!We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring!We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring!We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring!We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring!We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring!We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring!We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring!We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring!We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring!We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! We're hiring! 48 おわり