8
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AWS RDSのBackup/MaintenanceWindowを一括変更する

Last updated at Posted at 2014-10-17

またまた脆弱性で、来週の対応が忙しくなりそうですね。

MySQL 5.5 and 5.6 Security Advisory
http://aws.amazon.com/jp/security/security-bulletins/mysql-5-5-and-5-6-security-advisory/

要するに
・MySQL5.5系 → 5.5.40
・MySQL5.6系 → 5.6.21
上記アップグレードを手動で行わない場合は、
2014/10/20 PM 12:00(PDT) ~ 2014/10/27 PM 11:59(PDT)の間に設定している
Maintenance Windowの時間内にUpgradeが発生する。
AutoMinorVersionUpgradeをNoにしていても今回は対象なので注意してね。
ということだそうです。

追記(2014/10/25)

We will upgrade all MySQL 5.6 instances that are on 5.6.19 or earlier to 5.6.19a in the customer defined maintenance window between 28 Oct 2014 19:00 UTC and 04 Nov 2014 18:59 UTC.

5.6系のアップグレードは**10/28 19:00 ~ 11/4 18:59(UTC)のようですね。
JSTだと
10/29(水) 4:00 ~ 11/5(水) 3:59(JST)**です。

追記(2014/10/22 )

2014年10月21日 18:45 JST 更新
MySQL 5.6の新バージョンへの自動アップグレードに関しては現在一旦延期となっております。ご迷惑おかけいたしますが、新規スケジュールに関しては続報をお待ちください

なのでMySQL5.6系はAutoMinorVersionUpgradeをNoにしていれば、MaintenanceWindowの時間にUpdateはかかりません。
期間が発表されるのを待機。

追記

JSTだとJST(PDT+16)なので対象時間は10/21(火)AM 4:00 ~ 10/28(火)AM 3:59
その為対象となるメンテナンスウィンドウの時間はUTC表記でMon:19:00~になります

英語(最新):https://forums.aws.amazon.com/ann.jspa?annID=2687
日本語:https://forums.aws.amazon.com/ann.jspa?annID=2669

Backup/MaintenanceWindowを一括変更する

とりあえずMaintenanceWindowを把握しておき、いつの間にかUpgradeが走ってるということがないようにしておきたい。
時間帯が被らないようにしなくてはいけないので両Window変更できるようにしておく。

実行前に下記パラメーターを必要であれば編集する。

ACCOUNT="--profileで指定するアカウント名"

BACKUP_TIME="17:00-17:30"
	Format: hh24:mi-hh24:mi

MENTE_TIME="Thu:18:00-Thu:18:30"
	Format: ddd:hh24:mi-ddd:hh24:mi
	Valid Days: Mon | Tue | Wed | Thu | Fri | Sat | Sun

※ 両Windowの注意点として設定時間はUTC、30分のレンジで設定する

set_memtewindow.sh
# !/bin/sh

ACCOUNT="default"
BACKUP_TIME="17:00-17:30"
MENTE_TIME="Thu:18:00-Thu:18:30"

echo "ACCOUNT: ${ACCOUNT}"
echo "BACKUP_TIME: ${BACKUP_TIME}"
echo "MENTE_TIME : ${MENTE_TIME}"
echo "============================================="

RDS_LIST=`aws rds describe-db-instances --profile ${ACCOUNT} \
    |jq -r '.DBInstances[] | {"DBInstanceIdentifier"} | .[]'`

for RDS in ${RDS_LIST}
do
    echo "RDS : ${RDS}"
    echo "============================================="
    echo "before : "
    aws rds describe-db-instances --profile ${ACCOUNT} \
        --db-instance-identifier ${RDS} \
        |jq -r '.DBInstances[] | {"PreferredMaintenanceWindow","PreferredBackupWindow"} | .[]'

    RESULT=`aws rds modify-db-instance --profile ${ACCOUNT} \
                --db-instance-identifier ${RDS} \
                --preferred-backup-window ${BACKUP_TIME} \
                --preferred-maintenance-window ${MENTE_TIME} \
                --apply-immediately`

    echo "after : "
    echo ${RESULT} |jq '{"DBInstance"}' | jq -r .'[] |{"PreferredMaintenanceWindow","PreferredBackupWindow"} | .[]'
    echo "============================================="
done

※ --apply-immediately追加。(2014/10/22)
  Backup/MaintenanceWindowの変更には必要ないはずですが、念の為。
 (BackupWindowは変更時--apply-immediately無しで変更された事を確認。
  MaintenanceWindowも表示上変更されていたので、変更されているはず。)

実行結果

$ sh set_memtewindow.sh
ACCOUNT: default
BACKUP_TIME: 17:00-17:30
MENTE_TIME : Thu:18:00-Thu:18:30
=============================================
RDS : test-db
=============================================
before :
16:00-16:30
thu:18:00-thu:18:30
after :
17:00-17:30
thu:18:00-thu:18:30
=============================================

確認用スクリプト

show_rds_parametors.sh
# !/bin/sh

ACCOUNT="default"
REGION="ap-northeast-1"

echo "ACCOUNT: ${ACCOUNT}"

echo "============================================="

RDS_LIST=`aws rds describe-db-instances \
    --profile ${ACCOUNT} \
    --region ${REGION} \
    |jq -r '.DBInstances[] | {"DBInstanceIdentifier"} | .[]'`

for RDS in ${RDS_LIST}
do
    echo "RDS : ${RDS}"
    echo "============================================="
    aws rds describe-db-instances --profile ${ACCOUNT} \
        --region ${REGION} \
        --db-instance-identifier ${RDS} \
        |jq -r '.DBInstances[] | {"PreferredMaintenanceWindow","PreferredBackupWindow","BackupRetentionPeriod","AutoMinorVersionUpgrade","EngineVersion", "VpcSecurityGroups"} '
    echo "============================================="
done

実行結果

$ sh show_rds_parametors.sh                                                                                                                                                                                                                                   (git)-[master]
ACCOUNT: default
BACKUP_TIME: 18:00-18:30
MENTE_TIME : Thu:19:00-Thu:19:30
=============================================
RDS : test-db
=============================================
{
  "VpcSecurityGroups": [
    {
      "VpcSecurityGroupId": "sg-123456",
      "Status": "active"
    }
  ],
  "EngineVersion": "5.6.13",
  "AutoMinorVersionUpgrade": false,
  "BackupRetentionPeriod": 7,
  "PreferredBackupWindow": "18:00-18:30",
  "PreferredMaintenanceWindow": "thu:19:00-thu:19:30"
}
=============================================
8
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?