从 Java 连接到 AWS Elasticache(Redis 集群)的正确方法是什么?
What is a proper way to connect to AWS Elasticache (Redis cluster) from Java?
我是 AWS Elasticache redis 的新手,并且我低于端点。
我对使用 Jedis 和 Redisson 感到困惑,因为它们都提供单连接和集群连接 class。
就像在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 Redis Elasticache 集群的正确方法,当你只有一个端点时仍然可以利用 AWS 自动缩放功能?
预期答案是:使用单一或集群模式。
谢谢:)
您应该在 Redisson 中为 AWS Elasticache Redis 或其他类似托管服务使用复制配置。 documentation.
中描述了用法
这取决于你如何配置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
我是 AWS Elasticache redis 的新手,并且我低于端点。
我对使用 Jedis 和 Redisson 感到困惑,因为它们都提供单连接和集群连接 class。
就像在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 Redis Elasticache 集群的正确方法,当你只有一个端点时仍然可以利用 AWS 自动缩放功能?
预期答案是:使用单一或集群模式。
谢谢:)
您应该在 Redisson 中为 AWS Elasticache Redis 或其他类似托管服务使用复制配置。 documentation.
中描述了用法这取决于你如何配置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