当前位置: 首页 > 面试题库 >

Amazon Elasticache Redis集群-无法获得端点

澹台正业
2023-03-14
问题内容

我需要获取Amazon Elasticache中Redis集群的终端节点。以下代码适用于Memcached群集,但不适用于Redis:

import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.profile.ProfileCredentialsProvider;
import com.amazonaws.regions.Regions;

import com.amazonaws.services.elasticache.AmazonElastiCacheClient;
import com.amazonaws.services.elasticache.model.DescribeCacheClustersRequest;
import com.amazonaws.services.elasticache.model.DescribeCacheClustersResult;
import com.amazonaws.services.elasticache.model.CacheNode;
import com.amazonaws.services.elasticache.model.CacheCluster;
import com.amazonaws.services.elasticache.model.Endpoint;

public class Redis {
    public static void main(String[] args) {
        AWSCredentials credentials = 
            new ProfileCredentialsProvider("default").getCredentials();
        AmazonElastiCacheClient amazonClient = new AmazonElastiCacheClient(credentials);
        amazonClient.setRegion(Regions.EU_WEST_1);
        DescribeCacheClustersRequest dccRequest = new DescribeCacheClustersRequest();
        dccRequest.setShowCacheNodeInfo(true);
        dccRequest.withCacheClusterId("app-001");
        DescribeCacheClustersResult clusterResult = 
            amazonClient.describeCacheClusters(dccRequest);

        CacheCluster cacheCluster = clusterResult.getCacheClusters().get(0);
        System.out.println("cluster: " + cacheCluster);
        System.out.println("endpoint: " + cacheCluster.getConfigurationEndpoint());
    }
}

输出为:

cluster: {CacheClusterId: app-001,ClientDownloadLandingPage: https://console.aws.amazon.com/elasticache/home#client-download:,CacheNodeType: cache.r3.large,Engine: redis,EngineVersion: 2.8.19,CacheClusterStatus: available,NumCacheNodes: 1,PreferredAvailabilityZone: eu-west-1a,CacheClusterCreateTime: Thu May 21 11:43:03 CEST 2015,PreferredMaintenanceWindow: mon:04:00-mon:05:00,PendingModifiedValues: {CacheNodeIdsToRemove: [],},CacheSecurityGroups: [],CacheParameterGroup: {CacheParameterGroupName: default.redis2.8,ParameterApplyStatus: in-sync,CacheNodeIdsToReboot: []},CacheSubnetGroupName: default,CacheNodes: [{CacheNodeId: 0001,CacheNodeStatus: available,CacheNodeCreateTime: Thu May 21 11:43:03 CEST 2015,Endpoint: {Address: app-001.3pusxn.0001.euw1.cache.amazonaws.com,Port: 6379},ParameterGroupStatus: in-sync,CustomerAvailabilityZone: eu-west-1a}],AutoMinorVersionUpgrade: true,SecurityGroups: [{SecurityGroupId: sg-3231f657,Status: active}],ReplicationGroupId: app,SnapshotRetentionLimit: 0,SnapshotWindow: 22:00-23:00}
endpoint: null

请注意,群集对象如何包含端点信息(键Endpoint:),但仍getConfigurationEndpoint返回null

我如何获得终点?


问题答案:

通常,我在发布问题后就找到了解决方案。在Redis中,您必须访问缓存节点:

cacheCluster.getCacheNodes().get(0).getEndpoint());


 类似资料:
  • 问题内容: 管理员版本, 工人版本。 创建了Swarm管理器: 然后创建工人 我已经检查了工人的日志 在中,我看到了“虫群:待定” 我也做到了!尽管如此,该工作人员仍无法加入集群。所以,我该怎么爱 更新1 卸载并删除配置文件,然后再次安装docker 1.12版本。 仍然面临着相同的问题(无法加入和中的“ Swarm:Pending” ),其中存在DIFFERENT错误 谢谢。 问题答案: 问题是

  • 我有3个虚拟机。它们都有docker 1.12,并且在centos7上运行。所有端口都已打开,vm可以在我启动集群时相互ping Docker信息告诉我: 现在,我尝试将节点(其他VM)加入集群。我使用启动管理器后推荐的命令。 但我得到了: Docker信息告诉我: 集群管理器: 如何调试此问题,或者我是否忘记执行某些重要步骤?服务器之间是否需要ssh访问?谢谢 节点上的日志: 有时警告:

  • 我刚刚设置了一个AWS EMR集群(带有Spark 2.3.2的EMR版本5.18)。我ssh进入主maschine,并运行spark-shell或pyspark,得到以下错误: 我是新的火花和EMR,不知道该怎么做。是否有一些配置步骤我错过了或任何其他我必须提供使其工作? 谢谢你的帮助!

  • 我基于构建了一个映像,它基本上添加了一个新的,但是在第一个节点成功开始工作后,在第二个节点上遇到了以下错误。谁能帮我在这里调试一下吗? 为了确保容器之间的网络正常工作,尝试创建另一个可以登录到第一个容器的mysql实例的容器。 这绝对与无关 为了查看容器是否内存不足,我使用并看到失败的容器在整个生命周期中只使用了142MB,直到失败,这比允许的总内存(~4GB)要小得多。 我使用,但尝试在Cent

  • 给定一组正整数,其元素不必不同,我需要找到从给定集合的任何子集都不能得到的最小非负和。 例如:,我们可以得到作为,作为,作为,,作为,作为,但我们无法得到。 现在我们得到一个数组A,由N个正整数组成。它们是M个查询,每个查询由两个整数组成,分别描述i't查询:我们需要找到无法从数组元素{A[Li],A[Li 1],…,A[Ri-1],A[Ri]}中获得的和。 我知道用蛮力方法找到它要在O(2^n)

  • 问题内容: 一切工作正常,但问题是当我在地图上定位时什么都没发生我注册了我的谷歌地图,我在这里做了所有说明 http://code.google.com/intl/pl/android/add-ons/google- apis/mapkey.html 我可以看到地图,可以放大和缩小,但是当我搜索位置时,会在logcat中找到它 这是我的Java代码 有什么帮助吗?提前致谢 问题答案: 如果您在AP