選擇網路類型 - Amazon ElastiCache 的雷迪斯

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

選擇網路類型

ElastiCache 支援網際網路通訊協定第 4 版和第 6 版 (IPv4 和 IPv6),可讓您將叢集設定為接受:

  • 只有 IPv4 連接,

  • 只有 IPv6 連線,

  • IPv4 和 IPv6 連線皆可 (雙堆疊)

Nitro 系統上建置的所有執行個體中,使用 Redis 引擎 6.2 版以上的工作負載都支援 IPv6。透過 IPv6 存取 ElastiCache 不另行收費。

注意

不支援在 IPV6/雙堆疊可用性之前建立的叢集遷移。也不支援在新建立的叢集上切換網路類型。

設定網路類型的子網路

如果您在 Amazon VPC 中建立叢集,就必須指定子網路群組。ElastiCache 會使用此子網路群組選擇子網路及該子網路中的 IP 地址,以與您的節點建立關聯。ElastiCache 叢集需要具有 IPv4 和 IPv6 地址的雙堆疊子網路,以便在雙堆疊模式下運作,且僅限 IPv6 的子網路僅會以 IPv6 運作。

使用雙堆疊

在啟用叢集模式下使用 ElastiCache for Redis 時,從應用程式的角度來看,透過組態端點連線到所有叢集節點與直接連線至個別快取節點沒有不同。若要達成此目標,叢集感知用戶端必須參與叢集探索程序,並要求所有節點的組態資訊。Rediss 的探索通訊協定在每個節點僅支援一個 IP。

為了維持與所有現有用戶端的回溯相容性,我們會引入 IP 探索,讓您選取要在探索通訊協定中公告的 IP 類型 (即 IPv4 或 IPv6)。雖然這將自動探索限制為只有一種 IP 類型,但有了自動探索功能,雙堆疊仍然十分有用,因為可讓您從 IPv4 遷移 (或回復) 到 IPv6 探索 IP 類型,而不會導致停機。

啟用 TLS 的雙堆疊 ElastiCache 叢集

當針對 ElastiCache 叢集啟用 TLS 時,叢集探索功能 (cluster slotscluster shards、和cluster nodes) 會傳回主機名稱而非 IP。接著會使用主機名稱而非 IP 來連線 ElastiCache 叢集,並執行 TLS 交握。這表示用戶端不會受到 IP 探索參數的影響。針對啟用 TLS 的叢集,IP 探索參數對偏好的 IP 通訊協定沒有影響。反之,用戶端在解析 DNS 主機名稱時偏好使用的 IP 通訊協定會決定所使用的 IP 通訊協定。

如需如何在解析 DNS 主機名稱時設定 IP 通訊協定偏好設定的範例,請參閱 啟用 TLS 的雙堆疊 ElastiCache 叢集

使用 AWS Management Console

使用 AWS Management Console 建立叢集時,在 Connectivity (連線) 下,選擇網路類型,可以是 IPv4IPv6Dual stack (雙堆疊)。若您要建立 Redis (啟用叢集模式) 叢集並選擇雙堆疊,則須選取 IPv6 或 IPv4 做為 Discovery IP type (探索 IP 類型)。

如需詳細資訊,請參閱 建立 Redis (啟用叢集模式) 叢集 (主控台)建立 Redis (停用叢集模式) (主控台)

使用 AWS Management Console 建立複寫群組時,請選擇網路類型,可以是 IPv4IPv6Dual stack (雙堆疊)。若您選擇雙堆疊,則須選取 IPv6 或 IPv4 做為 Discovery IP type (探索 IP 類型)。

如需詳細資訊,請參閱 從頭建立 Redis (停用叢集模式) 複寫群組在 Redis (啟用叢集模式) 中從頭建立複寫群組

使用 CLI

使用 CLI 建立快取叢集時,您可以使用 create-cache-cluster 命令並指定 NetworkTypeIPDiscovery 參數:

若為 Linux、macOS 或 Unix:

aws elasticache create-cache-cluster \ --cache-cluster-id "cluster-test" \ --engine redis \ --cache-node-type cache.m5.large \ --num-cache-nodes 1 \ --network-type dual_stack \ --ip-discovery ipv4

針對 Windows:

aws elasticache create-cache-cluster ^ --cache-cluster-id "cluster-test" ^ --engine redis ^ --cache-node-type cache.m5.large ^ --num-cache-nodes 1 ^ --network-type dual_stack ^ --ip-discovery ipv4

使用 CLI 建立停用叢集模式的複寫群組時,您可以使用 create-replication-group 命令並指定 NetworkTypeIPDiscovery 參數:

若為 Linux、macOS 或 Unix:

aws elasticache create-replication-group \ --replication-group-id sample-repl-group \ --replication-group-description "demo cluster with replicas" \ --num-cache-clusters 3 \ --primary-cluster-id redis01 \ --network-type dual_stack \ --ip-discovery ipv4

針對 Windows:

aws elasticache create-replication-group ^ --replication-group-id sample-repl-group ^ --replication-group-description "demo cluster with replicas" ^ --num-cache-clusters 3 ^ --primary-cluster-id redis01 ^ --network-type dual_stack ^ --ip-discovery ipv4

建立已啟用叢集模式的複寫群組,並使用 CLI 將 IPv4 用於 IP 探索時,您可以使用 create-replication-group 命令並指定 NetworkTypeIPDiscovery 參數:

若為 Linux、macOS 或 Unix:

aws elasticache create-replication-group \ --replication-group-id demo-cluster \ --replication-group-description "demo cluster" \ --cache-node-type cache.m5.large \ --num-node-groups 2 \ --engine redis \ --cache-subnet-group-name xyz \ --network-type dual_stack \ --ip-discovery ipv4 \ --region us-east-1

針對 Windows:

aws elasticache create-replication-group ^ --replication-group-id demo-cluster ^ --replication-group-description "demo cluster" ^ --cache-node-type cache.m5.large ^ --num-node-groups 2 ^ --engine redis ^ --cache-subnet-group-name xyz ^ --network-type dual_stack ^ --ip-discovery ipv4 ^ --region us-east-1

建立已啟用叢集模式的複寫群組,並使用 CLI 將 IPv6 用於 IP 探索時,您可以使用 create-replication-group 命令並指定 NetworkTypeIPDiscovery 參數:

若為 Linux、macOS 或 Unix:

aws elasticache create-replication-group \ --replication-group-id demo-cluster \ --replication-group-description "demo cluster" \ --cache-node-type cache.m5.large \ --num-node-groups 2 \ --engine redis \ --cache-subnet-group-name xyz \ --network-type dual_stack \ --ip-discovery ipv6 \ --region us-east-1

針對 Windows:

aws elasticache create-replication-group ^ --replication-group-id demo-cluster ^ --replication-group-description "demo cluster" ^ --cache-node-type cache.m5.large ^ --num-node-groups 2 ^ --engine redis ^ --cache-subnet-group-name xyz ^ --network-type dual_stack ^ --ip-discovery ipv6 ^ --region us-east-1