通过群集创建高级 Azure Redis 缓存Create a Premium Azure Cache for Redis with clustering

在此方案中,了解如何通过启用的群集与两个分片创建 6 GB 高级层 Azure Redis 缓存。In this scenario, you learn how to create a 6 GB Premium tier Azure Cache for Redis with clustering enabled and two shards.

若要运行此示例,请安装最新版本的 Azure CLITo run this sample, install the latest version of the Azure CLI. 若要开始,请运行 az login 以创建与 Azure 的连接。To start, run az login to create a connection with Azure.

适用于 Azure CLI 的示例是针对 bash shell 编写的。Samples for the Azure CLI are written for the bash shell. 若要在 Windows PowerShell 或命令提示符中运行此示例,可能需要更改脚本的元素。To run this sample in Windows PowerShell or Command Prompt, you may need to change elements of the script.

示例脚本Sample script

#/bin/bash

# Creates a Resource Group named contosoGroup, and creates a Premium Redis Cache with clustering in that group named contosoCache

# Create a Resource Group 
az group create --name contosoGroup --location chinanorth

# Create a Premium P1 (6 GB) Redis Cache with clustering enabled and 2 shards (for a total of 12 GB)
az redis create --name contosoCache --resource-group contosoGroup --location chinanorth --vm-size P1 --sku Premium --shard-count 2

清理部署Clean up deployment

运行脚本示例后,可以使用以下命令删除资源组、Azure Redis 缓存实例以及资源组中的任何相关资源。After the script sample has been run, the follow command can be used to remove the resource group, Azure Cache for Redis instance, and any related resources in the resource group.

az group delete --name contosoGroup

脚本说明Script explanation

此脚本使用以下命令创建资源组并通过启用群集创建高级层 Azure Redis 缓存。This script uses the following commands to create a resource group and a Premium tier Azure Cache for Redis with clustering enable. 表中的每条命令均链接到特定于命令的文档。Each command in the table links to command specific documentation.

命令Command 注释Notes
az group createaz group create 创建用于存储所有资源的资源组。Creates a resource group in which all resources are stored.
az redis createaz redis create 创建 Azure Redis 缓存实例。Create Azure Cache for Redis instance.

后续步骤Next steps

有关 Azure CLI 的详细信息,请参阅 Azure CLI 文档For more information on the Azure CLI, see Azure CLI documentation.

可以在 Azure Redis 缓存文档中找到其他 Azure Redis 缓存 CLI 脚本示例。Additional Azure Cache for Redis CLI script samples can be found in the Azure Cache for Redis documentation.