DB パラメータグループを使用する
DB インスタンスでは DB パラメータグループが使用されます。次のセクションでは、DB インスタンスパラメータグループの設定と管理について説明します。
トピック
DB パラメータグループを作成する
新しい DB パラメータグループは、AWS Management Console、AWS CLI、または RDS API を使って作成できます。
DB パラメータグループ名には、次の制限事項が適用されます。
-
名前は、1~255 の英字、数字、ハイフンである必要があります。
デフォルトのパラメータグループ名には、
default.mysql8.0
のようなピリオドを含めることができます。ただし、カスタムパラメータグループ名にはピリオドを含めることはできません。 -
1 字目は文字である必要があります。
-
名前の最後にハイフンを使用したり、ハイフンを 2 つ続けて使用したりすることはできません。
DB パラメータグループを作成するには
-
AWS Management Console にサインインし、Amazon RDS コンソール (https://console.aws.amazon.com/rds/
) を開きます。 -
ナビゲーションペインで、[パラメータグループ] を選択します。
-
[Create parameter group] (パラメータグループの作成) を選択します。
[パラメータグループの作成] ウィンドウが表示されます。
-
[パラメータグループファミリー] リストで、DB パラメータグループファミリーを選択します。
-
[Type] リストで、[DB Parameter Group] を選択します。
-
[グループ名] ボックスに、新しい DB パラメータグループの名前を入力します。
-
[説明] ボックスに、新しい DB パラメータグループの説明を入力します。
-
[作成] を選択します。
DB パラメータグループを作成するには、AWS CLI の create-db-parameter-group
コマンドを使用します。以下の例では、MySQL バージョン 8.0 用に、mydbparametergroup という名前で、「My new parameter group」という説明の新しい DB パラメータグループを作成しています。
以下の必須パラメータを含めます。
-
--db-parameter-group-name
-
--db-parameter-group-family
-
--description
使用可能なすべてのパラメータグループファミリーを一覧表示するには、次のコマンドを使用します。
aws rds describe-db-engine-versions --query "DBEngineVersions[].DBParameterGroupFamily"
注記
出力は重複が含まれます。
例
Linux、macOS、Unix の場合:
aws rds create-db-parameter-group \ --db-parameter-group-name
mydbparametergroup
\ --db-parameter-group-familyaurora-mysql5.7
\ --description"My new parameter group"
Windows の場合:
aws rds create-db-parameter-group ^ --db-parameter-group-name
mydbparametergroup
^ --db-parameter-group-familyaurora-mysql5.7
^ --description"My new parameter group"
このコマンドでは、以下のような出力が生成されます。
DBPARAMETERGROUP mydbparametergroup aurora-mysql5.7 My new parameter group
DB パラメータグループを作成するには、RDS API の CreateDBParameterGroup
オペレーションを使用します。
以下の必須パラメータを含めます。
-
DBParameterGroupName
-
DBParameterGroupFamily
-
Description
DB パラメータグループを DB インスタンスに関連付ける
カスタマイズした設定を使用して、独自の DB パラメータグループを作成できます。AWS Management Console、AWS CLI、または RDS API を使用して、DB パラメータグループを DB インスタンスに関連付けることができます。DB インスタンスを作成または変更するときに、これを行うことができます。
DB パラメータグループの作成については、DB パラメータグループを作成する を参照してください。DB インスタンスの変更については、「DB クラスター内の DB インスタンスの変更」を参照してください。
注記
新しい DB パラメータグループを DB インスタンスに関連付ける場合、変更された静的パラメータと動的パラメータは、DB インスタンスが再起動された後にのみ適用されます。ただし、DB インスタンスに関連付けた後に DB パラメータグループの動的パラメータを変更すると、これらの変更は再起動せずに直ちに適用されます。
DB パラメータグループを DB インスタンスに関連付けるには
AWS Management Console にサインインし、Amazon RDS コンソール (https://console.aws.amazon.com/rds/
) を開きます。 -
ナビゲーションペインで、[データベース] を選択し、変更する DB インスタンスを選択します。
-
[Modify] (変更) を選択します。[Modify DB Instance] ページが表示されます。
-
DB パラメータグループの設定を変更します。
-
[Continue] を選択して、変更の概要を確認します。
-
(オプション) 変更をすぐに適用するには、[Apply immediately] (すぐに適用) を選択します。このオプションを選択すると、停止状態になる場合があります。
-
確認ページで、変更内容を確認します。正しい場合は、[Modify DB Instance (DB インスタンスを変更)] を選択して変更を保存します。
または、[戻る] を選択して変更を編集するか、[キャンセル] を選択して変更をキャンセルします。
DB パラメータグループを DB インスタンスに関連付けるには、以下のオプションを指定しながら AWS CLI の modify-db-instance
コマンドを使用します。
-
--db-instance-identifier
-
--db-parameter-group-name
次の例では、mydbpg
DB パラメータグループを database-1
DB インスタンスに関連付けます。--apply-immediately
を使用すると変更はすぐに適用されます。--no-apply-immediately
を使用して、次のメンテナンス時間中に変更を適用します。
例
Linux、macOS、Unix の場合:
aws rds modify-db-instance \ --db-instance-identifier
database-1
\ --db-parameter-group-namemydbpg
\--apply-immediately
Windows の場合:
aws rds modify-db-instance ^ --db-instance-identifier
database-1
^ --db-parameter-group-namemydbpg
^--apply-immediately
DB パラメータグループを DB インスタンスに関連付けるには、以下のパラメータを指定しながら RDS API の ModifyDBInstance
オペレーションを使用します。
-
DBInstanceName
-
DBParameterGroupName
DB パラメータグループのパラメータの変更
ユーザー定義の DB パラメータグループのパラメータ値は変更できますが、デフォルトの DB パラメータグループのパラメータ値を変更することはできません。ユーザー定義の DB パラメータグループのパラメータの変更は、その DB パラメータグループに関連付けられたすべての DB インスタンスに適用されます。
一部のパラメータへの変更は、再起動せずに直ちに DB インスタンスに適用されます。他のパラメータの変更は、DB インスタンスの再起動後にのみ適用されます。DB インスタンスに関連付けられている DB パラメータグループのステータスは、RDS コンソールの [設定] タブに表示されます。例えば、DB インスタンスがその関連付けられた DB パラメータグループに対する最新の変更を使用していないとします。その場合、RDS コンソールは、DB パラメータグループのステータスを [pending-reboot] (再起動の保留中) と表示します。パラメータの最新の変更を DB インスタンスに適用するには、DB インスタンスを手動で再起動します。

DB パラメータグループを変更するには
-
AWS Management Console にサインインし、Amazon RDS コンソール (https://console.aws.amazon.com/rds/
) を開きます。 -
ナビゲーションペインで、[パラメータグループ] を選択します。
-
リストで、変更するパラメータグループを選択します。
-
[Parameter group actions (パラメータグループのアクション)] で、[編集] を選択します。
-
変更するパラメータの値を変更します。ダイアログボックスの右上にある矢印キーを使用して、パラメータをスクロールできます。
デフォルトパラメータグループの値を変更することはできません。
-
[Save changes] (変更を保存) をクリックします。
DB パラメータグループを変更するには、次の必須オプションを指定して、AWS CLI の modify-db-parameter-group
コマンドを使用します。
-
--db-parameter-group-name
-
--parameters
以下の例では、mydbparametergroup という名前の DB パラメータグループの max_connections
と max_allowed_packet
の値を変更しています。
例
Linux、macOS、Unix の場合:
aws rds modify-db-parameter-group \ --db-parameter-group-name
mydbparametergroup
\ --parameters "ParameterName=max_connections
,ParameterValue=250
,ApplyMethod=immediate
" \ "ParameterName=max_allowed_packet
,ParameterValue=1024
,ApplyMethod=immediate
"
Windows の場合:
aws rds modify-db-parameter-group ^ --db-parameter-group-name
mydbparametergroup
^ --parameters "ParameterName=max_connections
,ParameterValue=250
,ApplyMethod=immediate
" ^ "ParameterName=max_allowed_packet
,ParameterValue=1024
,ApplyMethod=immediate
"
このコマンドでは、以下のような出力が生成されます。
DBPARAMETERGROUP mydbparametergroup
DB パラメータグループを変更するには、以下の必須パラメータを指定しながら RDS API の ModifyDBParameterGroup
オペレーションを使用します。
-
DBParameterGroupName
-
Parameters
DB パラメータグループのパラメータをデフォルト値にリセットします
顧客が作成した DB パラメータグループのパラメータ値をデフォルト値にリセットできます。ユーザー定義の DB パラメータグループのパラメータの変更は、その DB パラメータグループに関連付けられたすべての DB インスタンスに適用されます。
コンソールを使用すると、特定のパラメータをデフォルト値にリセットできます。ただし、DB パラメータグループのすべてのパラメータを一度にリセットするのは簡単ではありません。AWS CLI または RDS API を使用すると、特定のパラメータをデフォルト値にリセットできます。DB パラメータグループのすべてのパラメータを一度にリセットすることもできます。
一部のパラメータへの変更は、再起動せずに直ちに DB インスタンスに適用されます。他のパラメータの変更は、DB インスタンスの再起動後にのみ適用されます。DB インスタンスに関連付けられている DB パラメータグループのステータスは、RDS コンソールの [設定] タブに表示されます。例えば、DB インスタンスがその関連付けられた DB パラメータグループに対する最新の変更を使用していないとします。その場合、RDS コンソールは、DB パラメータグループのステータスを [pending-reboot] (再起動の保留中) と表示します。パラメータの最新の変更を DB インスタンスに適用するには、DB インスタンスを手動で再起動します。

注記
デフォルトの DB パラメータグループでは、パラメータは常にデフォルト値に設定されます。
DB パラメータグループのパラメータをデフォルト値にリセットするには
-
AWS Management Console にサインインし、Amazon RDS コンソール (https://console.aws.amazon.com/rds/
) を開きます。 -
ナビゲーションペインで、[パラメータグループ] を選択します。
-
リストからパラメータグループを選択します。
-
[Parameter group actions (パラメータグループのアクション)] で、[編集] を選択します。
-
デフォルト値にリセットするパラメータを選択します。ダイアログボックスの右上にある矢印キーを使用して、パラメータをスクロールできます。
デフォルトのパラメータグループの値をリセットすることはできません。
-
リセットを選択し、パラメータをリセットを選択して確定します。
DB パラメータグループの一部またはすべてのパラメータをリセットするには、AWS CLIreset-db-parameter-group
コマンドに必須オプション--db-parameter-group-name
を指定します。
DB パラメータグループのすべてのパラメータをリセットするには、--reset-all-parameters
オプションを指定します。特定のパラメータをリセットするには、--parameters
オプションを指定します。
次の例では、mydbparametergroupという名前の DB パラメータグループ内のすべてのパラメータをデフォルト値にリセットします。
例
Linux、macOS、Unix の場合:
aws rds reset-db-parameter-group \ --db-parameter-group-name
mydbparametergroup
\ --reset-all-parameters
Windows の場合:
aws rds reset-db-parameter-group ^ --db-parameter-group-name
mydbparametergroup
^ --reset-all-parameters
次の例では、mydbparametergroup という名前の DB パラメータグループのおよびmax_connections
オプションmax_allowed_packet
をデフォルト値にリセットします。
例
Linux、macOS、Unix の場合:
aws rds reset-db-parameter-group \ --db-parameter-group-name
mydbparametergroup
\ --parameters "ParameterName=max_connections
,ApplyMethod=immediate
" \ "ParameterName=max_allowed_packet
,ApplyMethod=immediate
"
Windows の場合:
aws rds reset-db-parameter-group ^ --db-parameter-group-name
mydbparametergroup
^ --parameters "ParameterName=max_connections
,ApplyMethod=immediate
" ^ "ParameterName=max_allowed_packet
,ApplyMethod=immediate
"
このコマンドでは、以下のような出力が生成されます。
DBParameterGroupName mydbparametergroup
DB パラメータグループ内のパラメータをデフォルト値にリセットするには、RDS API ResetDBParameterGroup
コマンドに必須パラメータ DBParameterGroupName
を指定します。
DB パラメータグループのすべてのパラメータをリセットするには、ResetAllParameters
パラメータをtrue
に設定します。特定のパラメータをリセットするには、Parameters
パラメータを指定します。
DB パラメータグループをコピーする
作成したカスタム DB パラメータグループをコピーできます。パラメータグループのコピーは便利なソリューションです。例としては、作成済みの DB パラメータグループがあり、そのほとんどのカスタムパラメータと値を、新しい DB パラメータグループに含める場合です。AWS Management Console を使用して、DB パラメータグループをコピーできます。AWS CLI copy-db-parameter-group コマンド、または RDS API CopyDBParameterGroup オペレーションも使用できます。
DB パラメータグループをコピーした後で、その DB パラメータグループをデフォルトのパラメータグループとして使用する最初の DB インスタンスを作成するまで、最低 5 分待ちます。これにより、パラメータグループを使用する前に、Amazon RDS はコピーアクションが完全に終了できます。これは、DB インスタンスのデフォルトのデータベースを作成する際に不可欠となるパラメータで特に重要です。例としては、character_set_database
パラメータで定義するデフォルトのデータベースの文字セットが挙げられます。DB パラメータグループが作成されたことを確認するには、Amazon RDS コンソールの [パラメータグループ
注記
デフォルトのパラメータグループをコピーすることはできません。ただし、デフォルトのパラメータグループに基づく新しいパラメータグループを作成できます。
DB パラメータグループを別の AWS アカウント または AWS リージョン にコピーすることはできません。
DB パラメータグループをコピーするには
-
AWS Management Console にサインインし、Amazon RDS コンソール (https://console.aws.amazon.com/rds/
) を開きます。 -
ナビゲーションペインで、[パラメータグループ] を選択します。
-
リストで、コピーするカスタムパラメータグループを選択します。
-
[Parameter group actions (パラメータグループのアクション)] で、[コピー] を選択します。
-
[新規の DB パラメータグループの識別子] に、新しいパラメータグループの名前を入力します。
-
[説明] に、新しいパラメータグループの説明を入力します。
-
[Copy (コピー)] を選択します。
DB パラメータグループをコピーするには、次の必須オプションを指定しながら AWS CLI の copy-db-parameter-group
コマンドを使用します。
-
--source-db-parameter-group-identifier
-
--target-db-parameter-group-identifier
-
--target-db-parameter-group-description
次の例は、DB パラメータグループ mygroup2
のコピーである mygroup1
という名前の新しい DB パラメータグループを作成します。
例
Linux、macOS、Unix の場合:
aws rds copy-db-parameter-group \ --source-db-parameter-group-identifier
mygroup1
\ --target-db-parameter-group-identifiermygroup2
\ --target-db-parameter-group-description"DB parameter group 2"
Windows の場合:
aws rds copy-db-parameter-group ^ --source-db-parameter-group-identifier
mygroup1
^ --target-db-parameter-group-identifiermygroup2
^ --target-db-parameter-group-description"DB parameter group 2"
DB パラメータグループをコピーするには、以下の必須パラメータを指定して、RDS API の CopyDBParameterGroup
オペレーションを使用します。
-
SourceDBParameterGroupIdentifier
-
TargetDBParameterGroupIdentifier
-
TargetDBParameterGroupDescription
DB パラメータグループを一覧表示する
AWS アカウント用に作成した DB パラメータグループを一覧表示できます。
注記
デフォルトのパラメータグループは、特定の DB エンジンとバージョンの DB インスタンスを作成するときに、デフォルトのパラメータテンプレートから自動的に作成されます。これらのデフォルトのパラメータグループには、優先されるパラメータ設定が含まれています。これを変更することはできません。カスタムパラメータグループを作成する場合、パラメータ設定を変更できます。
AWS アカウントのすべての DB パラメータグループを一覧表示するには
-
AWS Management Console にサインインし、Amazon RDS コンソール (https://console.aws.amazon.com/rds/
) を開きます。 -
ナビゲーションペインで、[パラメータグループ] を選択します。
DB パラメータグループがリストに表示されます。
AWS アカウントのすべての DB パラメータグループを一覧表示するには、AWS CLI の describe-db-parameter-groups
コマンドを使用します。
例
以下の例では、AWS アカウントに使用できるすべての DB パラメータグループを一覧表示しています。
aws rds describe-db-parameter-groups
このコマンドでは次のようなレスポンスが返されます。
DBPARAMETERGROUP default.mysql8.0 mysql8.0 Default parameter group for MySQL8.0 DBPARAMETERGROUP mydbparametergroup mysql8.0 My new parameter group
次の例は、mydbparamgroup1 パラメータグループを表しています。
Linux、macOS、Unix の場合:
aws rds describe-db-parameter-groups \ --db-parameter-group-name
mydbparamgroup1
Windows の場合:
aws rds describe-db-parameter-groups ^ --db-parameter-group-name
mydbparamgroup1
このコマンドでは次のようなレスポンスが返されます。
DBPARAMETERGROUP mydbparametergroup1 mysql8.0 My new parameter group
AWS アカウントのすべての DB パラメータグループを一覧表示するには、RDS API の DescribeDBParameterGroups
オペレーションを使用します。
DB パラメータグループのパラメータ値を表示する
DB パラメータグループのすべてのパラメータとそれらの値のリストを取得できます。
DB パラメータグループのパラメータ値を表示するには
-
AWS Management Console にサインインし、Amazon RDS コンソール (https://console.aws.amazon.com/rds/
) を開きます。 -
ナビゲーションペインで、[パラメータグループ] を選択します。
DB パラメータグループがリストに表示されます。
-
パラメータを一覧表示するパラメータグループの名前を選択します。
DB パラメータグループのパラメータ値を表示するには、以下の必須パラメータを指定して、AWS CLI の describe-db-parameters
コマンドを使用します。
--db-parameter-group-name
例
以下の例では、mydbparametergroup という名前の DB パラメータグループのパラメータとその値を一覧表示しています。
aws rds describe-db-parameters --db-parameter-group-name
mydbparametergroup
このコマンドでは次のようなレスポンスが返されます。
DBPARAMETER Parameter Name Parameter Value Source Data Type Apply Type Is Modifiable DBPARAMETER allow-suspicious-udfs engine-default boolean static false DBPARAMETER auto_increment_increment engine-default integer dynamic true DBPARAMETER auto_increment_offset engine-default integer dynamic true DBPARAMETER binlog_cache_size 32768 system integer dynamic true DBPARAMETER socket /tmp/mysql.sock system string static false
DB パラメータグループのパラメータ値を表示するには、以下の必須パラメータを指定して、RDS API の DescribeDBParameters
コマンドを使用します。
DBParameterGroupName