Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

哨兵只能一直读写主 #80

Open
ming2882 opened this issue Feb 16, 2022 · 12 comments
Open

哨兵只能一直读写主 #80

ming2882 opened this issue Feb 16, 2022 · 12 comments

Comments

@ming2882
Copy link

哨兵只能一直读写主,从的没有请求过,这是正常的吗?然后主就时不时的Unable to read data from the transport connection: 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。.

@ming2882
Copy link
Author

var cli = new RedisClient(redisOption.Connection, redisOption.Sentinels, true);
cli.Serialize = obj => JsonConvert.SerializeObject(obj);
cli.Deserialize = (json, type) => JsonConvert.DeserializeObject(json, type, new JsonSerializerSettings {
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
});
cli.Notice += (s, e) => Console.WriteLine(e.Log);
services.AddSingleton(cli);这样配置对吗,单例注入

@2881099
Copy link
Owner

2881099 commented Feb 17, 2022

把连接串加上配置 idletimeout=20000

@2881099
Copy link
Owner

2881099 commented Feb 17, 2022

确定哨兵环境配置正确吗

@ming2882
Copy link
Author

image
我有做6379端口kill时,哨兵就会切换端口

@ming2882
Copy link
Author

image
image

@ming2882
Copy link
Author

ming2882 commented Feb 19, 2022

是用jmeter直接跑业务,做压力测试,jmeter的线程组里的线程数是100,循环1次,用户文件里有100个用户,api请求有64条,共计就是6400并发数

@ming2882
Copy link
Author

是不是同一台服务器做的主从不行啊?

@ming2882
Copy link
Author

测试了下StackExchange.Redis,可以主写分离,就是从的也有请求,说明哨兵模式没有问题

@2881099
Copy link
Owner

2881099 commented Feb 23, 2022

sentinel slaves mymaster

返回的所有信息发出来一下,其实可以根据源码分析:

Sentome;Adapter.cs

if (_rw_splitting)
{
    foreach (var slave in sentinelcli.Salves(_connectionString.Host))
    {
        ConnectionStringBuilder slaveConnectionString = localTestHost($"{slave.ip}:{slave.port}", RoleType.Slave);
        if (slaveConnectionString == null) continue;
    }
}

@johnhorse
Copy link

作者重现这个问题了没? 我配置了哨兵模式,但是和这位老兄一样,读写始终操作的是主。。。

@2881099
Copy link
Owner

2881099 commented Jul 14, 2022

作者重现这个问题了没? 我配置了哨兵模式,但是和这位老兄一样,读写始终操作的是主。。。

看上一楼回复

@2881099
Copy link
Owner

2881099 commented Jul 14, 2022

@johnhorse @ming2882
是读取 redis 哨兵配置时转换 bug 导致读写分离功能失效。

v0.5.5 已修复

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants