Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure ElastiCache Redis for Spring Data Access

I am trying to setup ElastiCache to use with a Java Application. I have based my setup based on this documentation: https://docs.aws.amazon.com/AmazonElastiCache/latest/UserGuide/BestPractices.html

The EC2 instance where the Java (8) App runs is in a VPC. I have tried an ElastiCache instance both in VPC and no VPC. However, I always got,

redis.clients.jedis.exceptions.JedisConnectionException: java.net.ConnectException: Connection refused

If I install Redis myself on an EC2 instance and connect to it, the app is able to connect to the Redis Cache!

I have setup proper authorization with Security-group from EC2 to Cache-Security but no luck. I just can't make the 'connection'. Any sample connection snippet would be really helpful.

Redis is setup this way in the APP Config:

    @Bean
    public JedisConnectionFactory redisConnectionFactory() {
    JedisConnectionFactory redisConnectionFactory = new JedisConnectionFactory();
    redisConnectionFactory.setHostName(<cache-node>);
    redisConnectionFactory.setPort(6397);
    redisConnectionFactory.setUsePool(true);
    redisConnectionFactory.setTimeout(3600);
    return redisConnectionFactory;
   }

The various versions:

Jedis- 2.6.2, Spring- 4.1.6, Spring-data-> 1.5.0
like image 697
asaraff2 Avatar asked Jun 01 '15 07:06

asaraff2


People also ask

How do I connect Redis ElastiCache?

Sign in to the AWS Management Console and open the ElastiCache console at https://console.aws.amazon.com/elasticache/ . From the navigation pane, choose Redis clusters. The clusters screen will appear with a list of Redis (cluster mode disabled) and Redis (cluster mode enabled) clusters.

How do I control access to Amazon ElastiCache choose the best answer?

Security Groups can be configured with the “Security Groups” section of the Amazon ElastiCache Console or using the Amazon ElastiCache APIs. In VPC deployments, access to your nodes is controlled using the VPC Security Group and the Subnet Group.


1 Answers

telnet redis-ip 6397

Determine if redis can be connected

like image 91
sundb Avatar answered Oct 12 '22 02:10

sundb