使用 AWS CLI 的 MemoryDB 示例 - AWS Command Line Interface

本文档仅适用于 AWS CLI 版本 1。有关 AWS CLI 版本 2 的相关文档,请参阅版本 2 用户指南

使用 AWS CLI 的 MemoryDB 示例

以下代码示例演示了如何通过将 AWS Command Line Interface与 MemoryDB 结合使用,来执行操作和实现常见场景。

操作 是大型程序的代码摘录,必须在上下文中运行。您可以通过操作了解如何调用单个服务函数,还可以通过函数相关场景的上下文查看操作。

每个示例都包含一个指向完整源代码的链接,您可以从中找到有关如何在上下文中设置和运行代码的说明。

主题

操作

以下代码示例演示了如何使用 copy-snapshot

AWS CLI

复制快照

以下 copy-snapshot 示例创建快照的副本。

aws memorydb copy-snapshot \ --source-snapshot-name my-cluster-snapshot \ --target-snapshot-name my-cluster-snapshot-copy

输出

{ "Snapshot": { "Name": "my-cluster-snapshot-copy", "Status": "creating", "Source": "manual", "ARN": "arn:aws:memorydb:us-east-1:491658xxxxxx:snapshot/my-cluster-snapshot-copy", "ClusterConfiguration": { "Name": "my-cluster", "Description": " ", "NodeType": "db.r6g.large", "EngineVersion": "6.2", "MaintenanceWindow": "wed:03:00-wed:04:00", "Port": 6379, "ParameterGroupName": "default.memorydb-redis6", "SubnetGroupName": "my-sg", "VpcId": "vpc-xx2574fc", "SnapshotRetentionLimit": 0, "SnapshotWindow": "04:30-05:30", "NumShards": 2 } } }

有关更多信息,请参阅《MemoryDB 用户指南》中的复制快照

  • 有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 CopySnapshot

以下代码示例演示了如何使用 create-acl

AWS CLI

创建 ACL

以下 create-acl 示例创建新的访问控制列表。

aws memorydb create-acl \ --acl-name "new-acl-1" \ --user-names "my-user"

输出:

{ "ACL": { "Name": "new-acl-1", "Status": "creating", "UserNames": [ "my-user" ], "MinimumEngineVersion": "6.2", "Clusters": [], "ARN": "arn:aws:memorydb:us-east-1:491658xxxxxx:acl/new-acl-1" } }

有关更多信息,请参阅《MemoryDB 用户指南》中的使用访问控制列表对用户进行身份验证

  • 有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 CreateAcl

以下代码示例演示了如何使用 create-cluster

AWS CLI

创建集群

以下 create-cluster 示例创建一个新的集群。

aws memorydb create-cluster \ --cluster-name my-new-cluster \ --node-type db.r6g.large \ --acl-name my-acl \ --subnet-group my-sg

输出:

{ "Cluster": { "Name": "my-new-cluster", "Status": "creating", "NumberOfShards": 1, "AvailabilityMode": "MultiAZ", "ClusterEndpoint": { "Port": 6379 }, "NodeType": "db.r6g.large", "EngineVersion": "6.2", "EnginePatchVersion": "6.2.6", "ParameterGroupName": "default.memorydb-redis6", "ParameterGroupStatus": "in-sync", "SubnetGroupName": "my-sg", "TLSEnabled": true, "ARN": "arn:aws:memorydb:us-east-1:49165xxxxxx:cluster/my-new-cluster", "SnapshotRetentionLimit": 0, "MaintenanceWindow": "sat:10:00-sat:11:00", "SnapshotWindow": "07:30-08:30", "ACLName": "my-acl", "AutoMinorVersionUpgrade": true } }

有关更多信息,请参阅《MemoryDB 用户指南》中的管理集群

  • 有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 CreateCluster

以下代码示例演示了如何使用 create-parameter-group

AWS CLI

创建参数组

以下 create-parameter-group 示例创建一个参数组。

aws memorydb create-parameter-group \ --parameter-group-name myRedis6x \ --family memorydb_redis6 \ --description "my-parameter-group"

输出:

{ "ParameterGroup": { "Name": "myredis6x", "Family": "memorydb_redis6", "Description": "my-parameter-group", "ARN": "arn:aws:memorydb:us-east-1:49165xxxxxx:parametergroup/myredis6x" } }

有关更多信息,请参阅《MemoryDB 用户指南》中的创建参数组

以下代码示例演示了如何使用 create-snapshot

AWS CLI

创建快照

以下 create-snapshot 示例创建快照。

aws memorydb create-snapshot \ --cluster-name my-cluster \ --snapshot-name my-cluster-snapshot

输出:

{ "Snapshot": { "Name": "my-cluster-snapshot1", "Status": "creating", "Source": "manual", "ARN": "arn:aws:memorydb:us-east-1:49165xxxxxx:snapshot/my-cluster-snapshot", "ClusterConfiguration": { "Name": "my-cluster", "Description": "", "NodeType": "db.r6g.large", "EngineVersion": "6.2", "MaintenanceWindow": "wed:03:00-wed:04:00", "Port": 6379, "ParameterGroupName": "default.memorydb-redis6", "SubnetGroupName": "my-sg", "VpcId": "vpc-862xxxxc", "SnapshotRetentionLimit": 0, "SnapshotWindow": "04:30-05:30", "NumShards": 2 } } }

有关更多信息,请参阅《MemoryDB 用户指南》中的生成手动快照

  • 有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 CreateSnapshot

以下代码示例演示了如何使用 create-subnet-group

AWS CLI

创建子网组

以下 create-subnet-group 示例创建一个子网组。

aws memorydb create-subnet-group \ --subnet-group-name mysubnetgroup \ --description "my subnet group" \ --subnet-ids subnet-5623xxxx

输出:

{ "SubnetGroup": { "Name": "mysubnetgroup", "Description": "my subnet group", "VpcId": "vpc-86257xxx", "Subnets": [ { "Identifier": "subnet-5623xxxx", "AvailabilityZone": { "Name": "us-east-1a" } } ], "ARN": "arn:aws:memorydb:us-east-1:491658xxxxxx:subnetgroup/mysubnetgroup" } }

有关更多信息,请参阅《MemoryDB 用户指南》中的创建子网组

  • 有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 CreateSubnetGroup

以下代码示例演示了如何使用 create-user

AWS CLI

创建用户

以下 create-user 示例创建一个新的用户。

aws memorydb create-user \ --user-name user-name-1 \ --access-string "~objects:* ~items:* ~public:*" \ --authentication-mode \ Passwords="enterapasswordhere",Type=password

输出:

{ "User": { "Name": "user-name-1", "Status": "active", "AccessString": "off ~objects:* ~items:* ~public:* resetchannels -@all", "ACLNames": [], "MinimumEngineVersion": "6.2", "Authentication": { "Type": "password", "PasswordCount": 1 }, "ARN": "arn:aws:memorydb:us-west-2:491658xxxxxx:user/user-name-1" } }

有关更多信息,请参阅《MemoryDB 用户指南》中的使用访问控制列表对用户进行身份验证

  • 有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 CreateUser

以下代码示例演示了如何使用 delete-acl

AWS CLI

删除 ACL

以下 delete-acl 示例删除访问控制列表。

aws memorydb delete-acl \ --acl-name "new-acl-1"

输出:

{ "ACL": { "Name": "new-acl-1", "Status": "deleting", "UserNames": [ "pat" ], "MinimumEngineVersion": "6.2", "Clusters": [], "ARN": "arn:aws:memorydb:us-east-1:491658xxxxxx:acl/new-acl-1" } }

有关更多信息,请参阅《MemoryDB 用户指南》中的使用访问控制列表对用户进行身份验证

  • 有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 DeleteAcl

以下代码示例演示了如何使用 delete-cluster

AWS CLI

删除集群

以下 delete-cluster 示例删除集群。

aws memorydb delete-cluster \ --cluster-name my-new-cluster

输出:

{ "Cluster": { "Name": "my-new-cluster", "Status": "deleting", "NumberOfShards": 1, "ClusterEndpoint": { "Address": "clustercfg.my-new-cluster.xxxxx.memorydb.us-east-1.amazonaws.com", "Port": 6379 }, "NodeType": "db.r6g.large", "EngineVersion": "6.2", "EnginePatchVersion": "6.2.6", "ParameterGroupName": "default.memorydb-redis6", "ParameterGroupStatus": "in-sync", "SubnetGroupName": "my-sg", "TLSEnabled": true, "ARN": "arn:aws:memorydb:us-east-1:491658xxxxxx:cluster/my-new-cluster", "SnapshotRetentionLimit": 0, "MaintenanceWindow": "sat:10:00-sat:11:00", "SnapshotWindow": "07:30-08:30", "AutoMinorVersionUpgrade": true } }

有关更多信息,请参阅《MemoryDB 用户指南》中的删除集群

  • 有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 DeleteCluster

以下代码示例演示了如何使用 delete-parameter-group

AWS CLI

删除参数组

以下 delete-parameter-group 示例删除一个参数组。

aws memorydb delete-parameter-group \ --parameter-group-name myRedis6x

输出:

{ "ParameterGroup": { "Name": "myredis6x", "Family": "memorydb_redis6", "Description": "my-parameter-group", "ARN": "arn:aws:memorydb:us-east-1:491658xxxxxx:parametergroup/myredis6x" } }

有关更多信息,请参阅《MemoryDB 用户指南》中的删除参数组

以下代码示例演示了如何使用 delete-snapshot

AWS CLI

删除快照

以下 delete-snapshot 示例删除快照。

aws memorydb delete-snapshot \ --snapshot-name my-cluster-snapshot

输出:

{ "Snapshot": { "Name": "my-cluster-snapshot", "Status": "deleting", "Source": "manual", "ARN": "arn:aws:memorydb:us-east-1:49165xxxxxx:snapshot/my-cluster-snapshot", "ClusterConfiguration": { "Name": "my-cluster", "Description": "", "NodeType": "db.r6g.large", "EngineVersion": "6.2", "MaintenanceWindow": "wed:03:00-wed:04:00", "Port": 6379, "ParameterGroupName": "default.memorydb-redis6", "SubnetGroupName": "my-sg", "VpcId": "vpc-862xxxxc", "SnapshotRetentionLimit": 0, "SnapshotWindow": "04:30-05:30", "NumShards": 2 } } }

有关更多信息,请参阅《MemoryDB 用户指南》中的删除快照

  • 有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 DeleteSnapshot

以下代码示例演示了如何使用 delete-subnet-group

AWS CLI

删除子网组

以下 delete-subnet-group 示例删除子网组。

aws memorydb delete-subnet-group \ --subnet-group-name mysubnetgroup

输出:

{ "SubnetGroup": { "Name": "mysubnetgroup", "Description": "my subnet group", "VpcId": "vpc-86xxxx4fc", "Subnets": [ { "Identifier": "subnet-56xxx61b", "AvailabilityZone": { "Name": "us-east-1a" } } ], "ARN": "arn:aws:memorydb:us-east-1:491658xxxxxx:subnetgroup/mysubnetgroup" } }

有关更多信息,请参阅《MemoryDB 用户指南》中的删除子网组

  • 有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 DeleteSubnetGroup

以下代码示例演示了如何使用 delete-user

AWS CLI

删除用户

以下 delete-user 示例删除用户。

aws memorydb delete-user \ --user-name my-user

输出:

{ "User": { "Name": "my-user", "Status": "deleting", "AccessString": "on ~app::* resetchannels -@all +@read", "ACLNames": [ "my-acl" ], "MinimumEngineVersion": "6.2", "Authentication": { "Type": "password", "PasswordCount": 1 }, "ARN": "arn:aws:memorydb:us-east-1:491658xxxxxx:user/my-user" } }

有关更多信息,请参阅《MemoryDB 用户指南》中的使用访问控制列表对用户进行身份验证

  • 有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 DeleteUser

以下代码示例演示了如何使用 describe-acls

AWS CLI

返回 ACL 列表

以下 describe-acls 命令返回 ACL 列表。

aws memorydb describe-acls

输出:

{ "ACLs": [ { "Name": "open-access", "Status": "active", "UserNames": [ "default" ], "MinimumEngineVersion": "6.2", "Clusters": [], "ARN": "arn:aws:memorydb:us-east-1:491658xxxxxx:acl/open-access" }, { "Name": my-acl", "Status": "active", "UserNames": [], "MinimumEngineVersion": "6.2", "Clusters": [ "my-cluster" ], "ARN": "arn:aws:memorydb:us-east-1:49165xxxxxxx:acl/my-acl" } ] }

有关更多信息,请参阅《MemoryDB 用户指南》中的使用访问控制列表对用户进行身份验证

  • 有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 DescribeAcls

以下代码示例演示了如何使用 describe-clusters

AWS CLI

返回集群列表

以下 describe-clusters 命令返回集群的列表。

aws memorydb describe-clusters

输出:

{ "Clusters": [ { "Name": "my-cluster", "Status": "available", "NumberOfShards": 2, "ClusterEndpoint": { "Address": "clustercfg.my-cluster.llru6f.memorydb.us-east-1.amazonaws.com", "Port": 6379 }, "NodeType": "db.r6g.large", "EngineVersion": "6.2", "EnginePatchVersion": "6.2.6", "ParameterGroupName": "default.memorydb-redis6", "ParameterGroupStatus": "in-sync", "SecurityGroups": [ { "SecurityGroupId": "sg-0a1434xxxxxc9fae", "Status": "active" } ], "SubnetGroupName": "pat-sg", "TLSEnabled": true, "ARN": "arn:aws:memorydb:us-east-1:49165xxxxxx:cluster/my-cluster", "SnapshotRetentionLimit": 0, "MaintenanceWindow": "wed:03:00-wed:04:00", "SnapshotWindow": "04:30-05:30", "ACLName": "my-acl", "AutoMinorVersionUpgrade": true } ] }

有关更多信息,请参阅《MemoryDB 用户指南》中的管理集群

  • 有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 DescribeClusters

以下代码示例演示了如何使用 describe-engine-versions

AWS CLI

返回引擎版本列表

以下 describe-engine-versions 命令返回引擎版本列表。

aws memorydb describe-engine-versions

输出:

{ "EngineVersions": [ { "EngineVersion": "6.2", "EnginePatchVersion": "6.2.6", "ParameterGroupFamily": "memorydb_redis6" } ] }

有关更多信息,请参阅《MemoryDB 用户指南》中的引擎版本和升级

以下代码示例演示了如何使用 describe-events

AWS CLI

返回事件列表

以下 describe-events 命令返回事件列表。

aws memorydb describe-events

输出:

{ "Events": [ { "SourceName": "my-cluster", "SourceType": "cluster", "Message": "Increase replica count started for replication group my-cluster on 2022-07-22T14:09:01.440Z", "Date": "2022-07-22T07:09:01.443000-07:00" }, { "SourceName": "my-user", "SourceType": "user", "Message": "Create user my-user operation completed.", "Date": "2022-07-22T07:00:02.975000-07:00" } ] }

有关更多信息,请参阅《MemoryDB 用户指南》中的监控事件

  • 有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 DescribeEvents

以下代码示例演示了如何使用 describe-parameter-groups

AWS CLI

返回参数组列表

以下 describe-parameter-groups 返回参数组列表。

aws memorydb describe-parameter-groups

输出:

{ "ParameterGroups": [ { "Name": "default.memorydb-redis6", "Family": "memorydb_redis6", "Description": "Default parameter group for memorydb_redis6", "ARN": "arn:aws:memorydb:us-east-1:491658xxxxxx:parametergroup/default.memorydb-redis6" } ] }

有关更多信息,请参阅《MemoryDB 用户指南》中的使用参数组配置引擎参数

以下代码示例演示了如何使用 describe-parameters

AWS CLI

返回参数列表

以下 describe-parameters 返回参数列表。

aws memorydb describe-parameters

输出:

{ "Parameters": [ { "Name": "acllog-max-len", "Value": "128", "Description": "The maximum length of the ACL Log", "DataType": "integer", "AllowedValues": "1-10000", "MinimumEngineVersion": "6.2.4" }, { "Name": "activedefrag", "Value": "no", "Description": "Enabled active memory defragmentation", "DataType": "string", "AllowedValues": "yes,no", "MinimumEngineVersion": "6.2.4" }, { "Name": "active-defrag-cycle-max", "Value": "75", "Description": "Maximal effort for defrag in CPU percentage", "DataType": "integer", "AllowedValues": "1-75", "MinimumEngineVersion": "6.2.4" }, { "Name": "active-defrag-cycle-min", "Value": "5", "Description": "Minimal effort for defrag in CPU percentage", "DataType": "integer", "AllowedValues": "1-75", "MinimumEngineVersion": "6.2.4" }, { "Name": "active-defrag-ignore-bytes", "Value": "104857600", "Description": "Minimum amount of fragmentation waste to start active defrag", "DataType": "integer", "AllowedValues": "1048576-", "MinimumEngineVersion": "6.2.4" }, { "Name": "active-defrag-max-scan-fields", "Value": "1000", "Description": "Maximum number of set/hash/zset/list fields that will be processed from the main dictionary scan", "DataType": "integer", "AllowedValues": "1-1000000", "MinimumEngineVersion": "6.2.4" }, { "Name": "active-defrag-threshold-lower", "Value": "10", "Description": "Minimum percentage of fragmentation to start active defrag", "DataType": "integer", "AllowedValues": "1-100", "MinimumEngineVersion": "6.2.4" }, { "Name": "active-defrag-threshold-upper", "Value": "100", "Description": "Maximum percentage of fragmentation at which we use maximum effort", "DataType": "integer", "AllowedValues": "1-100", "MinimumEngineVersion": "6.2.4" }, { "Name": "active-expire-effort", "Value": "1", "Description": "The amount of effort that redis uses to expire items in the active expiration job", "DataType": "integer", "AllowedValues": "1-10", "MinimumEngineVersion": "6.2.4" }, { "Name": "activerehashing", "Value": "yes", "Description": "Apply rehashing or not", "DataType": "string", "AllowedValues": "yes,no", "MinimumEngineVersion": "6.2.4" }, { "Name": "client-output-buffer-limit-normal-hard-limit", "Value": "0", "Description": "Normal client output buffer hard limit in bytes", "DataType": "integer", "AllowedValues": "0-", "MinimumEngineVersion": "6.2.4" }, { "Name": "client-output-buffer-limit-normal-soft-limit", "Value": "0", "Description": "Normal client output buffer soft limit in bytes", "DataType": "integer", "AllowedValues": "0-", "MinimumEngineVersion": "6.2.4" }, { "Name": "client-output-buffer-limit-normal-soft-seconds", "Value": "0", "Description": "Normal client output buffer soft limit in seconds", "DataType": "integer", "AllowedValues": "0-", "MinimumEngineVersion": "6.2.4" }, { "Name": "client-output-buffer-limit-pubsub-hard-limit", "Value": "33554432", "Description": "Pubsub client output buffer hard limit in bytes", "DataType": "integer", "AllowedValues": "0-", "MinimumEngineVersion": "6.2.4" }, { "Name": "client-output-buffer-limit-pubsub-soft-limit", "Value": "8388608", "Description": "Pubsub client output buffer soft limit in bytes", "DataType": "integer", "AllowedValues": "0-", "MinimumEngineVersion": "6.2.4" }, { "Name": "client-output-buffer-limit-pubsub-soft-seconds", "Value": "60", "Description": "Pubsub client output buffer soft limit in seconds", "DataType": "integer", "AllowedValues": "0-", "MinimumEngineVersion": "6.2.4" }, { "Name": "hash-max-ziplist-entries", "Value": "512", "Description": "The maximum number of hash entries in order for the dataset to be compressed", "DataType": "integer", "AllowedValues": "0-", "MinimumEngineVersion": "6.2.4" }, { "Name": "hash-max-ziplist-value", "Value": "64", "Description": "The threshold of biggest hash entries in order for the dataset to be compressed", "DataType": "integer", "AllowedValues": "0-", "MinimumEngineVersion": "6.2.4" }, { "Name": "hll-sparse-max-bytes", "Value": "3000", "Description": "HyperLogLog sparse representation bytes limit", "DataType": "integer", "AllowedValues": "1-16000", "MinimumEngineVersion": "6.2.4" }, { "Name": "lazyfree-lazy-eviction", "Value": "no", "Description": "Perform an asynchronous delete on evictions", "DataType": "string", "AllowedValues": "yes,no", "MinimumEngineVersion": "6.2.4" }, { "Name": "lazyfree-lazy-expire", "Value": "no", "Description": "Perform an asynchronous delete on expired keys", "DataType": "string", "AllowedValues": "yes,no", "MinimumEngineVersion": "6.2.4" }, { "Name": "lazyfree-lazy-server-del", "Value": "no", "Description": "Perform an asynchronous delete on key updates", "DataType": "string", "AllowedValues": "yes,no", "MinimumEngineVersion": "6.2.4" }, { "Name": "lazyfree-lazy-user-del", "Value": "no", "Description": "Specifies whether the default behavior of DEL command acts the same as UNLINK", "DataType": "string", "AllowedValues": "yes,no", "MinimumEngineVersion": "6.2.4" }, { "Name": "lfu-decay-time", "Value": "1", "Description": "The amount of time in minutes to decrement the key counter for LFU eviction policyd", "DataType": "integer", "AllowedValues": "0-", "MinimumEngineVersion": "6.2.4" }, { "Name": "lfu-log-factor", "Value": "10", "Description": "The log factor for incrementing key counter for LFU eviction policy", "DataType": "integer", "AllowedValues": "1-", "MinimumEngineVersion": "6.2.4" }, { "Name": "list-compress-depth", "Value": "0", "Description": "Number of quicklist ziplist nodes from each side of the list to exclude from compression. The head and tail of the list are always uncompressed for fast push/pop operations", "DataType": "integer", "AllowedValues": "0-", "MinimumEngineVersion": "6.2.4" }, { "Name": "maxmemory-policy", "Value": "noeviction", "Description": "Max memory policy", "DataType": "string", "AllowedValues": "volatile-lru,allkeys-lru,volatile-lfu,allkeys-lfu,volatile-random,allkeys-random,volatile-ttl,noeviction", "MinimumEngineVersion": "6.2.4" }, { "Name": "maxmemory-samples", "Value": "3", "Description": "Max memory samples", "DataType": "integer", "AllowedValues": "1-", "MinimumEngineVersion": "6.2.4" }, { "Name": "notify-keyspace-events", "Description": "The keyspace events for Redis to notify Pub/Sub clients about. By default all notifications are disabled", "DataType": "string", "MinimumEngineVersion": "6.2.4" }, { "Name": "set-max-intset-entries", "Value": "512", "Description": "The limit in the size of the set in order for the dataset to be compressed", "DataType": "integer", "AllowedValues": "0-", "MinimumEngineVersion": "6.2.4" }, { "Name": "slowlog-log-slower-than", "Value": "10000", "Description": "The execution time, in microseconds, to exceed in order for the command to get logged. Note that a negative number disables the slow log, while a value of zero forces the logging of every command", "DataType": "integer", "AllowedValues": "-", "MinimumEngineVersion": "6.2.4" }, { "Name": "slowlog-max-len", "Value": "128", "Description": "The length of the slow log. There is no limit to this length. Just be aware that it will consume memory. You can reclaim memory used by the slow log with SLOWLOG RESET.", "DataType": "integer", "AllowedValues": "0-", "MinimumEngineVersion": "6.2.4" }, { "Name": "stream-node-max-bytes", "Value": "4096", "Description": "The maximum size of a single node in a stream in bytes", "DataType": "integer", "AllowedValues": "0-", "MinimumEngineVersion": "6.2.4" }, { "Name": "stream-node-max-entries", "Value": "100", "Description": "The maximum number of items a single node in a stream can contain", "DataType": "integer", "AllowedValues": "0-", "MinimumEngineVersion": "6.2.4" }, { "Name": "tcp-keepalive", "Value": "300", "Description": "If non-zero, send ACKs every given number of seconds", "DataType": "integer", "AllowedValues": "0-", "MinimumEngineVersion": "6.2.4" }, { "Name": "timeout", "Value": "0", "Description": "Close connection if client is idle for a given number of seconds, or never if 0", "DataType": "integer", "AllowedValues": "0,20-", "MinimumEngineVersion": "6.2.4" }, { "Name": "tracking-table-max-keys", "Value": "1000000", "Description": "The maximum number of keys allowed for the tracking table for client side caching", "DataType": "integer", "AllowedValues": "1-100000000", "MinimumEngineVersion": "6.2.4" }, { "Name": "zset-max-ziplist-entries", "Value": "128", "Description": "The maximum number of sorted set entries in order for the dataset to be compressed", "DataType": "integer", "AllowedValues": "0-", "MinimumEngineVersion": "6.2.4" }, { "Name": "zset-max-ziplist-value", "Value": "64", "Description": "The threshold of biggest sorted set entries in order for the dataset to be compressed", "DataType": "integer", "AllowedValues": "0-", "MinimumEngineVersion": "6.2.4" } ] }

有关更多信息,请参阅《MemoryDB 用户指南》中的使用参数组配置引擎参数

  • 有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 DescribeParameters

以下代码示例演示了如何使用 describe-snapshots

AWS CLI

返回快照列表

以下 describe-snapshots 命令返回快照列表。

aws memorydb describe-snapshots

输出:

{ "Snapshots": [ { "Name": "my-cluster-snapshot", "Status": "available", "Source": "manual", "ARN": "arn:aws:memorydb:us-east-1:491658xxxxxx2:snapshot/my-cluster-snapshot", "ClusterConfiguration": { "Name": "my-cluster", "Description": " ", "NodeType": "db.r6g.large", "EngineVersion": "6.2", "MaintenanceWindow": "wed:03:00-wed:04:00", "Port": 6379, "ParameterGroupName": "default.memorydb-redis6", "SubnetGroupName": "my-sg", "VpcId": "vpc-862574fc", "SnapshotRetentionLimit": 0, "SnapshotWindow": "04:30-05:30", "NumShards": 2 } } }

有关更多信息,请参阅《MemoryDB 用户指南》中的快照和恢复

  • 有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 DescribeSnapshots

以下代码示例演示了如何使用 describe-subnet-groups

AWS CLI

返回子网组列表

以下 describe-subnet-groups 命令返回子网组列表。

aws memorydb describe-subnet-groups

输出

{ "SubnetGroups": [ { "Name": "my-sg", "Description": "pat-sg", "VpcId": "vpc-86xxx4fc", "Subnets": [ { "Identifier": "subnet-faxx84a6", "AvailabilityZone": { "Name": "us-east-1b" } }, { "Identifier": "subnet-56xxf61b", "AvailabilityZone": { "Name": "us-east-1a" } } ], "ARN": "arn:aws:memorydb:us-east-1:49165xxxxxx:subnetgroup/my-sg" } ] }

有关更多信息,请参阅《MemoryDB 用户指南》中的子网和子网组

以下代码示例演示了如何使用 describe-users

AWS CLI

返回用户列表

以下 describe-users 命令返回用户的列表。

aws memorydb describe-users

输出

{ "Users": [ { "Name": "default", "Status": "active", "AccessString": "on ~* &* +@all", "ACLNames": [ "open-access" ], "MinimumEngineVersion": "6.0", "Authentication": { "Type": "no-password" }, "ARN": "arn:aws:memorydb:us-east-1:491658xxxxxx:user/default" }, { "Name": "my-user", "Status": "active", "AccessString": "off ~objects:* ~items:* ~public:* resetchannels -@all", "ACLNames": [], "MinimumEngineVersion": "6.2", "Authentication": { "Type": "password", "PasswordCount": 2 }, "ARN": "arn:aws:memorydb:us-east-1:491658xxxxxx:user/my-user" } ] }

有关更多信息,请参阅《MemoryDB 用户指南》中的使用访问控制列表对用户进行身份验证

  • 有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 DescribeUsers

以下代码示例演示了如何使用 failover-shard

AWS CLI

转移失效分片

以下 failover-shard 命令对分片进行失效转移。

aws memorydb failover-shard \ --cluster-name my-cluster --shard-name 0001

输出:

{ "Cluster": { "Name": "my-cluster", "Status": "available", "NumberOfShards": 2, "ClusterEndpoint": { "Address": "clustercfg.my-cluster.xxxxxx.memorydb.us-east-1.amazonaws.com", "Port": 6379 }, "NodeType": "db.r6g.large", "EngineVersion": "6.2", "EnginePatchVersion": "6.2.6", "ParameterGroupName": "default.memorydb-redis6", "ParameterGroupStatus": "in-sync", "SecurityGroups": [ { "SecurityGroupId": "sg-0a143xxxx45c9fae", "Status": "active" } ], "SubnetGroupName": "my-sg", "TLSEnabled": true, "ARN": "arn:aws:memorydb:us-east-1:491658xxxxxx:cluster/my-cluster", "SnapshotRetentionLimit": 0, "MaintenanceWindow": "wed:03:00-wed:04:00", "SnapshotWindow": "04:30-05:30", "AutoMinorVersionUpgrade": true } }

有关更多信息,请参阅《MemoryDB 用户指南》中的通过多可用区最大程度地减少停机时间

  • 有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 FailoverShard

以下代码示例演示了如何使用 list-allowed-node-type-updates

AWS CLI

返回允许的节点类型更新的列表

以下 list-allowed-node-type-updates 返回可用节点类型更新的列表。

aws memorydb list-allowed-node-type-updates

输出:

{ "Cluster": { "Name": "my-cluster", "Status": "available", "NumberOfShards": 2, "ClusterEndpoint": { "Address": "clustercfg.my-cluster.xxxxxx.memorydb.us-east-1.amazonaws.com", "Port": 6379 }, "NodeType": "db.r6g.large", "EngineVersion": "6.2", "EnginePatchVersion": "6.2.6", "ParameterGroupName": "default.memorydb-redis6", "ParameterGroupStatus": "in-sync", "SecurityGroups": [ { "SecurityGroupId": "sg-0a143xxxx45c9fae", "Status": "active" } ], "SubnetGroupName": "my-sg", "TLSEnabled": true, "ARN": "arn:aws:memorydb:us-east-1:491658xxxxxx:cluster/my-cluster", "SnapshotRetentionLimit": 0, "MaintenanceWindow": "wed:03:00-wed:04:00", "SnapshotWindow": "04:30-05:30", "AutoMinorVersionUpgrade": true } }

有关更多信息,请参阅《MemoryDB 用户指南》中的扩展

以下代码示例演示了如何使用 list-tags

AWS CLI

返回标签列表

以下 list-tags 命令返回标签列表。

aws memorydb list-tags \ --resource-arn arn:aws:memorydb:us-east-1:491658xxxxxx:cluster/my-cluster

输出:

{ "TagList": [ { "Key": "mytag", "Value": "myvalue" } ] }

有关更多信息,请参阅《MemoryDB 用户指南》中的标记资源

  • 有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 ListTags

以下代码示例演示了如何使用 reset-parameter-group

AWS CLI

重置参数组

以下 reset-parameter-group 命令重置参数组。

aws memorydb reset-parameter-group \ --parameter-group-name my-parameter-group \ --all-parameters

输出:

{ "ParameterGroup": { "Name": "my-parameter-group", "Family": "memorydb_redis6", "Description": "my parameter group", "ARN": "arn:aws:memorydb:us-east-1:491658xxxxxx:parametergroup/my-parameter-group" } }

有关更多信息,请参阅《MemoryDB 用户指南》中的使用参数组配置引擎参数

以下代码示例演示了如何使用 tag-resource

AWS CLI

标记资源

以下 tag-resource 命令将标签添加到资源中。

aws memorydb tag-resource \ --resource-arn arn:aws:memorydb:us-east-1:491658xxxxxx:cluster/my-cluster \ --tags Key="mykey",Value="myvalue"

输出:

{ "TagList": [ { "Key": "mytag", "Value": "myvalue" }, { "Key": "mykey", "Value": "myvalue" } ] }

有关更多信息,请参阅《MemoryDB 用户指南》中的标记资源

  • 有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 TagResource

以下代码示例演示了如何使用 untag-resource

AWS CLI

更新 ACL

以下 update-acl 通过添加用户来更新 ACL。

aws memorydb untag-resource \ --resource-arn arn:aws:memorydb:us-east-1:491658xxxxx:cluster/my-cluster \ --tag-keys mykey

输出:

{ "TagList": [ { "Key": "mytag", "Value": "myvalue" } ] }

有关更多信息,请参阅《MemoryDB 用户指南》中的标记资源

  • 有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 UntagResource

以下代码示例演示了如何使用 update-cluster

AWS CLI

更新集群

以下 update-cluster 命令将集群的参数组更新为 my-parameter-group。

aws memorydb update-cluster \ --cluster-name my-cluster \ --parameter-group-name my-parameter-group

输出:

{ "Cluster": { "Name": "my-cluster", "Status": "available", "NumberOfShards": 2, "AvailabilityMode": "MultiAZ", "ClusterEndpoint": { "Address": "clustercfg.my-cluster.llru6f.memorydb.us-east-1.amazonaws.com", "Port": 6379 }, "NodeType": "db.r6g.large", "EngineVersion": "6.2", "EnginePatchVersion": "6.2.6", "ParameterGroupName": "my-parameter-group", "ParameterGroupStatus": "in-sync", "SecurityGroups": [ { "SecurityGroupId": "sg-0a143xxxxxc9fae", "Status": "active" } ], "SubnetGroupName": "pat-sg", "TLSEnabled": true, "ARN": "arn:aws:memorydb:us-east-1:491658xxxxxx:cluster/my-cluster", "SnapshotRetentionLimit": 0, "MaintenanceWindow": "wed:03:00-wed:04:00", "SnapshotWindow": "04:30-05:30", "ACLName": "my-acl", "AutoMinorVersionUpgrade": true } }

有关更多信息,请参阅《MemoryDB 用户指南》中的修改集群

  • 有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 UpdateCluster

以下代码示例演示了如何使用 update-parameter-group

AWS CLI

更新参数组

以下 update-parameter-group 更新一个参数组。

aws memorydb update-parameter-group \ --parameter-group-name my-parameter-group \ --parameter-name-values "ParameterName=activedefrag, ParameterValue=no"

输出:

{ "ParameterGroup": { "Name": "my-parameter-group", "Family": "memorydb_redis6", "Description": "my parameter group", "ARN": "arn:aws:memorydb:us-east-1:49165xxxxxx:parametergroup/my-parameter-group" } }

有关更多信息,请参阅《MemoryDB 用户指南》中的修改参数组

以下代码示例演示了如何使用 update-subnet-group

AWS CLI

更新子网组

以下 update-subnet-group 命令更新子网组的子网 ID。

aws memorydb update-subnet-group \ --subnet-group-name my-sg \ --subnet-ids subnet-01f29d458f3xxxxx

输出:

{ "SubnetGroup": { "Name": "my-sg-1", "Description": "my-sg", "VpcId": "vpc-09d2cfc01xxxxxxx", "Subnets": [ { "Identifier": "subnet-01f29d458fxxxxxx", "AvailabilityZone": { "Name": "us-east-1a" } } ], "ARN": "arn:aws:memorydb:us-east-1:491658xxxxxx:subnetgroup/my-sg" } }

有关更多信息,请参阅《MemoryDB 用户指南》中的子网和子网组

  • 有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 UpdateSubnetGroup

以下代码示例演示了如何使用 update-user

AWS CLI

更新用户

以下 update-user 命令修改用户的访问字符串。

aws memorydb update-user \ --user-name my-user \ --access-string "off ~objects:* ~items:* ~public:* resetchannels -@all"

输出:

{ "User": { "Name": "my-user", "Status": "modifying", "AccessString": "off ~objects:* ~items:* ~public:* resetchannels -@all", "ACLNames": [ "myt-acl" ], "MinimumEngineVersion": "6.2", "Authentication": { "Type": "password", "PasswordCount": 2 }, "ARN": "arn:aws:memorydb:us-east-1:491658xxxxxx:user/my-user" } }

有关更多信息,请参阅《MemoryDB 用户指南》中的使用访问控制列表对用户进行身份验证

  • 有关 API 详细信息,请参阅《AWS CLI 命令参考》中的 UpdateUser