您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

如何配置 Azure Redis 缓存How to configure Azure Redis Cache

本主题介绍可用于 Azure Redis 缓存实例的配置。This topic describes the configurations available for your Azure Redis Cache instances. 本主题还介绍了适用于 Azure Redis 缓存实例的默认 Redis 服务器配置。This topic also covers the default Redis server configuration for Azure Redis Cache instances.

备注

有关配置和使用高级缓存功能的详细信息,请参阅如何配置持久性如何配置群集以及如何配置虚拟网络支持For more information on configuring and using premium cache features, see How to configure persistence, How to configure clustering, and How to configure Virtual Network support.

配置 Redis 缓存设置Configure Redis cache settings

可以通过“所有服务”在 Azure 门户中访问缓存。Caches can be accessed in the Azure portal from All services.

Azure Redis 缓存浏览边栏选项卡

若要查看缓存,请单击“所有服务”,然后搜索“Redis 缓存”。To view your caches, click All services and search for Redis Caches.

选择所需的缓存,查看和配置该缓存的设置。Select the desired cache to view and configure the settings for that cache.

Azure Redis 缓存浏览缓存列表

可以从“Redis 缓存”边栏选项卡查看和配置缓存。You can view and configure your cache from the Redis Cache blade.

Redis 缓存的所有设置

使用“资源菜单”在“Redis 缓存”边栏选项卡上查看和配置 Azure Redis 缓存设置。Azure Redis Cache settings are viewed and configured on the Redis Cache blade using the Resource Menu.

Redis 缓存设置

可使用“资源菜单”查看和配置以下设置。You can view and configure the following settings using the Resource Menu.

概述Overview

概述提高有关缓存的基本信息,如名称、端口、定价层和所选缓存度量值等。Overview provides you with basic information about your cache, such as name, ports, pricing tier, and selected cache metrics.

活动日志Activity log

单击“活动日志”可查看已对缓存执行的操作。Click Activity log to view actions performed on your cache. 也可以使用筛选来展开此视图,以包含其他资源。You can also use filtering to expand this view to include other resources. 有关如何使用审核日志的详细信息,请参阅 Audit operations with Resource Manager(使用 Resource Manager 执行审核操作)。For more information on working with audit logs, see Audit operations with Resource Manager. 有关监视 Azure Redis 缓存事件的详细信息,请参阅操作和警报For more information on monitoring Azure Redis Cache events, see Operations and alerts.

访问控制 (IAM)Access control (IAM)

访问控制 (IAM) 部分在 Azure 门户中为基于角色的访问控制 (RBAC) 提供支持。The Access control (IAM) section provides support for role-based access control (RBAC) in the Azure portal. 此配置有助于组织轻松准确地满足其访问管理要求。This configuration helps organizations meet their access management requirements simply and precisely. 有关详细信息,请参阅 Azure 门户中基于角色的访问控制For more information, see Role-based access control in the Azure portal.

标记Tags

“标记”部分可帮助用户整理资源。The Tags section helps you organize your resources. 有关详细信息,请参阅使用标记来组织 Azure 资源For more information, see Using tags to organize your Azure resources.

诊断并解决问题Diagnose and solve problems

单击“诊断并解决问题”可提供常见问题和用于解决这些问题的策略。Click Diagnose and solve problems to be provided with common issues and strategies for resolving them.

设置Settings

“设置”部分用于访问和配置缓存的下列设置。The Settings section allows you to access and configure the following settings for your cache.

访问密钥Access keys

单击“访问密钥”查看或重新生成缓存访问密钥。Click Access keys to view or regenerate the access keys for your cache. 这些密钥供连接到缓存的客户端使用。These keys are used by the clients connecting to your cache.

Redis 缓存访问密钥

高级设置Advanced settings

在“高级设置”边栏选项卡上配置以下设置。The following settings are configured on the Advanced settings blade.

访问端口Access Ports

默认情况下,为新缓存禁用非 SSL 访问。By default, non-SSL access is disabled for new caches. 要启用非 SSL 端口,请对“高级设置”边栏选项卡中的“仅允许通过 SSL 访问”单击“否”,并单击“保存”。To enable the non-SSL port, click No for Allow access only via SSL on the Advanced settings blade and then click Save.

Redis 缓存访问端口

内存策略Memory policies

“高级设置”边栏选项卡上的“Maxmemory policy”、“maxmemory-reserved”和“maxfragmentationmemory-reserved”设置用于为缓存配置内存策略。The Maxmemory policy, maxmemory-reserved, and maxfragmentationmemory-reserved settings on the Advanced settings blade configure the memory policies for the cache.

Redis 缓存 Maxmemory 策略

“Maxmemory policy”用于为缓存配置逐出策略,并允许你从以下逐出策略中进行选择:Maxmemory policy configures the eviction policy for the cache and allows you to choose from the following eviction policies:

  • volatile-lru - 这是默认逐出策略。volatile-lru - This is the default eviction policy.
  • allkeys-lru
  • volatile-random
  • allkeys-random
  • volatile-ttl
  • noeviction

有关 maxmemory 策略的详细信息,请参阅逐出策略For more information about maxmemory policies, see Eviction policies.

“maxmemory-reserved”设置用于配置保留给非缓存操作(例如故障转移期间的复制)的内存量 (MB)。The maxmemory-reserved setting configures the amount of memory, in MB, that is reserved for non-cache operations, such as replication during failover. 设置此值能够在负载变化时具有更一致的 Redis 服务器体验。Setting this value allows you to have a more consistent Redis server experience when your load varies. 对于写入密集型工作负荷,应将此值设置为较高。This value should be set higher for workloads that are write heavy. 为此类操作保留内存后,将无法存储缓存数据。When memory is reserved for such operations, it is unavailable for storage of cached data.

“maxfragmentationmemory-reserve”设置配置保留以容纳内存碎片的内存量(以 MB 为单位)。The maxfragmentationmemory-reserved setting configures the amount of memory in MB that is reserved to accommodate for memory fragmentation. 设置此值后,即使在缓存已满或接近满的状态并且碎片比率很高时,你也能拥有更加稳定的 Redis 服务器体验。Setting this value allows you to have a more consistent Redis server experience when the cache is full or close to full and the fragmentation ratio is high. 为此类操作保留内存后,将无法存储缓存数据。When memory is reserved for such operations, it is unavailable for storage of cached data.

在选择新的内存保留值(maxmemory-reserved 或 maxfragmentationmemory-reserved)时,请注意此更改可能会如何影响已在运行的包含大量数据的缓存。One thing to consider when choosing a new memory reservation value (maxmemory-reserved or maxfragmentationmemory-reserved) is how this change might affect a cache that is already running with large amounts of data in it. 例如,如果你的 53 GB 缓存中已有 49 GB 数据,那么,将保留值更改为 8 GB 后,此更改会将系统的最大可用内存降至 45 GB。For instance, if you have a 53 GB cache with 49 GB of data, then change the reservation value to 8 GB, this change will drop the max available memory for the system down to 45 GB. 如果你的当前 used_memoryused_memory_rss 值高于 45 GB 的新限制,则系统需要逐出数据,直到 used_memoryused_memory_rss 均低于 45 GB。If either your current used_memory or your used_memory_rss values are higher than the new limit of 45 GB, then the system will have to evict data until both used_memory and used_memory_rss are below 45 GB. 逐出可能会增加服务器负载和内存碎片。Eviction can increase server load and memory fragmentation. 有关 used_memoryused_memory_rss 等缓存指标的详细信息,请参阅可用指标和报告时间间隔For more information on cache metrics such as used_memory and used_memory_rss, see Available metrics and reporting intervals.

重要

“maxmemory-reserved”和“maxfragmentationmemory-reserved”设置仅适用于标准缓存和高级缓存。The maxmemory-reserved and maxfragmentationmemory-reserved settings are only available for Standard and Premium caches.

密钥空间通知(高级设置)Keyspace notifications (advanced settings)

Redis 密钥空间通知是在“高级设置”边栏选项卡上配置的。Redis keyspace notifications are configured on the Advanced settings blade. 密钥空间通知让客户端能够在发生特定事件时接收通知。Keyspace notifications allow clients to receive notifications when certain events occur.

Redis 缓存高级设置

重要

密钥空间通知和“notify-keyspace-events”设置仅适用于标准缓存和高级缓存。Keyspace notifications and the notify-keyspace-events setting are only available for Standard and Premium caches.

有关详细信息,请参阅 Redis Keyspace Notifications(Redis 密钥空间通知)。For more information, see Redis Keyspace Notifications. 有关示例代码,请参阅 Hello world 示例中的 KeySpaceNotifications.cs 文件。For sample code, see the KeySpaceNotifications.cs file in the Hello world sample.

Redis 缓存顾问Redis Cache Advisor

“Redis 缓存顾问”边栏选项卡会显示适用于缓存的建议。The Redis Cache Advisor blade displays recommendations for your cache. 在正常操作期间,不会显示任何建议。During normal operations, no recommendations are displayed.

建议

如果在缓存操作期间发生任何状况(例如,高内存使用率、网络带宽或服务器负载),会在“Redis 缓存”边栏选项卡中显示警报。If any conditions occur during the operations of your cache such as high memory usage, network bandwidth, or server load, an alert is displayed on the Redis Cache blade.

建议

可在“建议”边栏选项卡上找到进一步的信息。Further information can be found on the Recommendations blade.

建议

可以在“Redis 缓存”边栏选项卡的监视图表使用率图表部分监视这些度量值。You can monitor these metrics on the Monitoring charts and Usage charts sections of the Redis Cache blade.

每个定价层都有不同的客户端连接、内存和带宽的限制。Each pricing tier has different limits for client connections, memory, and bandwidth. 如果缓存持续一段时间接近这些度量值的最大容量,即会提供建议。If your cache approaches maximum capacity for these metrics over a sustained period of time, a recommendation is created. 有关通过“建议”工具查看的指标和限制的详细信息,请参阅下表:For more information about the metrics and limits reviewed by the Recommendations tool, see the following table:

Redis 缓存度量值Redis Cache metric 详细信息More information
网络带宽使用率Network bandwidth usage 缓存性能 - 可用带宽Cache performance - available bandwidth
连接的客户端数Connected clients 默认 Redis 服务器配置 - maxclientsDefault Redis server configuration - maxclients
服务器负载Server load 使用率图表 - Redis 服务器负载Usage charts - Redis Server Load
内存使用率Memory usage 缓存性能 - 大小Cache performance - size

若要升级缓存,请单击“立即升级”以更改定价层并缩放缓存。To upgrade your cache, click Upgrade now to change the pricing tier and scale your cache. 有关选择定价层的详细信息,请参阅应使用哪种 Redis 缓存产品和大小?For more information on choosing a pricing tier, see What Redis Cache offering and size should I use?

缩放Scale

单击“缩放”可查看或更改缓存的定价层。Click Scale to view or change the pricing tier for your cache. 有关缩放的详细信息,请参阅如何缩放 Azure Redis 缓存For more information on scaling, see How to Scale Azure Redis Cache.

Redis 缓存定价层

Redis 群集大小Redis Cluster Size

单击“(预览) Redis 群集大小”可更改正在运行并且已启用群集的高级缓存的群集大小。Click (PREVIEW) Redis Cluster Size to change the cluster size for a running premium cache with clustering enabled.

备注

请注意,虽然 Azure Redis 缓存高级层已发行公开上市版,但 Redis 群集大小功能目前以预览版提供。Note that while the Azure Redis Cache Premium tier has been released to General Availability, the Redis Cluster Size feature is currently in preview.

Redis 群集大小

要更改群集大小,请使用滑块,或在“分片计数”文本框中键入 1 到 10 之间的数字,并单击“确定”进行保存。To change the cluster size, use the slider or type a number between 1 and 10 in the Shard count text box and click OK to save.

重要

Redis 群集仅适用于高级缓存。Redis clustering is only available for Premium caches. 有关详细信息,请参阅 如何为高级 Azure Redis 缓存配置群集功能For more information, see How to configure clustering for a Premium Azure Redis Cache.

Redis 数据持久性Redis data persistence

单击“Redis 数据持久性”可启用、禁用或配置高级缓存的数据持久性。Click Redis data persistence to enable, disable, or configure data persistence for your premium cache. Azure Redis 缓存通过 RDB 持久性AOF 持久性提供 Redis 持久性。Azure Redis Cache offers Redis persistence using either RDB persistence or AOF persistence.

有关详细信息,请参阅如何为高级 Azure Redis 缓存配置持久性For more information, see How to configure persistence for a Premium Azure Redis Cache.

重要

Redis 数据持久性仅适用于高级缓存。Redis data persistence is only available for Premium caches.

计划更新Schedule updates

可以通过“计划更新”边栏选项卡指定一个维护时段,以便针对缓存进行 Redis 服务器更新。The Schedule updates blade allows you to designate a maintenance window for Redis server updates for your cache.

重要

维护时段仅适用于 Redis 服务器更新,不适用于任何 Azure 更新或托管缓存的 VM 的操作系统更新。The maintenance window applies only to Redis server updates, and not to any Azure updates or updates to the operating system of the VMs that host the cache.

计划更新

要指定维护时段,请勾选合适的日期,并指定每天的维护时段开始时间,最后再单击“确定”。To specify a maintenance window, check the desired days and specify the maintenance window start hour for each day, and click OK. 请注意,维护时段使用 UTC 时间。Note that the maintenance window time is in UTC.

重要

“计划更新”功能仅适用于高级层缓存。The Schedule updates functionality is only available for Premium tier caches. 有关详细信息和说明,请参阅 Azure Redis 缓存管理 - 计划更新For more information and instructions, see Azure Redis Cache administration - Schedule updates.

异地复制Geo-replication

“异地复制”边栏选项卡提供一种用于链接两个高级层 Azure Redis 缓存实例的机制。The Geo-replication blade provides a mechanism for linking two Premium tier Azure Redis Cache instances. 一个缓存指定为主链接缓存,另一个缓存指定为辅助链接缓存。One cache is designated as the primary linked cache, and the other as the secondary linked cache. 辅助链接缓存将变为只读,写入主缓存的数据将复制到辅助链接缓存。The secondary linked cache becomes read-only, and data written to the primary cache is replicated to the secondary linked cache. 此功能可用于跨 Azure 区域复制缓存。This functionality can be used to replicate a cache across Azure regions.

重要

异地复制仅适用于高级层缓存。Geo-replication is only available for Premium tier caches. 有关详细信息和说明,请参阅如何为 Azure Redis 缓存配置异地复制For more information and instructions, see How to configure Geo-replication for Azure Redis Cache.

虚拟网络Virtual Network

使用“虚拟网络”部分,可配置缓存的虚拟网络设置。The Virtual Network section allows you to configure the virtual network settings for your cache. 有关利用 VNET 支持创建高级缓存并更新其设置的信息,请参阅如何配置高级 Azure Redis 缓存的虚拟网络支持For information on creating a premium cache with VNET support and updating its settings, see How to configure Virtual Network Support for a Premium Azure Redis Cache.

重要

虚拟网络设置仅适用于缓存创建期间利用 VNET 支持配置的高级缓存。Virtual network settings are only available for premium caches that were configured with VNET support during cache creation.

防火墙Firewall

防火墙规则配置可用于所有 Azure Redis 缓存层。Firewall rules configuration is available for all Azure Redis Cache tiers.

单击“防火墙”,查看和配置缓存的防火墙规则。Click Firewall to view and configure firewall rules for cache.

防火墙

可以指定具有开始和结束 IP 地址范围的防火墙规则。You can specify firewall rules with a start and end IP address range. 配置防火墙规则时,仅指定 IP 地址范围内的客户端连接可以连接到缓存。When firewall rules are configured, only client connections from the specified IP address ranges can connect to the cache. 保存防火墙规则后,规则生效前会有短暂延迟。When a firewall rule is saved, there is a short delay before the rule is effective. 延迟通常不超过 1 分钟。This delay is typically less than one minute.

重要

即使配置了防火墙规则,仍始终允许来自 Azure Redis 缓存监视系统的连接。Connections from Azure Redis Cache monitoring systems are always permitted, even if firewall rules are configured.

属性Properties

单击“属性”查看有关缓存的信息,包括缓存终结点和端口。Click Properties to view information about your cache, including the cache endpoint and ports.

Redis 缓存属性

Locks

“锁定”部分可用来锁定订阅、资源组或资源,以防止组织中的其他用户意外删除或修改关键资源。The Locks section allows you to lock a subscription, resource group, or resource to prevent other users in your organization from accidentally deleting or modifying critical resources. 有关详细信息,请参阅 使用 Azure 资源管理器锁定资源For more information, see Lock resources with Azure Resource Manager.

自动化脚本Automation script

单击“自动化模板”可生成并导出已部署资源的模板,以用于将来部署。Click Automation script to build and export a template of your deployed resources for future deployments. 有关使用模板的详细信息,请参阅使用 Azure 资源管理器模板部署资源For more information about working with templates, see Deploy resources with Azure Resource Manager templates.

管理设置Administration settings

可以通过“管理”部分的设置针对缓存执行以下管理任务。The settings in the Administration section allow you to perform the following administrative tasks for your cache.

管理

导入/导出Import/Export

导入/导出是一种 Azure Redis 缓存数据管理操作,可用于通过从高级缓存导入 Redis 缓存数据库 (RDB) 快照以及将 Redis 缓存数据库 (RDB) 快照导出到 Azure 存储帐户中的页 blob 来相应地在缓存中导入和导出数据。Import/Export is an Azure Redis Cache data management operation, which allows you to import and export data in the cache by importing and exporting a Redis Cache Database (RDB) snapshot from a premium cache to a page blob in an Azure Storage Account. 导入/导出允许在不同 Azure Redis 缓存实例之间进行迁移,或者在使用缓存之前在缓存中填充数据。Import/Export enables you to migrate between different Azure Redis Cache instances or populate the cache with data before use.

导入可用于从任何云或环境中运行的任何 Redis 服务器引入与 Redis 兼容的 RDB 文件,包括在 Linux、Windows 上运行的 Redis 或任何云提供程序(如 Amazon Web Services 等)。Import can be used to bring Redis compatible RDB files from any Redis server running in any cloud or environment, including Redis running on Linux, Windows, or any cloud provider such as Amazon Web Services and others. 导入数据是使用预先填充的数据创建缓存的简单方式。Importing data is an easy way to create a cache with pre-populated data. 在导入过程中,Azure Redis 缓存从 Azure 存储将 RDB 文件加载到内存中,然后再将密钥插入到缓存中。During the import process, Azure Redis Cache loads the RDB files from Azure storage into memory, and then inserts the keys into the cache.

使用导出可以将 Azure Redis 缓存中存储的数据导出到与 Redis 兼容的 RDB 文件。Export allows you to export the data stored in Azure Redis Cache to Redis compatible RDB files. 可以使用此功能将一个 Azure Redis 缓存实例中的数据移到另一个 Azure Redis 缓存实例或另一个 Redis 服务器。You can use this feature to move data from one Azure Redis Cache instance to another or to another Redis server. 在导出过程中,会在托管 Azure Redis 缓存服务器实例的 VM 上创建临时文件,并将该文件上传到指定的存储帐户。During the export process, a temporary file is created on the VM that hosts the Azure Redis Cache server instance, and the file is uploaded to the designated storage account. 导出操作完成后,无论状态为成功还是失败,都会删除临时文件。When the export operation completes with either a status of success or failure, the temporary file is deleted.

重要

导入/导出仅适用于高级层缓存。Import/Export is only available for Premium tier caches. 有关详细信息和说明,请参阅在 Azure Redis 缓存中导入和导出数据For more information and instructions, see Import and Export data in Azure Redis Cache.

重新启动Reboot

可通过“重新启动”边栏选项卡重新启动缓存的节点。The Reboot blade allows you to reboot the nodes of your cache. 如果有缓存节点发生故障,此重新启动功能可用于测试应用程序的复原能力。This reboot capability enables you to test your application for resiliency if there is a failure of a cache node.

重新启动

如果高级缓存启用了群集功能,则可选择要重新启动的缓存分片。If you have a premium cache with clustering enabled, you can select which shards of the cache to reboot.

重新启动

要重新启动缓存的一个或多个节点,请选择所需节点,并单击“重新启动”。To reboot one or more nodes of your cache, select the desired nodes and click Reboot. 如果高级缓存启用了群集功能,请选择要重新启动的分片,并单击“重新启动”。If you have a premium cache with clustering enabled, select the shard(s) to reboot and then click Reboot. 几分钟后,所选节点将重新启动,再过几分钟后,又会回到联机状态。After a few minutes, the selected node(s) reboot, and are back online a few minutes later.

重要

现在所有定价层都可以重新启动。Reboot is now available for all pricing tiers. 有关详细信息和说明,请参阅 Azure Redis 缓存管理 - 重启For more information and instructions, see Azure Redis Cache administration - Reboot.

监视Monitoring

“监视”部分用于配置诊断和监视 Redis 缓存。The Monitoring section allows you to configure diagnostics and monitoring for your Redis Cache. 有关 Azure Redis 缓存监视和诊断的详细信息,请参阅如何监视 Azure Redis 缓存For more information on Azure Redis Cache monitoring and diagnostics, see How to monitor Azure Redis Cache.

诊断

Redis 指标Redis metrics

单击“Redis 指标”可查看度量值(用于缓存的)。Click Redis metrics to view metrics for your cache.

警报规则Alert rules

单击“警报规则”可配置基于 Redis 缓存指标的警报。Click Alert rules to configure alerts based on Redis Cache metrics. 有关详细信息,请参阅警报For more information, see Alerts.

诊断Diagnostics

默认情况下,Azure Monitor 中的缓存指标会存储 30 天,之后将被删除。By default, cache metrics in Azure Monitor are stored for 30 days and then deleted. 若要将缓存指标保留超过 30 天,请单击“诊断”,配置存储帐户以用于存储缓存诊断。To persist your cache metrics for longer than 30 days, click Diagnostics to configure the storage account used to store cache diagnostics.

备注

除了将缓存指标存档到存储中外,还可以将其流式传输到事件中心或将其发送到 Log AnalyticsIn addition to archiving your cache metrics to storage, you can also stream them to an Event hub or send them to Log Analytics.

支持和故障排除设置Support & troubleshooting settings

“支持 + 疑难解答”部分中的设置提供了用于解决缓存问题的选项。The settings in the Support + troubleshooting section provide you with options for resolving issues with your cache.

支持 + 疑难解答

资源运行状况Resource health

“资源运行状况”会监视资源,并告知资源是否按预期运行。Resource health watches your resource and tells you if it's running as expected. 有关 Azure 资源运行状况服务的详细信息,请参阅 Azure 资源运行状况概述For more information about the Azure Resource health service, see Azure Resource health overview.

备注

资源运行状况当前无法报告在虚拟网络中托管的 Azure Redis 缓存实例的运行状况。Resource health is currently unable to report on the health of Azure Redis Cache instances hosted in a virtual network. 有关详细信息,请参阅在 VNET 中托管缓存时,是否可以使用所有缓存功能?For more information, see Do all cache features work when hosting a cache in a VNET?

新建支持请求New support request

单击“新建支持请求”可建立缓存的支持请求。Click New support request to open a support request for your cache.

默认 Redis 服务器配置Default Redis server configuration

新的 Azure Redis 缓存实例均已配置以下默认 Redis 配置值:New Azure Redis Cache instances are configured with the following default Redis configuration values:

备注

无法使用 StackExchange.Redis.IServer.ConfigSet 方法更改本部分中的设置。The settings in this section cannot be changed using the StackExchange.Redis.IServer.ConfigSet method. 如果使用此部分中的任一命令调用此方法,将引发类似于如下示例的异常:If this method is called with one of the commands in this section, an exception similar to the following example is thrown:

StackExchange.Redis.RedisServerException: ERR unknown command 'CONFIG'

任何可配置的值(例如 max-memory-policy)都可以通过 Azure 门户或命令行管理工具(例如 Azure CLI 或 PowerShell)进行配置。Any values that are configurable, such as max-memory-policy, are configurable through the Azure portal or command-line management tools such as Azure CLI or PowerShell.

设置Setting 默认值Default value 说明Description
databases 1616 默认的数据库数为 16,但可以根据定价层配置不同数目。1 默认数据库是 DB 0,可以基于每个连接使用 connection.GetDatabase(dbid)(其中 dbid 是介于 0databases - 1 之间的数字)选择其他数据库。The default number of databases is 16 but you can configure a different number based on the pricing tier.1 The default database is DB 0, you can select a different one on a per-connection basis using connection.GetDatabase(dbid) where dbid is a number between 0 and databases - 1.
maxclients 取决于定价层2Depends on the pricing tier2 该值是同一时间内允许的最大已连接客户端数。This value is the maximum number of connected clients allowed at the same time. 一旦达到该限制,Redis 会在关闭所有新连接的同时返回“达到客户端最大数量”的错误。Once the limit is reached Redis closes all the new connections, returning a 'max number of clients reached' error.
maxmemory-policy volatile-lru Maxmemory 策略是达到 maxmemory(创建缓存时所选缓存服务的大小)时,Redis 会根据它选择要删除内容的设置。Maxmemory policy is the setting for how Redis selects what to remove when maxmemory (the size of the cache offering you selected when you created the cache) is reached. Azure Redis 缓存的默认设置为 volatile-lru,此设置使用 LRU 算法删除具有过期设置的密钥。With Azure Redis Cache the default setting is volatile-lru, which removes the keys with an expiration set using an LRU algorithm. 可以在 Azure 门户中配置此设置。This setting can be configured in the Azure portal. 有关详细信息,请参阅内存策略For more information, see Memory policies.
maxmemory-samples 33 为了节省内存,LRU 和最小 TTL 算法是近似算法而不是精确算法。To save memory, LRU and minimal TTL algorithms are approximated algorithms instead of precise algorithms. 默认情况下,Redis 会检查三个密钥并选取最近使用较少的一个。By default Redis checks three keys and picks the one that was used less recently.
lua-time-limit 5,0005,000 Lua 脚本的最大执行时间(以毫秒为单位)。Max execution time of a Lua script in milliseconds. 如果达到最大执行时间,Redis 将记录脚本在达到最大允许时间后仍在执行,并开始以错误响应查询。If the maximum execution time is reached, Redis logs that a script is still in execution after the maximum allowed time, and starts to reply to queries with an error.
lua-event-limit 500500 脚本事件队列的最大大小。Max size of script event queue.
client-output-buffer-limit normalclient-output-buffer-limit pubsubclient-output-buffer-limit normalclient-output-buffer-limit pubsub 0 0 032mb 8mb 600 0 032mb 8mb 60 客户端输出缓冲区限制可用于强制断开处于某种原因(一个常见原因是发布/订阅客户端处理消息的速度慢于发布者提供消息的速度)而未从服务器快速读取数据的客户端的连接。The client output buffer limits can be used to force disconnection of clients that are not reading data from the server fast enough for some reason (a common reason is that a Pub/Sub client can't consume messages as fast as the publisher can produce them). 有关详细信息,请参阅 http://redis.io/topics/clientsFor more information, see http://redis.io/topics/clients.

1每个 Azure Redis 缓存定价层的 databases 限制是不同的,可以在创建缓存时进行设置。1The limit for databases is different for each Azure Redis Cache pricing tier and can be set at cache creation. 如果在创建缓存期间未指定 databases 设置,则默认值为 16。If no databases setting is specified during cache creation, the default is 16.

  • 基本缓存和标准缓存Basic and Standard caches
    • C0 (250 MB) 缓存 - 最多支持 16 个数据库C0 (250 MB) cache - up to 16 databases
    • C1 (1 GB) 缓存 - 最多支持 16 个数据库C1 (1 GB) cache - up to 16 databases
    • C2 (2.5 GB) 缓存 - 最多支持 16 个数据库C2 (2.5 GB) cache - up to 16 databases
    • C3 (6 GB) 缓存 - 最多支持 16 个数据库C3 (6 GB) cache - up to 16 databases
    • C4 (13 GB) 缓存 - 最多支持 32 个数据库C4 (13 GB) cache - up to 32 databases
    • C5 (26 GB) 缓存 - 最多支持 48 个数据库C5 (26 GB) cache - up to 48 databases
    • C6 (53 GB) 缓存 - 最多支持 64 个数据库C6 (53 GB) cache - up to 64 databases
  • 高级缓存Premium caches
    • P1 (6 GB - 60 GB) - 最多支持 16 个数据库P1 (6 GB - 60 GB) - up to 16 databases
    • P2 (13 GB - 130 GB) - 最多支持 32 个数据库P2 (13 GB - 130 GB) - up to 32 databases
    • P3 (26 GB - 260 GB) - 最多支持 48 个数据库P3 (26 GB - 260 GB) - up to 48 databases
    • P4 (53 GB - 530 GB) - 最多支持 64 个数据库P4 (53 GB - 530 GB) - up to 64 databases
    • 所有启用了 Redis 群集的高级缓存 - Redis 群集仅支持使用数据库 0,因此任何启用了 Redis 群集的高级缓存的 databases 限制实际上是 1,并且不允许使用 Select 命令。All premium caches with Redis cluster enabled - Redis cluster only supports use of database 0 so the databases limit for any premium cache with Redis cluster enabled is effectively 1 and the Select command is not allowed. 有关详细信息,请参阅使用群集功能时,是否需要对客户端应用程序进行更改?For more information, see Do I need to make any changes to my client application to use clustering?

有关数据库的详细信息,请参阅什么是 Redis 数据库?For more information about databases, see What are Redis databases?

备注

databases 设置只能在创建缓存期间配置,并且只能使用 PowerShell、CLI 或其他管理客户端进行配置。The databases setting can be configured only during cache creation and only using PowerShell, CLI, or other management clients. 有关在创建缓存期间使用 PowerShell 配置 databases 的示例,请参阅 New-AzureRmRedisCacheFor an example of configuring databases during cache creation using PowerShell, see New-AzureRmRedisCache.

2maxclients 对于每个 Azure Redis 缓存定价层都是不同的。2maxclients is different for each Azure Redis Cache pricing tier.

  • 基本缓存和标准缓存Basic and Standard caches
    • C0 (250 MB) 缓存 - 最多支持 256 个连接C0 (250 MB) cache - up to 256 connections
    • C1 (1 GB) 缓存 - 最多支持 1,000 个连接C1 (1 GB) cache - up to 1,000 connections
    • C2 (2.5 GB) 缓存 - 最多支持 2,000 个连接C2 (2.5 GB) cache - up to 2,000 connections
    • C3 (6 GB) 缓存 - 最多支持 5,000 个连接C3 (6 GB) cache - up to 5,000 connections
    • C4 (13 GB) 缓存 - 最多支持 10,000 个连接C4 (13 GB) cache - up to 10,000 connections
    • C5 (26 GB) 缓存 - 最多支持 15,000 个连接C5 (26 GB) cache - up to 15,000 connections
    • C6 (53 GB) 缓存 - 最多支持 20,000 个连接C6 (53 GB) cache - up to 20,000 connections
  • 高级缓存Premium caches
    • P1 (6 GB - 60 GB) - 最多支持 7,500 个连接P1 (6 GB - 60 GB) - up to 7,500 connections
    • P2 (13 GB - 130 GB) - 最多支持 15,000 个连接P2 (13 GB - 130 GB) - up to 15,000 connections
    • P3 (26 GB - 260 GB) - 最多支持 30,000 个连接P3 (26 GB - 260 GB) - up to 30,000 connections
    • P4 (53 GB - 530 GB) — 最多支持 40,000 个连接P4 (53 GB - 530 GB) - up to 40,000 connections

备注

虽然每个缓存大小最多允许一定数量的连接,但与 Redis 的每个连接都具有其关联的开销。While each size of cache allows up to a certain number of connections, each connection to Redis has overhead associated with it. 此类开销的一个示例是,由于 TLS/SSL 加密而导致的 CPU 和内存使用。An example of such overhead would be CPU and memory usage as a result of TLS/SSL encryption. 给定缓存大小的最大连接限制假定轻负载缓存。The maximum connection limit for a given cache size assumes a lightly loaded cache. 如果连接开销的负载客户端操作的负载超出了系统容量,那么即使未超出当前缓存大小的连接限制,缓存也可能会遇到容量问题。If load from connection overhead plus load from client operations exceeds capacity for the system, the cache can experience capacity issues even if you have not exceeded the connection limit for the current cache size.

Azure Redis 缓存中不支持 Redis 命令Redis commands not supported in Azure Redis Cache

重要

因为 Azure Redis 缓存实例的配置和管理由 Microsoft 进行管理,所以禁用了以下命令。Because configuration and management of Azure Redis Cache instances is managed by Microsoft, the following commands are disabled. 如果尝试调用它们,将收到一条类似于 "(error) ERR unknown command" 的错误消息。If you try to invoke them, you receive an error message similar to "(error) ERR unknown command".

  • BGREWRITEAOFBGREWRITEAOF
  • BGSAVEBGSAVE
  • 配置CONFIG
  • 调试DEBUG
  • 迁移MIGRATE
  • 保存SAVE
  • 关机SHUTDOWN
  • SLAVEOFSLAVEOF
  • CLUSTER - 群集写命令已禁用,但允许使用只读群集命令。CLUSTER - Cluster write commands are disabled, but read-only Cluster commands are permitted.

有关 Redis 命令的详细信息,请参阅 http://redis.io/commandsFor more information about Redis commands, see http://redis.io/commands.

Redis 控制台Redis console

可以使用“Redis 控制台”向 Azure Redis 缓存实例安全地发出命令,此操作在 Azure 门户中适用于所有缓存层。You can securely issue commands to your Azure Redis Cache instances using the Redis Console, which is available in the Azure portal for all cache tiers.

重要

  • Redis 控制台不处理 VNETThe Redis Console does not work with VNET. 如果缓存是 VNET 的一部分,则只有 VNET 中的客户端可以访问缓存。When your cache is part of a VNET, only clients in the VNET can access the cache. 由于 Redis 控制台在本地浏览器中运行(这在 VNET 的外部),因此它无法连接到缓存。Because Redis Console runs in your local browser, which is outside the VNET, it can't connect to your cache.
  • Azure Redis 缓存中并不支持所有 Redis 命令。Not all Redis commands are supported in Azure Redis Cache. 有关为 Azure Redis 缓存禁用的 Redis 命令列表,请参阅之前的 Azure Redis 缓存中不支持的 Redis 命令部分。For a list of Redis commands that are disabled for Azure Redis Cache, see the previous Redis commands not supported in Azure Redis Cache section. 有关 Redis 命令的详细信息,请参阅 http://redis.io/commandsFor more information about Redis commands, see http://redis.io/commands.

要访问 Redis 控制台,则从“Redis 缓存”边栏选项卡单击“控制台”。To access the Redis Console, click Console from the Redis Cache blade.

Redis 控制台

若要针对缓存实例发出命令,只需将所需命令键入到控制台即可。To issue commands against your cache instance, simply type the desired command into the console.

Redis 控制台

配合使用 Redis 控制台和高级群集缓存Using the Redis Console with a premium clustered cache

配合使用 Redis 控制台和高级群集缓存时,可向缓存的单个分片发出命令。When using the Redis Console with a premium clustered cache, you can issue commands to a single shard of the cache. 若要向某个特定分片发出命令,请首先在分片选取器上单击所需的分片以连接到它。To issue a command to a specific shard, first connect to the desired shard by clicking it on the shard picker.

Redis 控制台

如果尝试访问存储在不同分片(而非已连接的分片)中的密钥,将收到类似于以下消息的错误消息:If you attempt to access a key that is stored in a different shard than the connected shard, you receive an error message similar to the following message:

shard1>get myKey
(error) MOVED 866 13.90.202.154:13000 (shard 0)

在之前的示例中,分片 1 为所选分片,但如错误消息的 (shard 0) 部分所述,myKey 位于分片 0 中。In the previous example, shard 1 is the selected shard, but myKey is located in shard 0, as indicated by the (shard 0) portion of the error message. 在此示例中,若要访问 myKey,请使用分片选取器选择分片 0,然后发出所需命令。In this example, to access myKey, select shard 0 using the shard picker, and then issue the desired command.

将缓存移动到新的订阅Move your cache to a new subscription

可以单击“移动”,将缓存移动到新的订阅。You can move your cache to a new subscription by clicking Move.

移动 Redis 缓存

有关在资源组之间以及订阅之间移动资源的信息,请参阅将资源移到新的资源组或订阅For information on moving resources from one resource group to another, and from one subscription to another, see Move resources to new resource group or subscription.

后续步骤Next steps