hiredis-vip icon indicating copy to clipboard operation
hiredis-vip copied to clipboard

When I try to do hmset/hmget facing error "no reachable node in cluster"

Open eshwar472 opened this issue 8 years ago • 8 comments

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

eshwar472 avatar Jan 12 '17 13:01 eshwar472

I test your code in my cluster, and there is no errors appeared.

deep011 avatar Jan 13 '17 04:01 deep011

image

Why the cluster_size is 1??

deep011 avatar Jan 13 '17 06:01 deep011

please show me your redis cluster 'cluster nodes' result.

deep011 avatar Jan 13 '17 06:01 deep011

redis-host:6379> CLUSTER nodes f89444b6339b454aaaa99f2fb6405ddb01889ac4 :6379 myself,master - 0 0 0 connected 0-16383

eshwar472 avatar Jan 13 '17 09:01 eshwar472

Why your cluster only has one node?

deep011 avatar Jan 15 '17 02:01 deep011

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.

eshwar472 avatar Jan 15 '17 04:01 eshwar472

The normal redis cluster require at least three nodes. Your cluster node is a redis? What's the redis version?

deep011 avatar Jan 15 '17 06:01 deep011

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

eshwar472 avatar Jan 16 '17 04:01 eshwar472