如何設定 Azure Redis 快取How to configure Azure Cache for Redis

本主題說明您「Azure Redis 快取」執行個體可用的設定。This topic describes the configurations available for your Azure Cache for Redis instances. 本主題也涵蓋適用於「Azure Redis 快取」執行個體的預設 Redis 伺服器設定。This topic also covers the default Redis server configuration for Azure Cache for Redis 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.

設定 Azure Redis 快取設定Configure Azure Cache for Redis settings

如果您未將快取釘選到儀表板,請使用 [所有服務] 在 Azure 入口網站中找到快取。If you did not pin your cache to the dashboard, find your cache in the Azure portal using All services.

Azure Cache for Redis 瀏覽刀鋒視窗

若要檢視您的快取,請按一下 [所有服務] 並搜尋 [Azure Cache for Redis] 。To view your caches, click All services and search for Azure Cache for Redis.

選取所需的快取,以檢視和設定該快取的設定。Select the desired cache to view and configure the settings for that cache.

Azure Cache for Redis 瀏覽快取清單

您可以在 [Azure Cache for Redis] 刀鋒視窗檢視和設定快取。You can view and configure your cache from the Azure Cache for Redis blade.

Azure Cache for Redis 全部設定

您可以在 [Azure Redis 快取] 刀鋒視窗上使用 [資源功能表] 來檢視及設定「Azure Redis 快取」設定。Azure Cache for Redis settings are viewed and configured on the Azure Cache for Redis blade using the Resource Menu.

Azure 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. 如需使用稽核記錄的詳細資訊,請參閱使用 Resource Manager 來稽核作業For more information on working with audit logs, see Audit operations with Resource Manager. 如需有關監視「Azure Redis 快取」事件的詳細資訊,請參閱作業和警示For more information on monitoring Azure Cache for Redis 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.

TagsTags

[標記] 區段有助於您組織資源。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.

Azure 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.

注意

「Azure Redis 快取」的 SSL 存取預設支援 TLS 1.0。SSL access to Azure Cache for Redis supports TLS 1.0 by default. 您可以視需要將支援的最低 TLS 版本提升至 TLS 1.2,方法是使用 [進階設定] 刀鋒視窗上的 [最低的 TLS 版本] 下拉式清單,然後按一下 [儲存] 。The minimum supported TLS version can be raised up to TLS 1.2 if desired by using the Minimum TLS version dropdown on the Advanced settings blade and then click Save.

Azure Redis 快取存取連接埠

記憶體原則Memory policies

[進階設定] 刀鋒視窗中的 [Maxmemory 原則] 、[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.

Azure Redis 快取 Maxmemory 原則

[Maxmemory 原則] 設定快取的收回原則,並讓您從下列收回原則中選擇: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-reserved] 設定會以 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-reservedmaxfragmentationmemory-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-reservedmaxfragmentationmemory-reserved 設定。The maxmemory-reserved and maxfragmentationmemory-reserved settings are only available for Standard and Premium caches.

Keyspace 通知 (進階設定)Keyspace notifications (advanced settings)

Redis Keyspace 通知是在 [進階設定] 刀鋒視窗上進行設定。Redis keyspace notifications are configured on the Advanced settings blade. Keyspace 通知可讓用戶端在特定事件發生時收到通知。Keyspace notifications allow clients to receive notifications when certain events occur.

Azure Redis 快取進階設定

重要

Keyspace 通知和 notify-keyspace-events 設定只適用於標準和高階快取。Keyspace notifications and the notify-keyspace-events setting are only available for Standard and Premium caches.

如需詳細資訊,請參閱 Redis Keyspace 通知(英文)。For more information, see Redis Keyspace Notifications. 如需範例程式碼,請參閱 Hello world 範例中的 KeySpaceNotifications.cs 檔案。For sample code, see the KeySpaceNotifications.cs file in the Hello world sample.

Azure Redis 快取建議程式Azure Cache for Redis Advisor

[Azure Redis 快取建議程式] 刀鋒視窗會顯示適用於快取的建議。The Azure Cache for Redis Advisor blade displays recommendations for your cache. 在一般作業期間,不會顯示任何建議。During normal operations, no recommendations are displayed.

建議

如果在快取作業期間發生任何狀況 (例如高記憶體使用量、網路頻寬或伺服器負載),[Azure 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 Azure Cache for Redis blade.

建議

您可以在 [建議] 刀鋒視窗中找到進一步資訊。Further information can be found on the Recommendations blade.

建議

您可以在 [Azure Redis 快取] 刀鋒視窗的監視圖表使用量圖表區段上監視這些計量。You can monitor these metrics on the Monitoring charts and Usage charts sections of the Azure Cache for Redis 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:

Azure Redis 快取計量Azure Cache for Redis 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. 如需有關選擇定價層的詳細資訊,請參閱應該使用哪個 Azure Redis 快取供應項目和大小?For more information on choosing a pricing tier, see What Azure Cache for Redis 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 Cache for Redis.

Azure 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 Cache for Redis 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 Cache for Redis.

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 Cache for Redis offers Redis persistence using either RDB persistence or AOF persistence.

如需詳細資訊,請參閱如何設定進階 Azure Redis 快取的持續性For more information, see How to configure persistence for a Premium Azure Cache for Redis.

重要

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。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 Cache for Redis administration - Schedule updates.

異地複寫Geo-replication

[異地複寫] 刀鋒視窗提供一個機制,可連結兩個「進階」層「Azure Redis 快取」執行個體。The Geo-replication blade provides a mechanism for linking two Premium tier Azure Cache for Redis 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 Cache for Redis.

虛擬網路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 Cache for Redis.

重要

虛擬網路設定只適用於快取建立期間利用 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 Cache for Redis 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. 此延遲通常不超過一分鐘。This delay is typically less than one minute.

重要

系統一律會允許來自「Azure Redis 快取」監視系統的連線,即使已設定防火牆規則也一樣。Connections from Azure Cache for Redis 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.

Azure 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 Resource Manager 範本部署資源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 快取」的資料管理作業,可讓您從進階快取將「Azure Redis 快取資料庫」(RDB) 快照集匯入和匯出至「Azure 儲存體帳戶」中的分頁 Blob,來匯入和匯出快取中的資料。Import/Export is an Azure Cache for Redis data management operation, which allows you to import and export data in the cache by importing and exporting an Azure Cache for Redis 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 Cache for Redis instances or populate the cache with data before use.

匯入可以用來從任何雲端或環境中執行的 Redis 伺服器 (包含在 Linux、Windows 上執行的 Redis,或任何雲端提供者,例如 Amazon Web Services 等) 引入 Redis 相容 RDB 檔案。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 Cache for Redis 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 Cache for Redis to Redis compatible RDB files. 您可以使用這項功能,將資料從一個「Azure Redis 快取」執行個體移到另一個執行個體,或移到另一個 Redis 伺服器。You can use this feature to move data from one Azure Cache for Redis instance to another or to another Redis server. 在進行匯出程序的期間,會在裝載 Azure Cache for Redis 伺服器執行個體的 VM 上建立暫存檔案,然後將檔案上傳至指定的儲存體帳戶。During the export process, a temporary file is created on the VM that hosts the Azure Cache for Redis 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 Cache for Redis.

重新啟動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 Cache for Redis administration - Reboot.

監視Monitoring

[監視] 區段可讓您設定「Azure Redis 快取」的診斷和監視。The Monitoring section allows you to configure diagnostics and monitoring for your Azure Cache for Redis. 如需有關「Azure Redis 快取」監視和診斷的詳細資訊,請參閱如何監視 Azure Redis 快取For more information on Azure Cache for Redis monitoring and diagnostics, see How to monitor Azure Cache for Redis.

診斷

Redis 度量Redis metrics

按一下 [Redis 度量] 以針對您的快取檢視度量Click Redis metrics to view metrics for your cache.

警示規則Alert rules

按一下 [警示規則] 以根據「Azure Redis 快取」計量設定警示。Click Alert rules to configure alerts based on Azure Cache for Redis metrics. 如需詳細資訊,請參閱警示For more information, see Alerts.

診斷Diagnostics

根據預設,Azure 監視器中的快取計量會儲存 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.

注意

除了封存至儲存體快取計量,您也可以串流至事件中樞,或將它們傳送至 Azure 監視器記錄In addition to archiving your cache metrics to storage, you can also stream them to an Event hub or send them to Azure Monitor logs.

支援和疑難排解設定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 Cache for Redis 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 Cache for Redis 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 Cache for Redis 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 用戶端輸出緩衝區限制可用來強制中斷基於某些原因而無法足夠快地從伺服器讀取資料之用戶端的連線 (常見的原因是 Pub/Sub 用戶端使用訊息的速度無法與發佈者產生這些訊息的速度一樣快)。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). 如需詳細資訊,請參閱 https://redis.io/topics/clientsFor more information, see https://redis.io/topics/clients.

1每個「Azure Redis 快取」定價層的 databases 限制皆不相同,在建立快取建立時即可設定此限制。1The limit for databases is different for each Azure Cache for Redis 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-AzRedisCacheFor an example of configuring databases during cache creation using PowerShell, see New-AzRedisCache.

2每個「Azure Redis 快取」定價層的 maxclients 皆不相同。2maxclients is different for each Azure Cache for Redis 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.5GB) 快取 - 最多 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 Cache for Redis

重要

「Azure Redis 快取」執行個體的設定與管理是由 Microsoft 管理,因此會停用下列命令。Because configuration and management of Azure Cache for Redis 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
  • CONFIGCONFIG
  • DEBUGDEBUG
  • MIGRATEMIGRATE
  • SAVESAVE
  • SHUTDOWNSHUTDOWN
  • SLAVEOFSLAVEOF
  • CLUSTER - 叢集寫入命令已停用,但允許唯讀的叢集命令。CLUSTER - Cluster write commands are disabled, but read-only Cluster commands are permitted.

如需 Redis 命令的詳細資訊,請參閱 https://redis.io/commandsFor more information about Redis commands, see https://redis.io/commands.

Redis 主控台Redis console

您可以使用 [Redis 主控台] (所有快取層的 Azure 入口網站中的都有提供此功能) 對「Azure Redis 快取」執行個體安全地發出命令。You can securely issue commands to your Azure Cache for Redis 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 Cache for Redis. 如需針對「Azure Redis 快取」停用的 Redis 命令清單,請參閱先前的 Azure Redis 快取中不支援的 Redis 命令一節。For a list of Redis commands that are disabled for Azure Cache for Redis, see the previous Redis commands not supported in Azure Cache for Redis section. 如需 Redis 命令的詳細資訊,請參閱 https://redis.io/commandsFor more information about Redis commands, see https://redis.io/commands.

若要存取 [Redis 主控台],請從 [Azure Redis 快取] 刀鋒視窗按一下 [主控台] 。To access the Redis Console, click Console from the Azure Cache for Redis blade.

Redis 主控台

若要對快取執行個體發出命令,請在主控台中輸入想要的命令。To issue commands against your cache instance, 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 是所選的分區,但 myKey 位於分區 0,如錯誤訊息的 (shard 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.

移動 Azure 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