Closed kelaicai closed 1 year ago
Redis sentinel has nothing to do with Redis cluster. If you want to send command to redis cluster, you can define a RedisCluster object. Please check the doc for detail.
Regards
发件人: jackzhang @.> 发送时间: Friday, March 31, 2023 1:03:54 AM 收件人: sewenew/redis-plus-plus @.> 抄送: Subscribed @.***> 主题: [sewenew/redis-plus-plus] When I settings more nodes in Sentinel,It always Throw MoveError:like 12539 127.0.0.1:8002 (Issue #467)
code in there: `
using namespace sw::redis; using namespace std;
int main(){
SentinelOptions sentinel_opts; sentinel_opts.nodes = {{"127.0.0.1", 28000}, {"127.0.0.1", 28001}, {"127.0.0.1", 28002} }; // Required. List of Redis Sentinel nodes.
// Optional. Timeout before we successfully connect to Redis Sentinel. // By default, the timeout is 100ms. sentinel_opts.connect_timeout = std::chrono::milliseconds(200);
// Optional. Timeout before we successfully send request to or receive response from Redis Sentinel. // By default, the timeout is 100ms. sentinel_opts.socket_timeout = std::chrono::milliseconds(200);
auto sentinel = std::make_shared
if(!sentinel){ cout << "sentinel happened error!" <<endl; return -1; }
ConnectionOptions connection_opts; //connection_opts.password = "auth"; // Optional. No password by default. //connection_opts.db = 1; connection_opts.connect_timeout = std::chrono::milliseconds(500); // Required. connection_opts.socket_timeout = std::chrono::milliseconds(500); // Required. connection_opts.keep_alive = 5;
ConnectionPoolOptions pool_opts; pool_opts.size = 3; // Optional. The default size is 1. pool_opts.wait_timeout = std::chrono::milliseconds(500);
auto master = Redis(sentinel, "master_8000", Role::MASTER, connection_opts, pool_opts); Redis* masterClient1 = &master;
auto slave = Redis(sentinel, "master_8000", Role::SLAVE, connection_opts, pool_opts);
//cout << master.info() <<endl;
for(int i = 0 ;i< 3; i++){ try{ // Write to master. master.set("key", "value"); //Read from slave. auto val = slave.get("key"); cout << *val <<endl; break; }catch(const exception& e){ cout << "error:"<< e.what() <<endl; } }
return 0;
}
`
local machine's redis-cluster nodes all close protect-mode ,code like docs's example https://github.com/sewenew/redis-plus-plus#Redis%20Sentinel
redis-node like 8000,8001,8002 are master nodes ,8003,8004,8005 are their slave nodes [image]https://user-images.githubusercontent.com/21305726/228910899-29eeaf35-44ce-4309-8c3c-40fa3e3e3eaf.png
― Reply to this email directly, view it on GitHubhttps://github.com/sewenew/redis-plus-plus/issues/467, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACWWTAN77J3PBHMG6ZEPWX3W6W4HVANCNFSM6AAAAAAWNSL5W4. You are receiving this because you are subscribed to this thread.Message ID: @.***>
Since there's no update, I'll close this issue. If you still have problem, feel free to reopen it.
Regards
code in there: `
include <sw/redis++/redis++.h>
include <sw/redis++/sentinel.h>
include <sw/redis++/connection.h>
include <sw/redis++/connection_pool.h>
using namespace sw::redis; using namespace std;
int main(){
} ` local machine's redis-cluster nodes all close protect-mode ,code like docs's example https://github.com/sewenew/redis-plus-plus#Redis%20Sentinel ,is there any problem? I can't find any problems.
redis-node like 8000,8001,8002 are master nodes ,8003,8004,8005 are their slave nodes