從頭開始在 Redis OSS (叢集模式已啟用) 中建立複寫群組 - Amazon ElastiCache (雷迪斯 OSS)

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

從頭開始在 Redis OSS (叢集模式已啟用) 中建立複寫群組

您可以使用 ElastiCache 主控台、或 API 建立 Redis OSS (已啟用叢集模式) 叢集 (API/CLI:複寫群組)。 AWS CLI ElastiCache Redis OSS (已啟用叢集模式) 複寫群組具有 1 到 500 個碎片 (API/CLI:節點群組)、每個碎片中有一個主要節點,以及每個碎片中最多 5 個僅供讀取複本。您可以建立具有較高數量碎片和較低數量複本的叢集,每一叢集最高總計為 90 個節點。此叢集組態的範圍可以從 90 個碎片和 0 個複本到 15 個碎片和 5 個複本,這是允許的複本最大數量。

如果 Redis OSS 引擎版本為 5.0.6 或更高版本,則每個叢集的節點或碎片限制最多可增加到 500 個。例如,您可以選擇設定具有 500 個節點的叢集,並容許碎片在 83 個(每個碎片一個主要版本和 5 個複本)到 500 個(單一主要版本並且沒有複本)之間變化。請確保有足夠的可用 IP 地址來容納增加的數量。常見的缺陷包括子網路群組中的子網路的 CIDR 範圍太小,或是子網路被共用並被其他叢集大量使用。如需詳細資訊,請參閱 建立子網路群組

對於 5.0.6 以下的版本,每個叢集的限制為 250 個。

若要請求提高配額,請參閱 AWS 服務配額,並選擇配額類型 Nodes per cluster per instance type (每執行個體類型每叢集的節點數)

建立 Redis OSS (已啟用叢集模式) 叢集 (主控台)

若要建立 Redis OSS (已啟用叢集模式) 叢集,請參閱。建立 Redis OSS (已啟用叢集模式) 叢集 (主控台)請務必啟用叢集模式 (Cluster Mode enabled (Scale Out) (啟用叢集模式 (向外擴展))),並在其中指定至少兩個碎片及一個複本節點。

從頭開始建立 Redis OSS (已啟用叢集模式) 複寫群組 ()AWS CLI

下列程序會使用建立 Redis OSS (已啟用叢集模式) 複寫群組。 AWS CLI

當您從頭開始建立 Redis OSS (已啟用叢集模式) 複寫群組時,只要呼叫命令即可建立複寫群組及其所有節點。 AWS CLI create-replication-group包含以下參數。

--replication-group-id

您要建立的複寫群組名稱。

Redis OSS (已啟用叢集模式) 複寫群組命名條件約束如下:

  • 必須包含 1-40 個英數字元或連字號。

  • 必須以字母開頭。

  • 不能連續包含兩個連字號。

  • 結尾不能是連字號。

--replication-group-description

複寫群組的說明。

--cache-node-type

複寫群組中每個節點的節點類型。

ElastiCache 支持以下節點類型。一般而言,最新一代的節點類型跟前一代相同的節點類型比較起來,能夠以較低的成本提供更多記憶體和運算能力。

如需深入了解每個節點類型的效能詳細資訊,請參閱 Amazon EC2 執行個體類型

--data-tiering-enabled

如果您使用的是 r6gd 節點類型,應設定此參數。如果您不想要資料分層,應設為 --no-data-tiering-enabled。如需詳細資訊,請參閱 資料分層

--cache-parameter-group

指定default.redis6.x.cluster.on參數群組或衍生自的參數群組,default.redis6.x.cluster.on以建立 Redis OSS (已啟用叢集模式) 複寫群組。如需詳細資訊,請參閱 雷迪斯 OSS 6.x 參數更改

--engine

redis

--engine-version

3.2.4

--num-node-groups

此複寫群組中節點群組的數量。有效值為 1 到 500。

注意

節點/碎片的限制可增加至每一叢集 500 個。若要請求增加限制,請參閱 AWS 服務配額,並選取限制類型「每一執行個體類型每一叢集的節點數」。

--replicas-per-node-group

每個節點群組中複本節點的數量。有效值為 0 到 5。

--網路類型

ipv4ipvdual-stack。若您選擇雙堆疊,則必須將 --IpDiscovery 參數設定為 ipv4ipv6

若您希望在此複寫群組上啟用傳輸中及待用加密,請新增 --transit-encryption-enabled--at-rest-encryption-enabled 參數或同時新增兩者,並符合以下條件。

  • 您的複寫群組必須執行 Redis 作業系統 3.2.6 或 4.0.10 版。

  • 複寫群組必須在 Amazon VPC 中建立。

  • 您也必須包含 --cache-subnet-group 參數。

  • 您也必須包含 --auth-token 參數,其中包含在此複寫群組上執行操作時所需要 AUTH 字符 (密碼) 的客戶指定字串值。

下列作業會建立sample-repl-group具有三個節點群組/碎片 (-) 的 Redis OSS (已啟用叢集模式) 複寫群組,每個節點都有三個節點,一個主要和兩個僅供讀取複本 (--num-node-groups)。replicas-per-node-group

若為 Linux、macOS 或 Unix:

aws elasticache create-replication-group \ --replication-group-id sample-repl-group \ --replication-group-description "Demo cluster with replicas" \ --num-node-groups 3 \ --replicas-per-node-group 2 \ --cache-node-type cache.m4.large \ --engine redis \ --security-group-ids SECURITY_GROUP_ID \ --cache-subnet-group-name SUBNET_GROUP_NAME>

針對 Windows:

aws elasticache create-replication-group ^ --replication-group-id sample-repl-group ^ --replication-group-description "Demo cluster with replicas" ^ --num-node-groups 3 ^ --replicas-per-node-group 2 ^ --cache-node-type cache.m4.large ^ --engine redis ^ --security-group-ids SECURITY_GROUP_ID ^ --cache-subnet-group-name SUBNET_GROUP_NAME>

上述命令會產生以下輸出。

{ "ReplicationGroup": { "Status": "creating", "Description": "Demo cluster with replicas", "ReplicationGroupId": "sample-repl-group", "SnapshotRetentionLimit": 0, "AutomaticFailover": "enabled", "SnapshotWindow": "05:30-06:30", "MemberClusters": [ "sample-repl-group-0001-001", "sample-repl-group-0001-002", "sample-repl-group-0001-003", "sample-repl-group-0002-001", "sample-repl-group-0002-002", "sample-repl-group-0002-003", "sample-repl-group-0003-001", "sample-repl-group-0003-002", "sample-repl-group-0003-003" ], "PendingModifiedValues": {} } }

當您從頭開始建立 Redis OSS (已啟用叢集模式) 複寫群組時,您可以使用--node-group-configuration參數來設定叢集中的每個碎片,如下列範例設定兩個節點群組 (主控台:碎片) 所示。第一個碎片有兩個節點:一個主要節點及一個僅供讀取複本。第二個碎片有三個節點:一個主要節點及兩個僅供讀取複本。

--node-group-configuration

每個節點群組的組態。--node-group-configuration 參數由以下欄位組成。

  • PrimaryAvailabilityZone - 此節點群組主節點所在的可用區域。如果省略此參數,請 ElastiCache 選擇主要節點的可用區域。

    範例:us-west-2a。

  • ReplicaAvailabilityZones - 僅供讀取複本所在可用區域的逗點分隔清單。此清單中的可用區域數量必須等於 ReplicaCount 的值。如果省略此參數,請 ElastiCache 選擇複本節點的可用區域。

    範例:"us-west-2a,us-west-2b,us-west-2c"

  • ReplicaCount - 此節點群組中複本節點的數量。

  • Slots - 指定節點群組 Keyspace 的字串。此字串格式為 startKey-endKey。如果省略此參數,則在節點群組之間平均 ElastiCache 分配索引鍵。

    範例:"0-4999"

     

下列作業會建立new-group具有兩個節點群組/碎片 () 的 Redis OSS (已啟用叢集模式) 複寫群組。--num-node-groups與上述範例不同,每個節點群組的設定都會與其他節點群組不同 (--node-group-configuration)。

若為 Linux、macOS 或 Unix:

aws elasticache create-replication-group \ --replication-group-id new-group \ --replication-group-description "Sharded replication group" \ --engine redis \ --snapshot-retention-limit 8 \ --cache-node-type cache.m4.medium \ --num-node-groups 2 \ --node-group-configuration \ "ReplicaCount=1,Slots=0-8999,PrimaryAvailabilityZone='us-east-1c',ReplicaAvailabilityZones='us-east-1b'" \ "ReplicaCount=2,Slots=9000-16383,PrimaryAvailabilityZone='us-east-1a',ReplicaAvailabilityZones='us-east-1a','us-east-1c'"

針對 Windows:

aws elasticache create-replication-group ^ --replication-group-id new-group ^ --replication-group-description "Sharded replication group" ^ --engine redis ^ --snapshot-retention-limit 8 ^ --cache-node-type cache.m4.medium ^ --num-node-groups 2 ^ --node-group-configuration \ "ReplicaCount=1,Slots=0-8999,PrimaryAvailabilityZone='us-east-1c',ReplicaAvailabilityZones='us-east-1b'" \ "ReplicaCount=2,Slots=9000-16383,PrimaryAvailabilityZone='us-east-1a',ReplicaAvailabilityZones='us-east-1a','us-east-1c'"

上述操作會產生以下輸出。

{ "ReplicationGroup": { "Status": "creating", "Description": "Sharded replication group", "ReplicationGroupId": "rc-rg", "SnapshotRetentionLimit": 8, "AutomaticFailover": "enabled", "SnapshotWindow": "10:00-11:00", "MemberClusters": [ "rc-rg-0001-001", "rc-rg-0001-002", "rc-rg-0002-001", "rc-rg-0002-002", "rc-rg-0002-003" ], "PendingModifiedValues": {} } }

如需您可能想要使用的其他資訊和參數,請參閱 AWS CLI 主題create-replication-group。

從頭開始在 Redis OSS (已啟用叢集模式) 中建立複寫群組 (ElastiCache API)

下列程序會使用 API 建立 Redis OSS (已啟用叢集模式) 複寫群組。 ElastiCache

當您從頭開始建立 Redis OSS (已啟用叢集模式) 複寫群組時,只要呼叫 ElastiCache API CreateReplicationGroup 作業即可建立複寫群組及其所有節點。包含以下參數。

ReplicationGroupId

您要建立的複寫群組名稱。

Redis OSS (已啟用叢集模式) 複寫群組命名條件約束如下:

  • 必須包含 1-40 個英數字元或連字號。

  • 必須以字母開頭。

  • 不能連續包含兩個連字號。

  • 結尾不能是連字號。

ReplicationGroupDescription

複寫群組的說明。

NumNodeGroups

您希望和此複寫群組一同建立的節點群組數量。有效值為 1 到 500。

ReplicasPerNodeGroup

每個節點群組中複本節點的數量。有效值為 1 到 5。

NodeGroupConfiguration

每個節點群組的組態。NodeGroupConfiguration 參數由以下欄位組成。

  • PrimaryAvailabilityZone - 此節點群組主節點所在的可用區域。如果省略此參數,請 ElastiCache 選擇主要節點的可用區域。

    範例:us-west-2a。

  • ReplicaAvailabilityZones - 僅供讀取複本所在可用區域的清單。此清單中的可用區域數量必須等於 ReplicaCount 的值。如果省略此參數,請 ElastiCache 選擇複本節點的可用區域。

  • ReplicaCount - 此節點群組中複本節點的數量。

  • Slots - 指定節點群組 Keyspace 的字串。此字串格式為 startKey-endKey。如果省略此參數,則在節點群組之間平均 ElastiCache 分配索引鍵。

    範例:"0-4999"

     

CacheNodeType

複寫群組中每個節點的節點類型。

ElastiCache 支持以下節點類型。一般而言,最新一代的節點類型跟前一代相同的節點類型比較起來,能夠以較低的成本提供更多記憶體和運算能力。

如需深入了解每個節點類型的效能詳細資訊,請參閱 Amazon EC2 執行個體類型

--data-tiering-enabled

如果您使用的是 r6gd 節點類型,應設定此參數。如果您不想要資料分層,應設為 --no-data-tiering-enabled。如需詳細資訊,請參閱 資料分層

CacheParameterGroup

指定default.redis6.x.cluster.on參數群組或衍生自的參數群組,default.redis6.x.cluster.on以建立 Redis OSS (已啟用叢集模式) 複寫群組。如需詳細資訊,請參閱 雷迪斯 OSS 6.x 參數更改

--網路類型

ipv4ipvdual-stack。若您選擇雙堆疊,則必須將 --IpDiscovery 參數設定為 ipv4ipv6

引擎

redis

EngineVersion

6.0

若您希望在此複寫群組上啟用傳輸中及待用加密,請新增 TransitEncryptionEnabled=trueAtRestEncryptionEnabled=true 參數或同時新增兩者,並符合以下條件。

  • 您的複寫群組必須執行 Redis 作業系統 3.2.6 或 4.0.10 版。

  • 複寫群組必須在 Amazon VPC 中建立。

  • 您也必須包含 CacheSubnetGroup 參數。

  • 您也必須包含 AuthToken 參數,其中包含在此複寫群組上執行操作時所需要 AUTH 字符 (密碼) 的客戶指定字串值。

加上分行符號的用意是便於閱讀。

https://elasticache.us-west-2.amazonaws.com/ ?Action=CreateReplicationGroup &CacheNodeType=cache.m4.large &CacheParemeterGroup=default.redis6.xcluster.on &Engine=redis &EngineVersion=6.0 &NumNodeGroups=3 &ReplicasPerNodeGroup=2 &ReplicationGroupDescription=test%20group &ReplicationGroupId=myReplGroup &Version=2015-02-02 &SignatureVersion=4 &SignatureMethod=HmacSHA256 &Timestamp=20150202T192317Z &X-Amz-Credential=<credential>

如需您可能想要使用的其他資訊和參數,請參閱 ElastiCache API 主題CreateReplicationGroup。