RDSのインスタンス作成、タイプ変更等の時間を調べた
イントロ
よくわかってなかったので自分で実験。
会社でアップグレードする機会があったので、その予行練習の記録をまとめたものです。
準備
0 の状態から最小限の構成で確認したかったので、以下のようになった
- 管理画面から RDS を作成
- 管理画面から ec2 を作成(ubuntu)
- デフォルトの Security Group を attach する(RDS の Security Group がデフォルトの Security Group を許可する設定になっていたため)
- 立ち上げた ec2 に
mysql-client
を install するsudo apt-get update && sudo apt-get install mysql-client
- 管理画面から RDS を変更
- この結果を観察
インスタンスの作成
Time(utc+9) | Event |
---|---|
Jul 9 9:37 AM | Finished applying modification to convert to a Multi-AZ DB Instance |
Jul 9 9:28 AM | Applying modification to convert to a Multi-AZ DB Instance |
Jul 9 9:28 AM | DB instance created |
Jul 9 9:28 AM | DB instance restarted |
- クリックしてからイベント表示まで、3 ~ 5 分ほどかかる。
- URL が表示されていれば、Status が
modifying
になっていても、接続は可能Applying modification to convert to a Multi-AZ DB Instance
のタイミングでは、もう URL は発行されている
- Multi AZ 構成だと、インスタンス作成に少なくとも 10 分程度かかる模様。
m3.xlarge
,m3.large
,t2.small
で検証したところ、インスタンス作成時間にインスタンスタイプは関係ないっぽい- 作成時間にほとんど差が無かった
- 検証に偏りがあるかもしれない可能性は若干ある
インスタンスタイプの変更
AWS RDSのインスタンスタイプ変更やメンテ再起動にかかる時間は約1分〜5分 - Qiita
を拝借。sleep の時間を 5 秒に変えている
ubuntu@ip-172-31-25-166:~$ while true; do > mysqladmin ping -h test.celqgbwlf3q4.ap-northeast-1.rds.amazonaws.com -u root -ppassword > date > sleep 5 > echo "---------" > done mysqladmin: [Warning] Using a password on the command line interface can be insecure. mysqld is alive Sun Jul 9 01:30:17 UTC 2017 --------- ... --------- mysqladmin: [Warning] Using a password on the command line interface can be insecure. mysqld is alive Sun Jul 9 01:38:44 UTC 2017 --------- mysqladmin: [Warning] Using a password on the command line interface can be insecure. mysqladmin: connect to server at 'test.celqgbwlf3q4.ap-northeast-1.rds.amazonaws.com' failed error: 'Can't connect to MySQL server on 'test.celqgbwlf3q4.ap-northeast-1.rds.amazonaws.com' (111)' Check that mysqld is running on test.celqgbwlf3q4.ap-northeast-1.rds.amazonaws.com and that the port is 3306. You can check this by doing 'telnet test.celqgbwlf3q4.ap-northeast-1.rds.amazonaws.com 3306' Sun Jul 9 01:38:49 UTC 2017 --------- mysqladmin: [Warning] Using a password on the command line interface can be insecure. mysqladmin: connect to server at 'test.celqgbwlf3q4.ap-northeast-1.rds.amazonaws.com' failed error: 'Can't connect to MySQL server on 'test.celqgbwlf3q4.ap-northeast-1.rds.amazonaws.com' (110)' Check that mysqld is running on test.celqgbwlf3q4.ap-northeast-1.rds.amazonaws.com and that the port is 3306. You can check this by doing 'telnet test.celqgbwlf3q4.ap-northeast-1.rds.amazonaws.com 3306' Sun Jul 9 01:41:01 UTC 2017 # <= 5 秒おきに ping を飛ばすが、これだけ刺さってしまった --------- mysqladmin: [Warning] Using a password on the command line interface can be insecure. mysqld is alive Sun Jul 9 01:41:06 UTC 2017 ...
Time(utc+9) | Event |
---|---|
Jul 9 11:06(?) AM | — インスタンスの status が modifying -> available になる — |
Jul 9 11:04 AM | Finished applying modification to allocated storage |
Jul 9 10:47 AM | Applying modification to allocated storage |
Jul 9 10:47 AM | Finished applying modification to DB instance class |
Jul 9 10:41 AM | — ping が通るようになる — |
Jul 9 10:40 AM | Multi-AZ instance failover completed |
Jul 9 10:39 AM | DB instance restarted |
Jul 9 10:39 AM | Multi-AZ instance failover started |
Jul 9 10:38 AM | — ping が通らなくなる — |
Jul 9 10:31 AM | Applying modification to database instance class |
Jul 9 10:30 AM | Performance Insights has been disabled |
Jul 9 10:30 AM | Monitoring Interval changed to 60 |
ストレージタイプの変更
General Purpose(SSD) -> Provisioned IOPS(SSD) に変更する。
この変更だとダウンタイムは発生しない。
mysqladmin ping
も変更の間、全部通ったことを確認した。
なお「Magnetic からの変更」「Magnetic への変更」はダウンタイムが発生する模様。
ストレージタイプの使用 - Amazon Relational Database Service
Time(utc+9) | Event |
---|---|
Jul 15 6:55 PM | Finished applying modification to allocated storage |
Jul 15 6:45 PM | Applying modification to allocated storage |
Jul 15 6:45 PM | Finished preparing for modification of storage |
Jul 15 6:44 PM | Performance Insights has been disabled |
Jul 15 6:44 PM | Monitoring Interval changed to 60 |
- ストレージの容量に比例して、変更の時間が長くなる可能性はありそう
- リードレプリカを作成している場合は以下の点を考慮する必要がある
- マスターと容量は合わせる必要がある
- マスターが 100G ならば、レプリカは 100G 以上でないといけない
- マスターとストレージタイプを合わせる必要は無い
- マスターが PIOPS で、レプリカが Magnetic は 可能
- Amazon RDS のストレージ - Amazon Relational Database Service
- マスターと容量は合わせる必要がある
mysql のバージョンアップ
5.6.35
-> 5.7.17
にしてみた。ダウンタイムが発生。
どうやらテーブルの型変換が強制的に行われるので、そのようなテーブルがあると結果が大きく変わりそう
MySQL DB エンジンのアップグレード - Amazon Relational Database Service
--------- mysqladmin: [Warning] Using a password on the command line interface can be insecure. mysqld is alive Sat Jul 15 10:10:21 UTC 2017 --------- mysqladmin: [Warning] Using a password on the command line interface can be insecure. mysqladmin: connect to server at 'test.celqgbwlf3q4.ap-northeast-1.rds.amazonaws.com' failed error: 'Can't connect to MySQL server on 'test.celqgbwlf3q4.ap-northeast-1.rds.amazonaws.com' (111)' Check that mysqld is running on test.celqgbwlf3q4.ap-northeast-1.rds.amazonaws.com and that the port is 3306. You can check this by doing 'telnet test.celqgbwlf3q4.ap-northeast-1.rds.amazonaws.com 3306' Sat Jul 15 10:10:26 UTC 2017 ... mysqladmin: [Warning] Using a password on the command line interface can be insecure. mysqladmin: connect to server at 'test.celqgbwlf3q4.ap-northeast-1.rds.amazonaws.com' failed error: 'Can't connect to MySQL server on 'test.celqgbwlf3q4.ap-northeast-1.rds.amazonaws.com' (111)' Check that mysqld is running on test.celqgbwlf3q4.ap-northeast-1.rds.amazonaws.com and that the port is 3306. You can check this by doing 'telnet test.celqgbwlf3q4.ap-northeast-1.rds.amazonaws.com 3306' Sat Jul 15 10:13:43 UTC 2017 --------- mysqladmin: [Warning] Using a password on the command line interface can be insecure. mysqld is alive Sat Jul 15 10:13:48 UTC 2017 ---------
Time(utc+9) | Event |
---|---|
Jul 15 7:19 PM | Finished DB Instance backup |
Jul 15 7:16 PM | Backing up DB instance |
Jul 15 7:15 PM | Database instance patched |
Jul 15 7:15 PM | Finished DB Instance backup |
Jul 15 7:15 PM | Updated to use DBParameterGroup default.mysql5.7 |
Jul 15 7:13 PM | DB instance restarted |
Jul 15 7:13 PM | – ping が通るようになる– |
Jul 15 7:12 PM | DB instance shutdown |
Jul 15 7:10 PM | – ping が通らなくなる– |
Jul 15 7:10 PM | Backing up DB instance |
Jul 15 7:10 PM | DB instance shutdown |
Jul 15 7:05 PM | Performance Insights has been disabled |
Jul 15 7:05 PM | Monitoring Interval changed to 60 |
注意事項
- snapshot 作成中は instance を変更できない
- snapshot の作成時間は、自動バックアップのイベントを見てれば大体予想がつく
まとめ
- 自動バックアップの時間帯に注意
- スナップショット作成中はインスタンスの変更ができない
- メンテナンス時間をとる場合は、作業が後ろ倒しになってしまうので気をつける
- インスタンスタイプ変更によるダウンタイムは 3 ~ 5 分程度
- Multi-AZ のフェイルオーバーのタイミングでダウンタイムが発生する
- この時間は DB にアクセス出来ないため、メンテナンス時間を設けることを推奨
- 復旧後、管理画面上は
modifying
になっていたものの、接続は可能- インスタンスタイプ変更から、
available
までの時間(= 全部完了の時間)は 約 35 分
- インスタンスタイプ変更から、
- mysql のバージョンアップによるダウンタイムは 3 分程度
- リードレプリカの設定をしている場合、storage の設定に気をつける
- マスターのアップグレードをするために、リードレプリカのアップグレードが必要になる場合がある
- 検証は行ったけど、実際のデータが投入されてないと、実際の作業時間の見積もりは難しい
- 変更前に手動スナップショットは作成しておくと、万が一の事があっても安心
- 無いとは思うが、いきなりインスタンスが消されても、手動スナップショットは残るため
参考
【AWS】RDSのインスタンスタイプ変更にかかる時間を調べてみた | Developers.IO AWS RDSのインスタンスタイプ変更やメンテ再起動にかかる時間は約1分〜5分 - Qiita