Redis BD Cluster in Amazon WS Elastic Cache

164 views
Skip to first unread message

Gian Piero Marcacci

unread,
Sep 14, 2015, 11:35:20 AM9/14/15
to Redis DB

Hi, I configured a Redis DB in my local machine and after I connected to my redis instance from a Java class with Lettuce library to get the information back . . . Now I configured a Redis BD Cluster in Amazon WS Elastic Cache product . . . can anybody tell me or suggest me a sources of information of How can I be able to establish the connection from my Java class to the Redis BD Cluster in Amazon WS Elastic Cache ?


THKS!!!

Mark Paluch

unread,
Sep 15, 2015, 2:07:09 AM9/15/15
to Redis DB
Hi Gian Piero,

it works basically the same way. Use the connection details (host/post) that are displayed on your AWS console and use those to connect to. AWS allows to configure master/slave setups. You can configure lettuce in a static way to access these instances but there's no read from slave option in Redis Standalone mode.


HTH, Mark

Gian Piero Marcacci

unread,
Sep 15, 2015, 3:17:40 AM9/15/15
to Redis DB

Hi Mark, my doubt is because with the lettuce library I have this code to stablished the connection: 

 RedisClient client = new RedisClient("localhost")
But with AWS I established the connection first with the EC2 instance, for which I need a user (ec2-user), 
DNS (ec2-52-11-150-12.us-west-2.compute.amazonaws.com) and a MyKeyPair.pem file, and after that I connect to my 
Redis Cluster ElasticCache with Cluster endpoit an port (mycachecluster.b4ujee.0001.usw2.cache.amazonaws.com -p 6379).
So in this case I don't know what to put in the place where actually I have "localhost" 
and if I need the MyKeyPair.pem file ?
THKS a lot!!!

Mark Paluch

unread,
Sep 15, 2015, 4:22:51 AM9/15/15
to Redis DB
The code should look more or less like:

 RedisClient client = new RedisClient("mycachecluster.b4ujee.0001.usw2.cache.amazonaws.com", 6379)

The EC2 host/user and the PEM file are not relevant when connecting to an ElastiCache cluster. Be sure to use only RedisClient, not RedisClusterClient. The ElastiCache has its own magic and does not require cluster-support from the client perspective, at least not in the Redis-Cluster fashion.

Tip: Try and error, go and try yourself things out, that's the best way to learn :)
Tip 2: Get familiar with the different AWS services and the programming language, you're using. 

HTH, Mark

Gian Piero Marcacci

unread,
Sep 15, 2015, 8:12:17 AM9/15/15
to Redis DB

Hi, now I got "Caused by: java.net.ConnectException: Connection timed out: no further information: mycachecluster.b4ujee.0001.usw2.cache.amazonaws.com/172.31.34.211:6379"

it seem be a proxy restriction . . . I am working in Jdeveloper and I setup the proxy settings in the tool, but I still got the same exception , , , so I was wondering which communication protocol use lettuce client to connect to redis , because I know that I am no allow to establish ssh connection from my company proxy.

any suggestion ? 

THKS!!!

Liviu Costea

unread,
Sep 15, 2015, 2:07:03 PM9/15/15
to Redis DB
This seems related to the AWS Security Groups. You need to open port 6379 inbound on your security group you use for the elasticache redis cluster, but only for your EC2 instance (not to the world). And also check your EC2 instance security group outbound if it can go out on port 6379 to reach the elasticache redis cluster.

Gian Piero Marcacci

unread,
Sep 16, 2015, 3:29:09 AM9/16/15
to Redis DB
Hi Liviu . . .I have been reviewing your suggestion, and I have defined only one Security Group with these rules: 

Inbound:

Type
Protocol
Port Range
Source
Custom TCP Rule
TCP
6379
SSH
TCP
22

Outbound:

Type
Protocol
Port Range
Destination
All traffic
All
All


and both the EC2 instance and the ElasticCache cluster seem be associated with this Security Group, so I understand that that is not the problem ... right ? 

Liviu Costea

unread,
Sep 17, 2015, 4:33:43 AM9/17/15
to Redis DB
This is far from a perfect situation, sharing the same security group for different types of servers, but in your case it should alow the communication. So the Security groups look like they allow the communication.
One more possible scenario: your EC2 instance is not in the same VPC as the (Elasticache) Redis server so they can't communicate. What's the private IP of your EC2 instance?
BTW: it doesn't look like a Redis problem, it seems an AWS problem, you could get more help from an AWS related forum/site
Reply all
Reply to author
Forward
0 new messages