我是AWS Elasticache redis的新手,但是我在端点以下.
我对使用Jedis和Redisson感到困惑,因为它们都提供了单个连接和群集连接类.
像Jedis中一样,对于单个连接,我们可以使用:
Jedis conn = new Jedis("endpoint_address");
对于集群连接,我们使用:
Set<HostAndPort> jedisClusterNodes = new HashSet<HostAndPort>();
jedisClusterNodes.add(new HostAndPort("redis_cluster_ip", 7379));
JedisCluster jc = new JedisCluster(jedisClusterNodes);
当我想使用Redisson时,也会出现这些选项.我不是要比较这两个库,我的问题是:当您只有一个端点并且仍然可以使用AWS自动扩展功能时,哪种方法是连接到AWS Redis Elasticache集群的正确方法?
预期答案是:使用“单人”或“集群模式”.
谢谢 :)
解决方法:
这取决于您如何配置redis集群.是否启用集群模式.
您可以在控制台中找到它
http://docs.aws.amazon.com/AmazonElastiCache/latest/UserGuide/Endpoints.html
Redis (cluster mode disabled) clusters, use the Primary Endpoint for
all write operations. Use the individual Node Endpoints for read
operations (In the API/CLI these are referred to as Read Endpoints).Redis (cluster mode enabled) clusters, use the cluster’s Configuration
Endpoint for all operations. You must use a client that supports Redis
Cluster (Redis 3.2). You can still read from individual node endpoints
(In the API/CLI these are referred to as Read Endpoints).
或使用AWS CLI
aws elasticache describe-cache-clusters \
--cache-cluster-id mycluster \
--show-cache-node-info
http://docs.aws.amazon.com/cli/latest/reference/elasticache/describe-cache-clusters.html
ConfigurationEndpoint -> (structure) Represents a Memcached cluster
endpoint which, if Automatic Discovery is enabled on the cluster, can
be used by an application to connect to any node in the cluster. The
configuration endpoint will always have .cfg in it. Example:
mem-3.9dvc4r.cfg.usw2.cache.amazonaws.com:11211