パラメーターグループ
作る
aws rds create-db-cluster-parameter-group \
--db-cluster-parameter-group-name hoge-canvas-postgresql10 \
--db-parameter-group-family aurora-postgresql10 \
--description "for wal_level must be set to logical"参考 aws rds create-db-cluster-parameter-group help
編集
aws rds modify-db-cluster-parameter-group \
--db-cluster-parameter-group-name hoge-canvas-postgresql10 \
--parameters "ParameterName=rds.logical_replication,ParameterValue=1,ApplyMethod=pending-reboot"設定するパラメーターによっては即時反映 ApplyMethod=immediate が使えず
An error occurred (InvalidParameterCombination) when calling the ModifyDBClusterParameterGroup operation: cannot use immediate apply method for static parameterというエラーが出る。この場合、 ApplyMethod=pending-reboot を使う必要がある。
staticかどうか?はWebUIの『タイプの適用』の箇所を見るとわかる。
反映
aws rds modify-db-cluster \
--apply-immediately \
--db-cluster-identifier hoge \
--db-cluster-parameter-group-name hoge-canvas-postgresql10パラメータグループ作成
- パラメータグループ名: test-aurora
- 説明: utf8mb4
- ファミリー: aurora5.6
を指定して、とりあえず設定自体を作る
$ aws rds create-db-parameter-group \
--db-parameter-group-name test-aurora \
--description utf8mb4 \
--db-parameter-group-family aurora5.6 \構築
aws rds create-db-cluster \
--engine aurora-postgresql \
--engine-mode serverless \
--engine-version 10.12 \
--copy-tags-to-snapshot \
--enable-http-endpoint \
--db-subnet-group-name prod \
--vpc-security-group-ids sg-1111111111111111 \
--db-cluster-identifier sample-cluster \
--master-username postgres \
--master-user-password himituno既存のパラメータグループから情報をコピーする
aws rds describe-db-parameters —db-parameter-group-name test-aurora > rds-test-aurora.json
既存パラメータからユーザ修正分を抜き出す
cat rds-test-aurora.json | jq ‘{Parameters:[ (.Parameters[]|select(.Source == “user”) * {“ApplyMethod”:“immediate”})]}’ > rds-test-aurora-change .json
modifyする
aws rds modify-db-parameter-group --db-parameter-group-name test-aurora --cli-input-json file://./rds-test-aurora-change.json
{
"DBParameterGroupName": "test-aurora"
}CLIからリードレプリカ追加
ここ の『WS CLI を使用して DB クラスターに Aurora レプリカを作成するには』から
aws rds create-db-instance \
--db-instance-identifier test-replica \
--region ap-northeast-1 \
--db-cluster-identifier testcluster \
--engine aurora \
--db-instance-class db.t2.small \
--availability-zone ap-northeast-1aクラスター情報の取得
devというクラスター名の情報を取得
aws rds describe-db-clusters | jq '.DBClusters[] | select(.DBClusterIdentifier == "dev")'DBインスタンスの詳細情報取得
aws rds describe-db-instances
--db-instance-identifier arn:aws:rds:ap-northeast-1:1111111111111111:db:test-replicaパラメータグループの設定
aws rds modify-db-instance
--db-instance-identifier test-replica
--db-parameter-group-name test-auroraインスタンス再起動
aws rds reboot-db-instance --db-instance-identifier test-replica