本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
連線至 Valkey 或 Redis OSS 叢集中的節點
注意
目前,支援複寫和僅供讀取複本的叢集 (API/CLI:複寫群組) 僅支援執行 Valkey 或 Redis OSS 的叢集。
針對叢集,ElastiCache 提供主控台、CLI 及 API 界面來取得個別節點的連線資訊。
針對唯讀活動,應用程式可連線到叢集中的任何節點。不過,對於寫入活動,我們建議您的應用程式連接到叢集的主要端點 (Valkey 或 Redis OSS (停用叢集模式)) 或組態端點 (Valkey 或 Redis OSS (啟用叢集模式)),而不是直接連接到節點。這可確保您的應用程式總能找到正確的節點,即使您決定透過將僅供讀取複本提升到主要角色來重新設定叢集也一樣。
連線到複寫群組中的叢集 (主控台)
判斷端點和連接埠號碼
連線到複寫群組中的叢集 (AWS CLI)
判斷快取節點端點和連接埠號碼
搭配您複寫群組的名稱,使用 describe-replication-groups 命令:
aws elasticache describe-replication-groupsredis2x2
此命令應該產生類似下列的輸出:
{
    "ReplicationGroups": [
        {
            "Status": "available", 
            "Description": "2 shards, 2 nodes (1 + 1 replica)", 
            "NodeGroups": [
                {
                    "Status": "available", 
                    "Slots": "0-8191", 
                    "NodeGroupId": "0001", 
                    "NodeGroupMembers": [
                        {
                            "PreferredAvailabilityZone": "us-west-2c", 
                            "CacheNodeId": "0001", 
                            "CacheClusterId": "redis2x2-0001-001"
                        }, 
                        {
                            "PreferredAvailabilityZone": "us-west-2a", 
                            "CacheNodeId": "0001", 
                            "CacheClusterId": "redis2x2-0001-002"
                        }
                    ]
                }, 
                {
                    "Status": "available", 
                    "Slots": "8192-16383", 
                    "NodeGroupId": "0002", 
                    "NodeGroupMembers": [
                        {
                            "PreferredAvailabilityZone": "us-west-2b", 
                            "CacheNodeId": "0001", 
                            "CacheClusterId": "redis2x2-0002-001"
                        }, 
                        {
                            "PreferredAvailabilityZone": "us-west-2a", 
                            "CacheNodeId": "0001", 
                            "CacheClusterId": "redis2x2-0002-002"
                        }
                    ]
                }
            ], 
            "ConfigurationEndpoint": {
                "Port": 6379, 
                "Address": "redis2x2.9dcv5r.clustercfg.usw2.cache.amazonaws.com"
            }, 
            "ClusterEnabled": true, 
            "ReplicationGroupId": "redis2x2", 
            "SnapshotRetentionLimit": 1, 
            "AutomaticFailover": "enabled", 
            "SnapshotWindow": "13:00-14:00", 
            "MemberClusters": [
                "redis2x2-0001-001", 
                "redis2x2-0001-002", 
                "redis2x2-0002-001", 
                "redis2x2-0002-002"
            ], 
            "CacheNodeType": "cache.m3.medium", 
            "PendingModifiedValues": {}
        }
    ]
}連線到複寫群組中的叢集 (ElastiCache API)
判斷快取節點端點和連接埠號碼
使用下列參數呼叫 DescribeReplicationGroups:
ReplicationGroupId = 您複寫群組的名稱。
範例
https://elasticache.us-west-2.amazonaws.com / ?Action=DescribeCacheClusters &ReplicationGroupId=repgroup01 &Version=2014-09-30 &SignatureVersion=4 &SignatureMethod=HmacSHA256 &Timestamp=20140421T220302Z &X-Amz-Algorithm=&AWS;4-HMAC-SHA256 &X-Amz-Date=20140421T220302Z &X-Amz-SignedHeaders=Host &X-Amz-Expires=20140421T220302Z &X-Amz-Credential=<credential> &X-Amz-Signature=<signature>