

# 开启适用于 Amazon RDS 的数据库洞察的标准模式
<a name="USER_DatabaseInsights.TurningOnStandard"></a>

要开启适用于 Amazon RDS 的数据库洞察的标准模式，请使用以下过程。

## 在创建数据库实例或多可用区数据库集群时开启数据库洞察的标准模式
<a name="USER_DatabaseInsights.TurnOnCreateDatabaseStandard"></a>

在为 Amazon RDS 创建数据库时，开启数据库洞察的标准模式。

------
#### [ Console ]

在控制台中，您可以在创建数据库实例或多可用区数据库集群时开启数据库洞察的标准模式。

**在使用控制台创建数据库实例或多可用区数据库集群时，开启数据库洞察的标准模式**

1. 登录 AWS 管理控制台 并通过以下网址打开 Amazon RDS 控制台：[https://console.aws.amazon.com/rds/](https://console.aws.amazon.com/rds/)。

1. 选择**数据库**。

1. 选择**创建数据库**。

1. 在**数据库洞察**部分，选择**标准模式**。然后，从以下选项中进行选择，打开或关闭性能详情：
   + 要关闭性能详情，请取消选择**启用性能详情**。
   + 要开启性能详情，请选择**启用性能详情**。要配置性能详情，请指定以下选项：
     + **保留** – 保留性能详情数据的时间。保留期必须至少为 7 天。
     + **AWS KMS key** - 指定您的 KMS 密钥。性能详情使用您的 KMS 密钥来加密所有潜在的敏感数据。正在传输的数据和静态数据都会被加密。有关更多信息，请参阅 [加密 Amazon RDS 资源](Overview.Encryption.md)。

1. 选择**创建数据库**。

------
#### [ AWS CLI ]

要在创建数据库实例或多可用区数据库集群时开启数据库洞察的标准模式，请调用 [create-db-instance](https://docs.aws.amazon.com/cli/latest/reference/rds/create-db-instance.html) 或 [create-db-cluster](https://docs.aws.amazon.com/cli/latest/reference/rds/create-db-cluster.html) AWS CLI 命令并提供以下值：
+ `--database-insights-mode standard`，开启数据库洞察的标准模式。
+ `--engine`：数据库实例的数据库引擎。
+ `--db-instance-identifier`：数据库实例的标识符或 `--db-cluster-identifier`：多可用区数据库集群的标识符。
+ `--enable-performance-insights` 或 `--no-enable-performance-insights`，打开和关闭性能详情。如果指定 `--enable-performance-insights`，则还必须指定 `--performance-insights-retention-period`，即数据库实例的数据的保留期。保留期必须至少为 7 天。

以下示例在创建数据库实例时启用数据库洞察的标准模式和性能详情。

对于 Linux、macOS 或 Unix：

```
aws rds create-db-instance \
    --database-insights-mode standard \ 
    --engine postgresql \
    --db-instance-identifier sample-db-identifier \
    --enable-performance-insights \
    --performance-insights-retention-period 7
```

对于 Windows：

```
aws rds create-db-instance ^
    --database-insights-mode standard ^ 
    --engine postgresql ^
    --db-instance-identifier sample-db-identifier ^
    --enable-performance-insights ^
    --performance-insights-retention-period 7
```

以下示例在创建数据库实例时启用数据库洞察的标准模式，但禁用性能详情。

对于 Linux、macOS 或 Unix：

```
aws rds create-db-instance \
    --database-insights-mode standard \ 
    --engine postgresql \
    --db-instance-identifier sample-db-identifier \
    --no-enable-performance-insights
```

对于 Windows：

```
aws rds create-db-instance ^
    --database-insights-mode standard ^ 
    --engine postgresql ^
    --db-instance-identifier sample-db-identifier ^
    --no-enable-performance-insights
```

------
#### [ RDS API ]

要在创建数据库实例或多可用区数据库集群时开启数据库洞察的标准模式，请为您的 [CreateDBInstance](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_CreateDBInstance.html) 或 [CreateDBCluster](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_CreateDBCluster.html) Amazon RDS API 操作指定以下参数。
+ `DatabaseInsightsMode`到 `standard`。
+ 将 `EnablePerformanceInsights` 设置为 `True` 或 `False`。如果将 `EnablePerformanceInsights` 设置为 `True`，则必须将 `PerformanceInsightsRetentionPeriod` 设置为至少 7 天。

------

## 在修改数据库实例或多可用区数据库集群时，开启数据库洞察的标准模式
<a name="USER_DatabaseInsights.TurnOnModifyDatabaseStandard"></a>

在为 Amazon RDS 修改数据库时，开启数据库洞察的标准模式。修改数据库实例来启用数据库洞察的标准模式不会导致停机。

**注意**  
要启用数据库洞察，多可用区数据库集群中的每个数据库实例都必须具有相同的性能详情和增强型监控设置。

------
#### [ Console ]

在控制台中，您可以在修改数据库实例或多可用区数据库集群时开启数据库洞察的标准模式。

**在使用控制台修改数据库实例或多可用区数据库集群时，开启数据库洞察的标准模式**

1. 登录 AWS 管理控制台 并通过以下网址打开 Amazon RDS 控制台：[https://console.aws.amazon.com/rds/](https://console.aws.amazon.com/rds/)。

1. 选择**数据库**。

1. 选择数据库实例或多可用区数据库集群，然后选择**修改**。

1. 在**数据库洞察**部分，选择**标准模式**。然后从以下选项中进行选择：
   + 要关闭性能详情，请取消选择**启用性能详情**。
   + 要开启性能详情，请选择**启用性能详情**。要配置性能详情，请指定以下选项：
     + **保留** – 保留性能详情数据的时间。保留期必须至少为 7 天。
     + **AWS KMS key** - 指定您的 KMS 密钥。性能详情使用您的 KMS 密钥来加密所有潜在的敏感数据。正在传输的数据和静态数据都会被加密。有关更多信息，请参阅“[加密 Amazon RDS 资源](Overview.Encryption.md)”。

1. 选择**继续**。

1. 对于**修改计划**，选择**立即应用**。如果您选择**在下一个计划维护时段内应用**，则您的数据库将忽略此设置，并立即开启数据库洞察的标准模式。

1. 选择**修改实例**。

------
#### [ AWS CLI ]

要在修改数据库实例或多可用区数据库集群时开启数据库洞察的标准模式，请调用 [modify-db-instance](https://docs.aws.amazon.com/cli/latest/reference/rds/modify-db-instance.html) 或 [modify-db-cluster](https://docs.aws.amazon.com/cli/latest/reference/rds/modify-db-cluster.html) AWS CLI 命令并提供以下值：
+ `--database-insights-mode standard`，开启数据库洞察的标准模式。
+ `--db-instance-identifier`：数据库实例的标识符或 `--db-cluster-identifier`：多可用区数据库集群的标识符。
+ `--enable-performance-insights` 或 `--no-enable-performance-insights`，打开和关闭性能详情。如果指定 `--enable-performance-insights`，则还必须指定 `--performance-insights-retention-period`，即数据库实例或多可用区数据库集群的数据的保留期。保留期必须至少为 7 天。

以下示例在修改数据库实例时启用数据库洞察的标准模式并启用性能详情。

对于 Linux、macOS 或 Unix：

```
aws rds modify-db-instance \
    --database-insights-mode standard \
    --db-instance-identifier sample-db-identifier \
    --enable-performance-insights \
    --performance-insights-retention-period 7
```

对于 Windows：

```
aws rds modify-db-instance ^
    --database-insights-mode standard ^
    --db-instance-identifier sample-db-identifier ^
    --enable-performance-insights ^
    --performance-insights-retention-period 7
```

以下示例在修改数据库实例时启用数据库洞察的标准模式并禁用性能详情。

对于 Linux、macOS 或 Unix：

```
aws rds modify-db-instance \
    --database-insights-mode standard \
    --db-instance-identifier sample-db-identifier \
    --no-enable-performance-insights
```

对于 Windows：

```
aws rds modify-db-instance ^
    --database-insights-mode standard ^
    --db-instance-identifier sample-db-identifier ^
    --no-enable-performance-insights
```

------
#### [ RDS API ]

要在修改数据库实例或多可用区数据库集群时开启数据库洞察的标准模式，请为您的 [ModifyDBInstance](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_ModifyDBInstance.html) 或 [ModifyDBCluster](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_ModifyDBCluster.html) Amazon RDS API 操作指定以下参数。
+ `DatabaseInsightsMode`到 `standard`。
+ 将 `EnablePerformanceInsights` 设置为 `True` 或 `False`。如果将 `EnablePerformanceInsights` 设置为 `True`，则必须将 `PerformanceInsightsRetentionPeriod` 设置为至少 7 天。

------