このセクションでは、フェイルオーバーを行い、その挙動を確認します。
オプションのページでも確認していますが、改めて動きを確認してみます。
そこで、readerノード を writerノードへ 昇格 させて、別の writerノード を用意するのが Auroraクラスターにおける フェイルオーバー です。
新規にノードを起動する場合に比べ復旧が早く、writer がいない場合はAuroraでは自動的にフェイルオーバー行われます。
また、Aurora では 最大15ノード まで reader を追加できるため、様々なAZ、インスタンスタイプで用意しておくことで耐障害性を高めることができます。
では、実際に手順を行います。
---- writer ----
+----+---------------------+-------+
| id | ts | value |
+----+---------------------+-------+
| 1 | 2020-xx-yy 12:27:19 | 97930 |
+----+---------------------+-------+
---- reader ----
+----+---------------------+-------+
| id | ts | value |
+----+---------------------+-------+
| 1 | 2020-xx-yy 12:27:20 | 97930 |
+----+---------------------+-------+
---- writer ----
+----+---------------------+-------+
| id | ts | value |
+----+---------------------+-------+
| 1 | 2020-xx-yy 12:27:20 | 97930 |
+----+---------------------+-------+
---- reader ----
ERROR 2003 (HY000): Can't connect to MySQL server on 'aurora-user1-cluster.cluster-ro-hogehoge.ap-northeast-1.rds.amazonaws.com' (111)
---- writer ----
+----+---------------------+-------+
| id | ts | value |
+----+---------------------+-------+
| 1 | 2020-xx-yy 12:27:21 | 97930 |
+----+---------------------+-------+
---- reader ----
+----+---------------------+-------+
| id | ts | value |
+----+---------------------+-------+
| 1 | 2020-xx-yy 12:27:22 | 97930 |
+----+---------------------+-------+
---- writer ----
+----+---------------------+-------+
| id | ts | value |
+----+---------------------+-------+
| 1 | 2020-xx-yy 12:27:22 | 97930 |
+----+---------------------+-------+
reader の設定が完了したので、フェイルオーバーを実行し、この readerノード を writer に変更します。 reader のDBを選択し、「アクション」から「フェイルオーバー」をクリックし、実行します。
---- reader ----
+----+---------------------+-------+
| id | ts | value |
+----+---------------------+-------+
| 1 | 2020-xx-yy 12:46:46 | 97930 |
+----+---------------------+-------+
---- writer ----
+----+---------------------+-------+
| id | ts | value |
+----+---------------------+-------+
| 1 | 2020-xx-yy 12:46:46 | 97930 |
+----+---------------------+-------+
---- reader ----
ERROR 2003 (HY000): Can't connect to MySQL server on 'aurora-user1-cluster.cluster-ro-hogehoge.ap-northeast-1.rds.amazonaws.com' (111)
---- writer ----
+----+---------------------+-------+
| id | ts | value |
+----+---------------------+-------+
| 1 | 2020-xx-yy 12:46:47 | 97930 |
+----+---------------------+-------+
---- reader ----
ERROR 2003 (HY000): Can't connect to MySQL server on 'aurora-user1-cluster.cluster-ro-hogehoge.ap-northeast-1.rds.amazonaws.com' (111)
---- writer ----
ERROR 2003 (HY000): Can't connect to MySQL server on 'aurora-user1-cluster.cluster-hogehoge.ap-northeast-1.rds.amazonaws.com' (111)
ERROR 2003 (HY000): Can't connect to MySQL server on 'aurora-user1-cluster.cluster-hogehoge.ap-northeast-1.rds.amazonaws.com' (111)
---- reader ----
ERROR 2003 (HY000): Can't connect to MySQL server on 'aurora-user1-cluster.cluster-ro-hogehoge.ap-northeast-1.rds.amazonaws.com' (111)
---- writer ----
ERROR 2003 (HY000): Can't connect to MySQL server on 'aurora-user1-cluster.cluster-hogehoge.ap-northeast-1.rds.amazonaws.com' (111)
ERROR 2003 (HY000): Can't connect to MySQL server on 'aurora-user1-cluster.cluster-hogehoge.ap-northeast-1.rds.amazonaws.com' (111)
---- reader ----
ERROR 2003 (HY000): Can't connect to MySQL server on 'aurora-user1-cluster.cluster-ro-hogehoge.ap-northeast-1.rds.amazonaws.com' (111)
---- writer ----
ERROR 2003 (HY000): Can't connect to MySQL server on 'aurora-user1-cluster.cluster-hogehoge.ap-northeast-1.rds.amazonaws.com' (111)
ERROR 2003 (HY000): Can't connect to MySQL server on 'aurora-user1-cluster.cluster-hogehoge.ap-northeast-1.rds.amazonaws.com' (111)
---- reader ----
+----+---------------------+-------+
| id | ts | value |
+----+---------------------+-------+
| 1 | 2020-xx-yy 12:46:48 | 97930 |
+----+---------------------+-------+
---- writer ----
+----+---------------------+-------+
| id | ts | value |
+----+---------------------+-------+
| 1 | 2020-xx-yy 12:46:48 | 97930 |
+----+---------------------+-------+
ERROR 1290 (HY000) at line 1: The MySQL server is running with the --read-only option so it cannot execute this statement
---- reader ----
+----+---------------------+-------+
| id | ts | value |
+----+---------------------+-------+
| 1 | 2020-xx-yy 12:46:48 | 97930 |
+----+---------------------+-------+
---- writer ----
+----+---------------------+-------+
| id | ts | value |
+----+---------------------+-------+
| 1 | 2020-xx-yy 12:46:48 | 97930 |
+----+---------------------+-------+
ERROR 1290 (HY000) at line 1: The MySQL server is running with the --read-only option so it cannot execute this statement
---- reader ----
+----+---------------------+-------+
| id | ts | value |
+----+---------------------+-------+
| 1 | 2020-xx-yy 12:46:48 | 97930 |
+----+---------------------+-------+
---- writer ----
+----+---------------------+-------+
| id | ts | value |
+----+---------------------+-------+
| 1 | 2020-xx-yy 12:46:48 | 97930 |
+----+---------------------+-------+
ERROR 1290 (HY000) at line 1: The MySQL server is running with the --read-only option so it cannot execute this statement
---- reader ----
+----+---------------------+-------+
| id | ts | value |
+----+---------------------+-------+
| 1 | 2020-xx-yy 12:46:48 | 97930 |
+----+---------------------+-------+
---- writer ----
+----+---------------------+-------+
| id | ts | value |
+----+---------------------+-------+
| 1 | 2020-xx-yy 12:46:48 | 97930 |
+----+---------------------+-------+
ERROR 1290 (HY000) at line 1: The MySQL server is running with the --read-only option so it cannot execute this statement
---- reader ----
+----+---------------------+-------+
| id | ts | value |
+----+---------------------+-------+
| 1 | 2020-xx-yy 12:46:48 | 97930 |
+----+---------------------+-------+
---- writer ----
+----+---------------------+-------+
| id | ts | value |
+----+---------------------+-------+
| 1 | 2020-xx-yy 12:46:48 | 97930 |
+----+---------------------+-------+
ERROR 1290 (HY000) at line 1: The MySQL server is running with the --read-only option so it cannot execute this statement
---- reader ----
+----+---------------------+-------+
| id | ts | value |
+----+---------------------+-------+
| 1 | 2020-xx-yy 12:46:48 | 97930 |
+----+---------------------+-------+
---- writer ----
+----+---------------------+-------+
| id | ts | value |
+----+---------------------+-------+
| 1 | 2020-xx-yy 12:46:48 | 97930 |
+----+---------------------+-------+
ERROR 1290 (HY000) at line 1: The MySQL server is running with the --read-only option so it cannot execute this statement
---- reader ----
+----+---------------------+-------+
| id | ts | value |
+----+---------------------+-------+
| 1 | 2020-xx-yy 12:46:48 | 97930 |
+----+---------------------+-------+
---- writer ----
+----+---------------------+-------+
| id | ts | value |
+----+---------------------+-------+
| 1 | 2020-xx-yy 12:46:48 | 97930 |
+----+---------------------+-------+
---- reader ----
+----+---------------------+-------+
| id | ts | value |
+----+---------------------+-------+
| 1 | 2020-xx-yy 12:46:59 | 97930 |
+----+---------------------+-------+
--read-only
がまだ適用されており、書き込みが行えないためです。