配置实例

Memorystore for Valkey 支持一部分 OSS Valkey 配置参数,您可以修改这些参数来自定义实例的行为。

配置更改无需重启节点,如果节点重启,则保存这些更改。创建实例后,您可以更新可修改的配置参数。

如需详细了解可修改的配置参数,请参阅受支持的实例配置

准备工作

运行 gcloud components update 以确保您已安装最新版本的 Google Cloud CLI。

查看配置参数

如需使用 Google Cloud CLI 查看配置参数,请运行 gcloud memorystore instances describe 命令,并将 variables 替换为适当的值。

除非您已对配置参数的默认值进行了更改,否则在运行 gcloud memorystore instances describe 命令时不会看到配置参数。

gcloud memorystore instances describe instance-id --location=region-id

示例:

gcloud memorystore instances describe my-instance --location=us-central1

在创建实例期间设置配置参数

如需在创建实例时设置配置参数,请运行带有 --engine-configs 标志的 gcloud memorystore instances create 命令,并将 variables 替换为适当的值。

gcloud memorystore instances create instance-id \
--location=region-id \
--project=project-id \
--node-type=node-type \
--shard-count=shard-count \
--mode=MODE
--engine-configs=config-name=config-value \

替换以下内容:

  • instance-id 是您要创建的 Memorystore for Valkey 实例的 ID。
  • region-id 是您要将实例放置在其中的区域。
  • project-id 是项目 ID。
  • node-type 是您选择的节点类型。接受的值包括:

    • shared-core-nano
    • standard-small
    • highmem-medium
    • highmem-xlarge

    如需详细了解节点类型和实例配置,请参阅实例和节点规范

  • shard-count 用于确定实例中的分片数量。分片数决定了用于存储实例数据的总内存容量。如果您选择的模式为“已停用集群模式”,则只能为实例指定一个分片。如需了解详情,请参阅实例和节点规范

  • mode 用于确定实例是启用集群模式还是停用集群模式。如果省略此字段,则实例默认处于“集群模式已启用”状态。如需了解详情,请参阅启用和停用集群模式

  • config-name 是要修改的配置参数。

  • config-value 是您选择的与要配置的参数对应的设置。

例如:

已启用集群模式示例

  gcloud memorystore instances create foo --location=us-east1 --project=test-proj --node-type=highmem-medium --shard-count=3 --engine-configs=maxmemory-policy=allkeys-lru
  

集群模式已停用示例

  gcloud memorystore instances create foo --location=us-east1 --project=test-proj --node-type=highmem-medium --shard-count=1 --mode=cluster-disabled --engine-configs=maxmemory-policy=allkeys-lru
  

更新配置参数

如需更新现有实例的配置参数,请运行带有 --update-engine-configs 标志的 gcloud memorystore instances update 命令,并将 variables 替换为适当的值。

gcloud memorystore instances update instance-id \
--location=region-id \
--project=project-id \
--update-engine-configs=config-name=config-value

示例:

gcloud memorystore instances update foo --location=us-east1 --project=test-proj --update-engine-configs=maxmemory-policy=allkeys-lru

重置配置参数

如需将配置参数重置为默认值,请运行带有 --remove-engine-configs 标志的 gcloud memorystore instances update 命令,并将 variables 替换为适当的值。

gcloud memorystore instances update instance-id \
--location=region-id \
--project=project-id \
--remove-engine-configs=config-name

示例:

gcloud memorystore instances update foo --location=us-east1 --project=test-proj --remove-engine-configs=maxmemory-policy

清除配置参数

如需将所有配置参数恢复为其默认值,请运行带有 --clear-engine-configs 标志的 gcloud memorystore instances update 命令,并将 variables 替换为适当的值。

gcloud memorystore instances update instance-id \
--location=region-id \
--project=project-id \
--clear-engine-configs

示例:

gcloud memorystore instances update foo --location=us-east1 --project=test-proj --clear-engine-configs