这是集群中的一个节点, 连接之后直接调用发送命令, 然后就报错
MOVED 12539 192.168.6.251:19002
char *hostname = "192.168.6.251";
int port = 19003;
struct timeval timeout = { 1, 500000 }; // 1.5 seconds
//c = redisConnect(hostname, port);
redisContext *con = redisConnectWithTimeout(hostname, port, timeout);
if (con == NULL || con->err) {
if (con) {
printf("Connection error: %s\n", con->errstr);
redisFree(con);
} else {
printf("Connection error: can't allocate redis context\n");
}
return -1;
}
redisReply *reply = (redisReply *)redisCommand(con,"set key hello");
printf("Set return: %s\n", reply->str);
freeReplyObject(reply);
freeRedis(con);