创建和管理数据库

本文介绍如何使用 Redis Cloud API 创建和管理数据库。

Redis 云

您可以使用 Redis Cloud REST API 创建和管理数据库。

Redis Cloud Essentials

创建 Essentials 数据库

要创建 Redis Cloud Essentials 数据库,请使用POST /fixed/subscriptions/{subscriptionId}/databases.

此调用在指定的订阅中创建数据库。用GET /fixed/subscriptions以获取基本功能版订阅及其 ID 的列表。

POST "https://[host]/v1/fixed/subscriptions/{subscriptionId}/databases"
{
  "name": "Basic-essentials-database-example"
}

This example JSON body contains only the most basic, required parameters to create a database:

  • name: The database name. A unique name per subscription that can contain only alphanumeric characters and hyphens

There are other additional parameters and settings that can be defined on database creation. Review the database parameters and options in the full API reference.

Some options may not be compatible with your selected plan. Use GET /fixed/subscriptions/{subscriptionId} to view the plan you have selected and what options it supports.

The response body contains the taskId for the task that creates the database. You can use GET /v1/tasks/{taskId} to track the task's status.

Update an Essentials database

To update a Redis Cloud Essentials database, use PUT /fixed/subscriptions/{subscriptionId}/databases/{databaseId}.

The primary component of a database update request is the JSON request body that contains the details of the requested database changes. You can see the full set of changes you can make in the full API reference.

Some options may not be compatible with your selected plan. Use GET /fixed/subscriptions/{subscriptionId} to view the plan you have selected and what options it supports.

The response body contains the taskId for the task that updates the database. You can use GET /v1/tasks/{taskId} to track the task's status.

Redis Cloud Pro

Create a Pro database

If you want to create a Pro database in a new subscription, see Create a Pro subscription.

To create a Redis Cloud Pro database in an existing subscription, use POST /subscriptions/{subscriptionId}/databases.

This call creates a database in the specified subscription. Use GET /subscriptions to get a list of subscriptions and their IDs.

POST "https://[host]/v1/subscriptions/{subscriptionId}/databases"
{
  "name": "Basic-database-example",
  "datasetSizeInGb": 1
}

This example JSON body contains only the most basic, required parameters to create a database:

  • name: The database name. A unique name per subscription that can contain only alphanumeric characters and hyphens
  • datasetSizeInGb: Maximum dataset size in GB

There are many additional parameters and settings that can be defined on database creation. Review the database parameters and options in the full API reference.

The response body contains the taskId for the task that creates the database. You can use GET /v1/tasks/{taskId} to track the task's status.

Update a Redis Cloud Pro database

To update a Redis Cloud Pro database, use PUT /subscriptions/{subscriptionId}/databases/{databaseId}.

The primary component of a database update request is the JSON request body that contains the details of the requested database changes. You can see the full set of changes you can make in the full API reference.

The response body contains the taskId for the task that updates the database. You can use GET /v1/tasks/{taskId} to track the task's status.