LoginSignup
1
1

More than 5 years have passed since last update.

aws cli で Aurora RDS パラメーターグループの設定値確認

Last updated at Posted at 2018-06-01

事前準備

  • jq インストールしておく(yum install jq, apt install jq)
  • aws configure で aws コマンドを使えるようにしておく 

aurora_rds.sh

#!/bin/sh


case $1 in

   # RDS インスタンス一覧
   instances)
   aws rds describe-db-instances | jq -r '.DBInstances[] | .DBInstanceIdentifier + " : " + .DBParameterGroups[].DBParameterGroupName'
   ;;

   # RDS クラスター一覧
   clusters)
   aws rds describe-db-clusters | jq -r '.DBClusters[] | .DBClusterIdentifier + " : " + .DBClusterParameterGroup'
   ;;

   # クラスター パラメーターグループ
   cluster_pg)
   aws rds describe-db-cluster-parameter-groups  | jq -r '.DBClusterParameterGroups[].DBClusterParameterGroupName'
   ;;

   # インスタンス パラメーターグループ
   instance_pg)
   aws rds describe-db-parameter-groups | jq -r '.DBParameterGroups[].DBParameterGroupName' 
   ;;

   # クラスターのパラメーターグループキー, バリュー
   desc_cpg)
   # describe-db-cluster-parameter-groups のパラメータグループを指定
   aws rds describe-db-cluster-parameters --db-cluster-parameter-group-name $2 | jq -r '.Parameters[] | select( .ParameterValue != null) | .ParameterName + " : " +   .ParameterValue'
   ;;

   # インスタンスのパラメーターグループキー, バリュー
   desc_ipg)
   # describe-db-parameter-groups のパラメータグループを指定
   aws rds describe-db-parameters --db-parameter-group-name $2 | jq -r '.Parameters[] | select( .ParameterValue != null) | .ParameterName + " : " +   .ParameterValue'
   ;;
   *)
   echo 
   echo "Usage: $0 [ instances | clusters | cluster_pg | instance_pg ]"
   echo "       $0 desc_cpg CLUSTER-PARAMETER-GROUP"
   echo "       $0 desc_ipg INSTANCE-PARAMETER-GROUP"
   echo
   ;;
esac

使い方

$ sh rds.sh 

Usage: rds.sh [ instances | clusters | cluster_pg | instance_pg ]
       rds.sh desc_cpg CLUSTER-PARAMETER-GROUP
       rds.sh desc_ipg INSTANCE-PARAMETER-GROUP
クラスター一覧
$ sh  aurora_rds.sh  clusters
rds-cluster-aaa : rds-cluster-aaa-rdsdbclusterparametergroup-111111111
rds-cluster-bbb : rds-cluster-bbb-rdsdbclusterparametergroup-222222222
クラスターパラメーターグループを指定してパラメーター確認
$ sh aurora_rds.sh desc_cpg rds-cluster-aaa-rdsdbclusterparametergroup-111111111
binlog_format : OFF
character_set_client : utf8mb4
character_set_connection : utf8mb4
インスタンス一覧
$ sh aurora_rds.sh  instances 
xxxxxxxxxyyyyy  : aaaaabbb-dbparametergroup-xxxxxx
zzzzzzzzllllll  : aaaaabbb-dbparametergroup-yyyyyy
インスタンスパラメーターグループを指定してパラメーター確認
$ sh aurora_rds.sh  desc_ipg aaaaabbb-dbparametergroup-xxxxxx
aurora_lab_mode : 0
basedir : /rdsdbbin/oscar
binlog_cache_size : 32768

差分確認してみたりとか

$ sh aurora_rds.sh  instances | cut -d: -f2 > instance_parametergroups 
$ mkdir instances
$ for x in `cat instance_parametergroups` ; do sh aurora_rds.sh desc_ipg $x > instances/$x ;done
$ cd instances
$ for x in * ; do echo "== $x ==" ; diff rds-33-dbparametergroup-jfejifjeijejf  $x;done 
== xxxx == 
== bbbb ==
12a13
> innodb_print_all_deadlocks : 1
20c21
< long_query_time : 0.5
---
> long_query_time : 0.1
22c23,24
1
1
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
1
1