本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
尋找連線端點
您的應用程式會使用端點連線到叢集。端點是節點或叢集的唯一位址。
要使用哪些端點
對於使用 Memcached 的 ElastiCache 無伺服器快取,只要從主控台取得叢集端點DNS和連接埠即可。
從中 AWS CLI,使用指describe-serverless-caches
令取得端點資訊。
Linux
aws elasticache describe-serverless-caches --serverless-cache-name CacheName
Windows
aws elasticache describe-serverless-caches --serverless-cache-name CacheName
上述操作的輸出應如下所示(JSON格式):
{ "ServerlessCaches": [ { "ServerlessCacheName": "serverless-memcached", "Description": "test", "CreateTime": 1697659642.136, "Status": "available", "Engine": "memcached", "MajorEngineVersion": "1.6", "FullEngineVersion": "21", "SecurityGroupIds": [ "sg-083eda453e1e51310" ], "Endpoint": { "Address": "serverless-memcached-01.amazonaws.com", "Port":11211 }, "ARN": "<the ARN>", "SubnetIds": [ "subnet-0cf759df15bd4dc65", "subnet-09e1307e8f1560d17" ], "SnapshotRetentionLimit": 0, "DailySnapshotTime": "03:00" } ] }
執行個體型 Memcached 叢集:如果您使用自動探索功能,則可以使用叢集的組態端點來設定 Memcached 用戶端。這表示您必須使用支援 Automatic Discovery 的用戶端。
如果您並未使用 Automatic Discovery,則必須將用戶端設定為使用個別的節點端點以進行讀取和寫入。您也必須在新增和移除節點時追蹤這些端點。
以下各節可引導您探索執行引擎所需的端點。
所有 Memcached 端點都是讀取/寫入端點。若要連線至 Memcached 叢集中的節點,您的應用程式可以使用每個叢集的端點,或搭配使用 Automatic Discovery 與叢集的組態端點。若要使用 Automatic Discovery,您必須使用支援 Automatic Discovery 的用戶端。
使用 Automatic Discovery 時,您的用戶端應用程式會使用組態端點連線至 Memcached 叢集。當您透過新增或移除節點以擴展叢集時,應用程式會自動「知道」叢集中的所有節點,並能連線至其中任何節點。如果未使用 Automatic Discovery,應用程式就無法完成上述作業;您必須在每次新增或移除節點時手動更新應用程式中的端點。
若要複製端點,請選擇端點位址前面的複製圖示。如需使用端點連線至節點的相關資訊,請參閱 連線至節點。
組態端點和節點端點看起來非常類似。下列會將差異以粗體醒目提示。
myclustername.xxxxxx
.cfg.usw2.cache.amazonaws.com:port
# configuration endpoint contains "cfg"
myclustername.xxxxxx
.0001.usw2.cache.amazonaws.com:port
# node endpoint for node 0001
重要
如果您選擇為 Memcached 組態端點建立一個CNAME,為了讓自動探索用戶端將其識別CNAME為組態端點,您必須.cfg.
在CNAME.
您可以使 AWS CLI 用 Amazon 探 ElastiCache 索節點和叢集的端點。
尋找節點和叢集的端點 (AWS CLI)
您可以使用describe-cache-clusters
指令 AWS CLI 來探索叢集及其節點的端點。若是 Memcached 叢集,則命令會傳回組態端點。如果您包含選用參數 --show-cache-node-info
,則命令也會傳回叢集中個別節點的端點。
以下命令會擷取 Memcached 叢集 mycluster 的組態端點 (ConfigurationEndpoint
) 和個別節點端點 (Endpoint
)。
若為 Linux、macOS 或 Unix:
aws elasticache describe-cache-clusters \ --cache-cluster-id
mycluster
\ --show-cache-node-info
針對 Windows:
aws elasticache describe-cache-clusters ^ --cache-cluster-id
mycluster
^ --show-cache-node-info
上述操作的輸出應該看起來像這樣(JSON格式)。
{
"CacheClusters": [
{
"Engine": "memcached",
"CacheNodes": [
{
"CacheNodeId": "0001",
"Endpoint": {
"Port": 11211,
"Address": "mycluster.amazonaws.com"
},
"CacheNodeStatus": "available",
"ParameterGroupStatus": "in-sync",
"CacheNodeCreateTime": "2016-09-22T21:30:29.967Z",
"CustomerAvailabilityZone": "us-west-2b"
},
{
"CacheNodeId": "0002",
"Endpoint": {
"Port": 11211,
"Address": "mycluster.amazonaws.com"
},
"CacheNodeStatus": "available",
"ParameterGroupStatus": "in-sync",
"CacheNodeCreateTime": "2016-09-22T21:30:29.967Z",
"CustomerAvailabilityZone": "us-west-2b"
},
{
"CacheNodeId": "0003",
"Endpoint": {
"Port": 11211,
"Address": "mycluster.amazonaws.com"
},
"CacheNodeStatus": "available",
"ParameterGroupStatus": "in-sync",
"CacheNodeCreateTime": "2016-09-22T21:30:29.967Z",
"CustomerAvailabilityZone": "us-west-2b"
}
],
"CacheParameterGroup": {
"CacheNodeIdsToReboot": [],
"CacheParameterGroupName": "default.memcached1.4",
"ParameterApplyStatus": "in-sync"
},
"CacheClusterId": "mycluster",
"PreferredAvailabilityZone": "us-west-2b",
"ConfigurationEndpoint": {
"Port": 11211,
"Address": "mycluster.amazonaws.com"
},
"CacheSecurityGroups": [],
"CacheClusterCreateTime": "2016-09-22T21:30:29.967Z",
"AutoMinorVersionUpgrade": true,
"CacheClusterStatus": "available",
"NumCacheNodes": 3,
"ClientDownloadLandingPage": "https://console.aws.amazon.com/elasticache/home#client-download:",
"CacheSubnetGroupName": "default",
"EngineVersion": "1.4.24",
"PendingModifiedValues": {},
"PreferredMaintenanceWindow": "mon:09:00-mon:10:00",
"CacheNodeType": "cache.m4.large",
}
]
}
重要
如果您選擇為 Memcached 組態端點建立一個CNAME,為了讓 auto 探索用戶端將其識別CNAME為組態端點,您必須.cfg.
在CNAME. 例如,session.save_path
參數 php.ini 檔案中的 mycluster
。.cfg.
local
如需詳細資訊,請參閱主題describe-cache-clusters。
您可以使用 Amazon ElastiCache API 探索節點和叢集的端點。
尋找節點和叢集的端點 (ElastiCache API)
您可以使 ElastiCache API用透過DescribeCacheClusters
動作探索叢集及其節點的端點。若是 Memcached 叢集,則命令會傳回組態端點。如果您包含選用參數 ShowCacheNodeInfo
,則動作也會傳回叢集中個別節點的端點。
以下命令會擷取 Memcached 叢集 mycluster 的組態端點 (ConfigurationEndpoint
) 和個別節點端點 (Endpoint
)。
https://elasticache.us-west-2.amazonaws.com/ ?Action=DescribeCacheClusters &CacheClusterId=mycluster &ShowCacheNodeInfo=true &SignatureVersion=4 &SignatureMethod=HmacSHA256 &Timestamp=20150202T192317Z &Version=2015-02-02 &X-Amz-Credential=<credential>
重要
如果您選擇為 Memcached 組態端點建立一個CNAME,為了讓 auto 探索用戶端將其識別CNAME為組態端點,您必須.cfg.
在CNAME. 例如,session.save_path
參數 php.ini 檔案中的 mycluster
。.cfg.
local