I have installed and compiled Redis from source and am attempting to connect to an Amazon ElastiCache (Redis) cluster.
I can connect to the default localhost with no problem, but attempting to connect to an AWS endpoint causes what seems to be an infinite hangup.
With defaults:
$ redis-server /etc/redis.conf # daemonized, uses localhost
$ redis-cli ping
PONG
$ sudo service redis_6379 status
Redis is running (12919)
$ redis-cli shutdown # or sudo service redis_6379 stop
Now, here is an attempt to connect to the endpoint, copies from AWS documentation on the topic:
redis-cli -c -h my_example_endpoint_name.eaogs8.ng.0001.use1.cache.amazonaws.com -p 6379 ping
This hangs up infinitely without anything being issued to stderr/stdout.
(Please note this is an example endpoint name; I have verified I am using the primary endpoint listed at the AWS console.)
I suspect this may be related to the security group settings for the cluster on the AWS side but am not sure specifically what could/should be modified. I appreciate suggestions of what could be blocking the connection and can provide info on the cluster itself as needed.
Open the AWS Management Console in your favorite browser and navigate to ElastiCache. Click the blue “Create” button towards the middle of the page. For this cluster, we will select the Redis engine and enable Cluster Mode. Next, provide your cluster with a name and description.
Destination Type: Choose Network Interface and select the Elasticache ENI from the list. Destination port: specify 6379 for ElastiCache for Redis or 11211 for ElastiCache for Memcached. Those are the ports defined with the default configuration and this example assumes that they are not changed.
As we’ll discuss shortly, Redis clients that support clustering allow you to specify a single endpoint and then internally map to the nodes in the cluster transparently. Redis leverages a form of sharding in which every cache key is mapped to a “hash slot.” Within the cluster, there are 16,384 hash slots available.
5.1 — Select a Security group for your Redis Cluster. This is important: make sure the Security group you select allows incoming TCP connections on port 6379. If that's not the case, you won't be able to connect to your Redis nodes.
The connection was being prohibited by the security groups of the EC2 instance and the ElastiCache cluster to which it was trying to connect not being properly aligned.
From the AWS docs:
All ElastiCache clusters are designed to be accessed from an Amazon EC2 instance. The most common scenario is to access an ElastiCache cluster from an Amazon EC2 instance in the same Amazon Virtual Private Cloud (Amazon VPC).
The steps that I took to correct this were:
You should now be able to connect with something like (example):
redis-cli -c -h mycachecluster.eaogs8.0001.usw2.cache.amazonaws.com -p 6379 ping
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With