{RDS}Multi-AZ deployments for high availability

https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.MultiAZ.html
https://dev.classmethod.jp/articles/rds-multi-az-db-cluster-ga/


Multi-AZ DB Cluster は Provisioned IOPS ストレージ(io1)のみサポートされます。
Multi-AZ DB Cluster は全て DB クラスタレベルで行われるため、DB インスタンスレベルで変更できません。

 

前提: 米国東部 (バージニア北部)で作業

export AWS_DEFAULT_REGION=us-east-1


-- 1. コマンド等のインストール

-- 1.1 aws cli version 2 インストール

curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install

aws --version


-- 1.2 MySQL 8クライアント インストール

sudo yum -y remove mariadb-libs

sudo yum -y localinstall https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm

sudo yum-config-manager --disable mysql57-community
sudo yum-config-manager --enable mysql80-community

sudo yum info mysql-community-client

sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022

sudo yum -y install mysql-community-client

mysql --version


--1.3 PostgreSQL 13クライアント インストール

amazon-linux-extras list | grep postgresql
sudo amazon-linux-extras install postgresql13 -y

psql --version


-- 2. DBクラスター作成

aws rds create-db-cluster \
--db-cluster-identifier cluster01 \
--engine mysql \
--engine-version 8.0.28 \
--master-username root \
--master-user-password 'password' \
--port 3306 \
--backup-retention-period 1  \
--allocated-storage 100 \
--storage-type io1 \
--iops 1000 \
--db-cluster-instance-class db.m6gd.large \
--no-auto-minor-version-upgrade \
--no-deletion-protection \
--no-enable-performance-insights \
--no-publicly-accessible


aws rds create-db-cluster \
--db-cluster-identifier cluster02 \
--engine postgres \
--engine-version 13.4 \
--master-username postgres \
--master-user-password 'password' \
--port 5432 \
--backup-retention-period 1  \
--allocated-storage 100 \
--storage-type io1 \
--iops 1000 \
--db-cluster-instance-class db.m6gd.large \
--no-auto-minor-version-upgrade \
--no-deletion-protection \
--no-enable-performance-insights \
--no-publicly-accessible

 

aws rds describe-db-clusters
aws rds describe-db-instances

 


-- 3. 接続確認

mysql -h cluster01.cluster-xxxxxxxxxxxx.us-east-1.rds.amazonaws.com -P 3306 -u root -p
mysql -h cluster01.cluster-ro-xxxxxxxxxxxx.us-east-1.rds.amazonaws.com -P 3306 -u root -p


psql -h cluster02.cluster-xxxxxxxxxxxx.us-east-1.rds.amazonaws.com -p 5432 -U postgres
psql -h cluster02.cluster-ro-xxxxxxxxxxxx.us-east-1.rds.amazonaws.com -p 5432 -U postgres


PostgreSQLでライターインスタンスが利用可能、クラスターがバックアップ中の時にcreate databaseを実行するとハング状態となる

インスタンスは固定で、追加、削除はできない模様

 

-- 4. クリーンアップ

-- クラスター削除

aws rds describe-db-clusters
aws rds describe-db-instances

aws rds delete-db-cluster --db-cluster-identifier cluster01 --skip-final-snapshot 

aws rds delete-db-cluster --db-cluster-identifier cluster02 --skip-final-snapshot