記憶體資料庫範例使用 AWS CLI - AWS Command Line Interface

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

記憶體資料庫範例使用 AWS CLI

下列程式碼範例會示範如何使用 AWS Command Line Interface 與 MemoryDB 來執行動作及實作常見案例。

Actions 是大型程式的程式碼摘錄,必須在內容中執行。雖然動作會告訴您如何呼叫個別服務函數,但您可以在其相關情境和跨服務範例中查看內容中的動作。

Scenarios (案例) 是向您展示如何呼叫相同服務中的多個函數來完成特定任務的程式碼範例。

每個範例都包含一個連結 GitHub,您可以在其中找到如何在內容中設定和執行程式碼的指示。

主題

動作

下列程式碼範例會示範如何使用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 使用者指南中的建立子網路群組

下列程式碼範例會示範如何使用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 使用指南》中的刪除子網路群組

下列程式碼範例會示範如何使用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 清單

下列說明 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

若要傳回叢集清單

下列描述叢集 `會傳回叢集清單。

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

若要傳回事件清單

下列描述事件 `會傳回事件清單。

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

若要傳回參數清單

下列描述參數會傳回參數清單。

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 使用者指南中的使用參數群組設定引擎參數

下列程式碼範例會示範如何使用describe-snapshots

AWS CLI

傳回快照清單

下列說明快照 `會傳回快照清單。

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 使用指南中的快照和還原

下列程式碼範例會示範如何使用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

若要傳回使用者清單

下列描述-使用者會傳回使用者清單。

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

容錯移轉碎片

下列容錯移轉共用的容錯移轉會容錯移轉碎片。

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 使用者指南中的使用 MultiAZ 將停機時間最小化

  • 如需 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

若要傳回標籤清單

下面的列表標籤返回標籤的列表。

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

若要標記資源

以下標籤資源 '將標籤添加到資源中。

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 的步驟

下列更新 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

更新叢集

下列更新叢集將叢集的參數群組更新為。 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 使用指南中的子網路和子網路群組

下列程式碼範例會示範如何使用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中的。