

# DB インスタンスクラスの CPU コア数と CPU コアあたりのスレッド数の設定
<a name="SQLServer.Concepts.General.OptimizeCPU.Enabling"></a>

次のオペレーションを実行するときに、DB インスタンスクラスの CPU コア数とコアあたりのスレッド数を設定できます。
+ [Amazon RDS DB インスタンスの作成](USER_CreateDBInstance.md)
+ [Amazon RDS DB インスタンスを変更する](Overview.DBInstance.Modifying.md)
+ [DB インスタンスへの復元](USER_RestoreFromSnapshot.md)
+ [Amazon RDS の DB インスタンスを特定の時点に復元する](USER_PIT.md)

**注記**  
DB インスタンスを変更してコアごとの CPU 数とスレッド数を指定する際に、インスタンスクラスを変更したときと同様に、短時間の停止が発生します。

AWS マネジメントコンソール、AWS CLI または RDS API を使用して CPU コアを設定します。

## コンソール
<a name="SQLServer.Concepts.General.OptimizeCPU.Enabling.CON"></a>

**コアを設定するには**

1. AWS マネジメントコンソール にサインインし、Amazon RDS コンソール ([https://console.aws.amazon.com/rds/](https://console.aws.amazon.com/rds/)) を開きます。

1. [**データベースの作成**] を選択します。

1. **[インスタンス設定]** オプションを設定する場合:

   1. **[CPU を最適化]** オプションを選択します。

   1. コア数を選択して **[vCPU]** オプションを設定します。  
![OCPU 設定時のデータベース作成ページ。](https://docs.aws.amazon.com/ja_jp/AmazonRDS/latest/UserGuide/images/OCPU-screenshot.png)

1. 他の選択が完了したら、**[データベースの作成]** を選択します。

## AWS CLI
<a name="SQLServer.Concepts.General.OptimizeCPU.Enabling.CLI"></a>

**コアを設定するには**

1. AWS CLI を使用して CPU の最適化を設定するには、コマンドに `--processor-features` オプションを含めます。`coreCount` および `threadsPerCore` を `1` にして、CPU コアの数を指定します。

1. 次の構文を使用します。

   ```
   aws rds create-db-instance \
       --engine sqlserver-ee \
       --engine-version 16.00 \
       --license-model license-included \
       --allocated-storage 300 \
       --master-username {{myuser}} \
       --master-user-password {{xxxxx}} \
       --no-multi-az \
       --vpc-security-group-ids myvpcsecuritygroup \
       --db-subnet-group-name mydbsubnetgroup \
       --db-instance-identifier my-rds-instance \
       --db-instance-class db.m7i.4xlarge \
       --processor-features "Name=coreCount,Value=6" "Name=threadsPerCore,Value=1"
   ```

**Example DB インスタンスクラスの有効なプロセッサ値を確認する**  
`describe-orderable-db-instance-options` コマンドを使用して、デフォルトの vCPU、コア、コアあたりのスレッドを表示します。例えば、次のコマンドの出力は db.r7i.2xlarge インスタンスクラスのプロセッサオプションを示します。  

```
aws rds describe-orderable-db-instance-options --engine sqlserver-ee \
--db-instance-class db.r7i.2xlarge

Sample output: 
-------------------------------------------------------------
|            DescribeOrderableDBInstanceOptions             |
+-----------------------------------------------------------+
||               OrderableDBInstanceOptions                ||
|+------------------------------------+--------------------+|
||  DBInstanceClass                   |  db.r7i.2xlarge    ||
||  Engine                            |  sqlserver-ee      ||
||  EngineVersion                     |  13.00.6300.2.v1   ||
||  LicenseModel                      |  license-included  ||
||  MaxIopsPerDbInstance              |                    ||
||  MaxIopsPerGib                     |                    ||
||  MaxStorageSize                    |  64000             ||
||  MinIopsPerDbInstance              |                    ||
||  MinIopsPerGib                     |                    ||
||  MinStorageSize                    |  20                ||
||  MultiAZCapable                    |  True              ||
||  OutpostCapable                    |  False             ||
||  ReadReplicaCapable                |  True              ||
||  StorageType                       |  gp2               ||
||  SupportsClusters                  |  False             ||
||  SupportsDedicatedLogVolume        |  False             ||
||  SupportsEnhancedMonitoring        |  True              ||
||  SupportsGlobalDatabases           |  False             ||
||  SupportsIAMDatabaseAuthentication |  False             ||
||  SupportsIops                      |  False             ||
||  SupportsKerberosAuthentication    |  True              ||
||  SupportsPerformanceInsights       |  True              ||
||  SupportsStorageAutoscaling        |  True              ||
||  SupportsStorageEncryption         |  True              ||
||  SupportsStorageThroughput         |  False             ||
||  Vpc                               |  True              ||
|+------------------------------------+--------------------+|
|||                   AvailabilityZones                   |||
||+-------------------------------------------------------+||
|||                         Name                          |||
||+-------------------------------------------------------+||
|||  us-west-2a                                           |||
|||  us-west-2b                                           |||
|||  us-west-2c                                           |||
||+-------------------------------------------------------+||
|||              AvailableProcessorFeatures               |||
||+-----------------+-----------------+-------------------+||
|||  AllowedValues  |  DefaultValue   |       Name        |||
||+-----------------+-----------------+-------------------+||
|||  1,2,3,4        |  4              |  coreCount        |||
|||  1              |  1              |  threadsPerCore   |||
||+-----------------+-----------------+-------------------+||
```
さらに、次のコマンドを実行して DB インスタンスのクラスのプロセッサ情報を取得できます。  
+ `describe-db-instances` - 指定された DB インスタンスのプロセッサ情報を示します
+ `describe-db-snapshots` - 指定された DB スナップショットのプロセッサ情報を示します
+ `describe-valid-db-instance-modifications` - 指定された DB インスタンスのプロセッサに対する有効な変更を示します
前述のコマンドの出力では、CPU の最適化が設定されていない場合、プロセッサ機能の値は `null` になります。

**Example DB インスタンスの CPU コア数の設定**  
次の例では、CPU コアの数を 4、threadsPerCore を 1 に設定して {{mydbinstance}} を変更します。`--apply-immediately` を使用して変更をすぐに適用します。変更を次の予定されるメンテナンスウィンドウ中に適用するには、`--apply-immediately option` を省略します。  

```
aws rds modify-db-instance \
    --db-instance-identifier {{mydbinstance}} \
    --db-instance-class db.r7i.8xlarge \
    --processor-features "Name=coreCount,Value={{4}}" "Name=threadsPerCore,Value={{1}}" \
    --apply-immediately
```

**Example DB インスタンスのデフォルトのプロセッサ設定に戻す**  
次の例では、{{mydbinstance}} をデフォルトのプロセッサ値に戻すことで変更します。  

```
aws rds modify-db-instance \
    --db-instance-identifier {{mydbinstance}} \
    --db-instance-class db.r7i.8xlarge \
    --use-default-processor-features \
    --apply-immediately
```