hiredis-vip
hiredis-vip copied to clipboard
When I try to do hmset/hmget facing error "no reachable node in cluster"
I am able to connect to cluster withou any issue. Its not throwing any error. But whenever I try to do hmset/hmget its failing and throwing me the error "no reachable node in cluster"
Here is my code. In below code redis_config is string and its value is "
g_redis_cc = redisClusterConnect(redis_config, HIRCLUSTER_FLAG_NULL);
if (g_redis_cc == NULL || g_redis_cc->err) {
if (g_redis_cc) {
REDIS_DEBUG("Connection error: %s\n", g_redis_cc->errstr);
redisFree(g_redis_cc);
} else {
REDIS_DEBUG("Connection error: can't allocate redis context\n");
}
return NULL;
}
reply = redisClusterCommand(g_redis_cc, "hmset %s %s %s", "keyname", "fieldname", "valuename");
if (reply == NULL) {
printf("reply is NULL err %s \n", g_redis_cc->errstr);
}
Redis config is as below redis-host:6379> CLUSTER INFO cluster_state:ok cluster_slots_assigned:16384 cluster_slots_ok:16384 cluster_slots_pfail:0 cluster_slots_fail:0 cluster_known_nodes:1 cluster_size:1 cluster_current_epoch:0 cluster_my_epoch:0 cluster_stats_messages_sent:0 cluster_stats_messages_received:0
I test your code in my cluster, and there is no errors appeared.
Why the cluster_size is 1??
please show me your redis cluster 'cluster nodes' result.
redis-host:6379> CLUSTER nodes f89444b6339b454aaaa99f2fb6405ddb01889ac4 :6379 myself,master - 0 0 0 connected 0-16383
Why your cluster only has one node?
In production we are going to have multiple nodes. This is simulated setup which is given to individual developers. In this setup we will be having only one node. As the code should work in multi-node cluster, we are treating this single node as cluster and writing the code.
The normal redis cluster require at least three nodes. Your cluster node is a redis? What's the redis version?
redis-host:6379> INFO
Server
redis_version:3.0.7 redis_git_sha1:00000000 redis_git_dirty:0 redis_build_id:319b35380966d296 redis_mode:cluster os:Linux 4.6.3-coreos x86_64 arch_bits:64 multiplexing_api:epoll gcc_version:4.9.2 process_id:1 run_id:f15c6ef58a577541aa97e7bc840d3dee6654a7b4 tcp_port:6379 uptime_in_seconds:486535 uptime_in_days:5 hz:10 lru_clock:8147392 config_file:/data/redis.conf