0

i'm trying to connect to my redis cluster(on remote server) using jedis(on my local machine connected to same network).

My redis cluster is formed by following ips:

10.x.x.x:6380

10.x.x.x:6382

10.x.x.x:6385

My config file for redis instance 10.x.x.x:6380 is:

port 6380
cluster-enabled yes
cluster-config-file nodes-6380.conf
cluster-node-timeout 5000
appendonly yes
protected-mode yes
#daemonize yes
bind 127.0.0.1 10.x.x.x(machine ip)

However the issue is that when i'm tryig to run my redis server instance, i'm getting the following exception:

[admin@dn2 6380]$ redis-server  redis.conf 
10965:M 21 Jul 02:58:04.100 # Creating Server TCP listening socket (local machine ip):6380: bind: Cannot assign requested address

Can someone tell me what i'm doing wrong here??? Thanks in advance.

My jedis program is:

        Set<HostAndPort> jedisClusterNodes = new HashSet<HostAndPort>();
        //Jedis Cluster will attempt to discover cluster nodes automatically
        jedisClusterNodes.add(new HostAndPort("10.x.x.x", 6380));
        jedisClusterNodes.add(new HostAndPort("10.x.x.x", 6382));
        jedisClusterNodes.add(new HostAndPort("10.x.x.x", 6385));
        JedisCluster jc = new JedisCluster(jedisClusterNodes);
        jc.set("foo", "bar");
        String value;
        System.out.println(value = jc.get("foo"));
Marek
  • 245
  • 1
  • 4
  • 15

1 Answers1

0

Oops. It was a stupid mistake from my end.

Remove the machine ip and 127.0.0.1 from the bind tag in redis.conf and specify the correct host ip(i.e., 10.x.x.x in my case).

Also put protected-mode to no in redis.conf

Also when creating cluster using ./redis-trib.rb the host ips should be mentioned in correct format(10.x.x.x) and not put localhost(i.e., not 127.0.0.1) even if all the redis instances are running on the same server.

Marek
  • 245
  • 1
  • 4
  • 15