本页面介绍了如何扩缩 Memorystore for Valkey 实例。实例的容量由实例中的分片数量和实例的节点类型决定。如需扩缩实例,您必须更改分片数量或节点类型。如需详细了解实例在伸缩期间的行为,请参阅关于伸缩实例容量。
扩缩和双可用区部署
如果您通过向实例添加分片或副本来扩缩实例,而可用区遇到资源限制,则 Memorystore for Valkey 会自动跨两个可用区部署实例。此部署可确保您的实例成功扩缩。如需详细了解此类部署,请参阅双可用区部署,实现高可用性和弹性。
扩缩分片数
您可以使用 Google Cloud 控制台或 Google Cloud CLI 增加或减少实例的分片数量。
控制台
在 Google Cloud 控制台中,前往 Memorystore for Valkey 页面。
点击您的实例 ID。
在配置部分中,点击分片旁边的铅笔图标。
在分片字段中,输入要将实例扩缩到的分片数量。
点击更新实例。
gcloud
如需扩缩实例的分片数量,请使用 gcloud memorystore instances update 命令:
gcloud memorystore instances update INSTANCE_ID \ --location=REGION_ID \ --shard-count=SHARD_COUNT
替换以下内容:
- INSTANCE_ID:实例的 ID。
- REGION_ID:实例所在的区域。
- SHARD_COUNT:实例中的分片数量。分片数量决定了用于存储实例数据的总内存容量。如需详细了解 Memorystore for Valkey 实例的实例和节点规范,请参阅实例和节点规范。
例如:
gcloud memorystore instances update my-instance \ --location=us-central1 \ --shard-count=8
扩缩节点类型
您可以使用 Google Cloud CLI 扩缩实例的节点类型。
gcloud
如需检索实例的相关信息,请使用
gcloud memorystore instances describe命令:gcloud memorystore instances describe INSTANCE_ID \ --location=REGION_ID
替换以下内容:
- INSTANCE_ID:实例的 ID
- REGION_ID:实例所在的区域(例如
us-central1)
检查输出,看看是否存在以下情况:
输出包含
engineConfigs部分。maxmemory-clients、maxmemory或maxclients参数会显示在此部分中。
如果出现上述任何参数,则在扩缩实例的节点类型时,您必须扩缩这些参数的值,以反映 Memorystore for Valkey 可接受的扩缩后节点类型的值。如需了解详情,请参阅可修改的配置参数。
如需扩缩节点类型,请使用
gcloud memorystore instances update命令:gcloud memorystore instances update INSTANCE_ID \ --location=REGION_ID \ --node-type=NODE_TYPE
替换以下内容:
- INSTANCE_ID:实例的 ID。
- REGION_ID:实例所在的区域。
NODE_TYPE:要将实例扩缩到的节点类型。
在此示例中,您将
my-instance实例的节点类型扩缩为highmem-medium。此实例位于us-central1区域。gcloud memorystore instances update my-instance \ --location=us-central1 \ --node-type=highmem-medium
在此示例中,您需要将
maxclients参数的值更改为15,000。gcloud memorystore instances update my-instance \ --location=us-central1 \ --node-type=highmem-medium \ --update-engine-configs=maxclients=15000