使用全局数据存储 () CLI - Amazon ElastiCache
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

使用全局数据存储 () CLI

您可以使用 Amazon Command Line Interface (Amazon CLI) 从命令行控制多项 Amazon 服务,并通过脚本自动执行这些服务。您可以使用 Amazon CLI进行临时(一次性)操作。

正在下载和配置 Amazon CLI

它们可以在 Windows、macOS 或 Linux 上 Amazon CLI 运行。按照以下步骤下载和并对其进行配置。

要下载、安装和配置 CLI
  1. Amazon 命令行界面网页 Amazon CLI上下载。

  2. 按照《Amazon Command Line Interface 用户指南》 Amazon CLI中有关安装 Amazon CLI和配置的说明进行操作。

将 Amazon 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

    创建全球数据存储库 ID 时,Amazon ElastiCache 会自动为其添加前缀。每个 Amazon 区域都有自己的前缀。例如,在美国西部(北加利福尼亚)区域创建的全局数据存储 ID 以“virxk”和您提供的后缀名称开头。后缀与自动生成的前缀相结合,保证了全局数据存储名称在多个区域中的唯一性。

    下表列出了每个 Amazon 区域及其全局数据存储 ID 前缀。

    区域名称/区域 Prefix

    美国东部(俄亥俄州)区域

    us-east-2

    fpkhr

    美国东部(弗吉尼亚州北部)区域

    us-east-1

    ldgnf

    美国西部(北加利福尼亚)区域

    us-west-1

    virxk

    美国西部(俄勒冈州)区域

    us-west-2

    sgaui

    加拿大(中部)区域

    ca-central-1

    bxodz

    亚太地区(孟买)区域

    ap-south-1

    erpgt

    Asia Pacific(Tokyo)Region

    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

    Amazon 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 全局复制组,则可以通过指定新的引擎和引擎版本来升级到 Valkey。 modify-global-replication-group API

    对于 Linux、macOS 或 Unix:

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

    对于 Windows:

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

    如果您对要升级的现有 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 8.0 \ --apply-immediately \ --cache-parameter-group-name myParamGroup

    对于 Windows:

    aws elasticache modify-global-replication-group ^ --global-replication-group-id myGlobalReplGroup ^ --engine valkey ^ --engine-version 8.0 ^ --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 Amazon 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 Amazon 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

使用帮助列出 Valkey 或 Redis OSS 的所有可用命令。 ElastiCache

aws elasticache help

您还可以使用帮助来描述特定命令并了解有关其用法的详细信息:

aws elasticache create-global-replication-group help