使用全域資料存放區 (CLI) - Amazon ElastiCache

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

使用全域資料存放區 (CLI)

您可以使用 AWS Command Line Interface (AWS CLI) 從命令列控制多個 AWS 服務,並透過指令碼將其自動化。您可以使用 AWS CLI 進行臨時 (一次性) 操作。

下載和設定 AWS CLI

AWS CLI 會在 Windows、macOS 或 Linux 上執行。請使用下列程序來下載並進行設定。

若要下載、安裝和設定 CLI
  1. AWS 命令列介面網頁上下載 AWS CLI。

  2. 請遵循 AWS Command Line Interface 使用者指南 CLI AWS 中的安裝 AWS CLI 和設定 的指示。

將 AWS CLI與全域資料存放區搭配使用

使用下列CLI操作來使用全域資料存放區:

  • create-global-replication-group

    aws elasticache create-global-replication-group \ --global-replication-group-id-suffix my global datastore \ --primary-replication-group-id sample-repl-group \ --global-replication-group-description an optional description of the global datastore

    建立 Amazon 時 ElastiCache ,會自動將字首套用至全域資料存放區 ID。每個 AWS 區域都有自己的字首。例如,在美國西部 (加利佛尼亞北部) 區域建立的全域資料儲存 ID 都以 "virxk" 開頭,加上您提供的尾碼名稱。尾碼與自動產生的字首結合,可保證跨多個區域的全域資料存放區名稱保持唯一性。

    下表列出每個 AWS 區域及其全域資料存放區 ID 字首。

    區域名稱/區域 字首

    美國東部 (俄亥俄) 區域

    us-east-2

    fpkhr

    美國東部 (維吉尼亞北部) 區域

    us-east-1

    ldgnf

    美國西部 (加利佛尼亞北部) 區域

    us-west-1

    virxk

    美國西部 (奧勒岡) 區域

    us-west-2

    sgaui

    加拿大 (中部) 區域

    ca-central-1

    bxodz

    亞太 (孟買) 區域

    ap-south-1

    erpgt

    亞太區域 (東京) 區域

    ap-northeast-1

    quwsw

    亞太區域 (首爾) 區域

    ap-northeast-2

    lfqnh

    亞太 (大阪) 區域

    ap-northeast-3

    nlapn

    亞太區域 (新加坡) 區域

    ap-southeast-1

    vlqxn

    亞太區域 (雪梨) 區域

    ap-southeast-2

    vbgxd

    歐洲 (法蘭克福) 區域

    eu-central-1

    iudkw

    歐洲 (愛爾蘭) 區域

    eu-west-1

    gxeiz

    歐洲 (倫敦) 區域

    eu-west-2

    okuqm

    歐洲 (巴黎) 區域

    eu-west-3

    fgjhi

    南美洲 (聖保羅) 區域

    sa-east-1

    juxlw

    中國 (北京) 區域

    cn-north-1

    emvgo

    中國 (寧夏) 區域

    cn-northwest-1

    ckbem

    亞太區域 (香港) 區域

    ap-east-1

    knjmp

    AWS GovCloud (美國西部)

    us-gov-west-1

    sgwui
  • create-replication-group – 使用此操作,透過將全域資料存放區的名稱提供給 --global-replication-group-id 參數,為全域資料存放區建立次要叢集。

    aws elasticache create-replication-group \ --replication-group-id secondary replication group name \ --replication-group-description “Replication group description" \ --global-replication-group-id global datastore name

    呼叫此操作並傳遞--global-replication-group-id值時, ElastiCache 會從全域複寫群組的主要複寫群組推斷下列參數的值。請勿傳入這些參數的值:

    "PrimaryClusterId",

    "AutomaticFailoverEnabled",

    "NumNodeGroups",

    "CacheParameterGroupName",

    "CacheNodeType",

    "Engine",

    "EngineVersion",

    "CacheSecurityGroupNames",

    "EnableTransitEncryption",

    "AtRestEncryptionEnabled",

    "SnapshotArns",

    "SnapshotName"

  • describe-global-replication-groups

    aws elasticache describe-global-replication-groups \ --global-replication-group-id my global datastore \ --show-member-info an optional parameter that returns a list of the primary and secondary clusters that make up the global datastore
  • modify-global-replication-group

    aws elasticache modify-global-replication-group \ --global-replication-group-id my global datastore \ --automatic-failover-enabled \ --cache-node-type node type \ --cache-parameter-group-name parameter group name \ --engine-version engine version \ -—apply-immediately \ --global-replication-group-description description

    Redis 對 OSS Valkey 跨引擎升級 ElastiCache GlobalDataStore

    您可以使用主控台或 將現有的 Redis OSS全域複寫群組升級至 Valkey API 引擎CLI。

    如果您有現有的 Redis OSS全域複寫群組,您可以使用 指定新的引擎和引擎版本 modify-global-replication-group,升級至 ValkeyAPI。

    若為 Linux、macOS 或 Unix:

    aws elasticache modify-global-replication-group \ --global-replication-group-id myGlobalReplGroup \ --engine valkey \ --apply-immediately \ --engine-version 7.2

    針對 Windows:

    aws elasticache modify-global-replication-group ^ --global-replication-group-id myGlobalReplGroup ^ --engine valkey ^ --apply-immediately ^ --engine-version 7.2

    如果您將自訂快取參數群組套用至要升級的現有 Redis OSS全域複寫群組,您也需要在請求中傳遞自訂 Valkey 快取參數群組。輸入 Valkey 自訂參數群組必須與現有的 Redis OSS自訂參數群組具有相同的 Redis OSS 靜態參數值。

    若為 Linux、macOS 或 Unix:

    aws elasticache modify-global-replication-group \ --global-replication-group-id myGlobalReplGroup \ --engine valkey \ --engine-version 7.2 \ --apply-immediately \ --cache-parameter-group-name myParamGroup

    針對 Windows:

    aws elasticache modify-global-replication-group ^ --global-replication-group-id myGlobalReplGroup ^ --engine valkey ^ --engine-version 7.2 ^ --apply-immediately ^ --cache-parameter-group-name myParamGroup
  • delete-global-replication-group

    aws elasticache delete-global-replication-group \ --global-replication-group-id my global datastore \ --retain-primary-replication-group defaults to true
  • disassociate-global-replication-group

    aws elasticache disassociate-global-replication-group \ --global-replication-group-id my global datastore \ --replication-group-id my secondary cluster \ --replication-group-region the AWS Region in which the secondary cluster resides
  • failover-global-replication-group

    aws elasticache failover-replication-group \ --global-replication-group-id my global datastore \ --primary-region The AWS Region of the primary cluster \ --primary-replication-group-id The name of the global datastore, including the suffix.
  • increase-node-groups-in-global-replication-group

    aws elasticache increase-node-groups-in-global-replication-group \ --apply-immediately yes \ --global-replication-group-id global-replication-group-name \ --node-group-count 3
  • decrease-node-groups-in-global-replication-group

    aws elasticache decrease-node-groups-in-global-replication-group \ --apply-immediately yes \ --global-replication-group-id global-replication-group-name \ --node-group-count 3
  • rebalance-shards-in-global-複本-群組

    aws elasticache rebalance-shards-in-global-replication-group \ --apply-immediately yes \ --global-replication-group-id global-replication-group-name

使用 說明來列出 ElastiCache 使用 Valkey 或 Redis 的所有可用命令OSS。

aws elasticache help

您還可以使用說明來描述特定命令,並了解更多關於它的用法:

aws elasticache create-global-replication-group help