jedis 与 redis 集群的连接被拒绝
Connect refused for jedis with redis cluster
我正在尝试使用 jedis(在连接到同一网络的本地计算机上)连接到我的 redis 集群(在远程服务器上)。
我的redis集群是通过以下ips组成的:
10.x.x.x:6380
10.x.x.x:6382
10.x.x.x:6385
我的 redis 实例 10.x.x.x:6380 的配置文件是:
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)
但是问题是,当我尝试 运行 我的 redis 服务器实例时,出现以下异常:
[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
有人能告诉我我做错了什么吗???提前致谢。
我的绝地武士程序是:
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"));
糟糕。这对我来说是一个愚蠢的错误。
从 redis.conf 中的 bind
标记中删除机器 ip 和 127.0.0.1 并指定正确的主机 ip(即,在我的情况下为 10.x.x.x)。
也把protected-mode
放到no
在redis.conf
此外,当使用 ./redis-trib.rb
创建集群时,主机 ips 应该以正确的格式(10.x.x.x)提及,而不是放置本地主机(即,不是 127.0.0.1),即使所有的 redis 实例都是运行 在同一台服务器上。
我正在尝试使用 jedis(在连接到同一网络的本地计算机上)连接到我的 redis 集群(在远程服务器上)。
我的redis集群是通过以下ips组成的:
10.x.x.x:6380
10.x.x.x:6382
10.x.x.x:6385
我的 redis 实例 10.x.x.x:6380 的配置文件是:
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)
但是问题是,当我尝试 运行 我的 redis 服务器实例时,出现以下异常:
[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
有人能告诉我我做错了什么吗???提前致谢。
我的绝地武士程序是:
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"));
糟糕。这对我来说是一个愚蠢的错误。
从 redis.conf 中的 bind
标记中删除机器 ip 和 127.0.0.1 并指定正确的主机 ip(即,在我的情况下为 10.x.x.x)。
也把protected-mode
放到no
在redis.conf
此外,当使用 ./redis-trib.rb
创建集群时,主机 ips 应该以正确的格式(10.x.x.x)提及,而不是放置本地主机(即,不是 127.0.0.1),即使所有的 redis 实例都是运行 在同一台服务器上。