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

TONG RDS(国产信创) 哨兵有问题 #493

Open
edobnet opened this issue Nov 15, 2023 · 9 comments
Open

TONG RDS(国产信创) 哨兵有问题 #493

edobnet opened this issue Nov 15, 2023 · 9 comments

Comments

@edobnet
Copy link

edobnet commented Nov 15, 2023

image
换freeRedis或StackExchange.Redis可以
csredis连redis哨兵也是没有问题,国产信创有没有办法
换框架改动比较大,项目已经上线。

@2881099
Copy link
Owner

2881099 commented Nov 15, 2023

我没有你的环境,无法判断修改哪里有效。

后续建议用持续更新新功能的 FreeRedis,是全新重写的,支持更多功能。

@edobnet
Copy link
Author

edobnet commented Nov 16, 2023

FreeRedis,本地是没有问题,到客户有现场也有问题本地TongRds比客户现场高一版本,只能升级试一下了,
image

@edobnet
Copy link
Author

edobnet commented Nov 16, 2023

csredis出错在ROLE命令
image
image

image

@edobnet
Copy link
Author

edobnet commented Nov 16, 2023

哨兵端口是这样
image
6379端口是这样
image

@2881099
Copy link
Owner

2881099 commented Nov 16, 2023

FreeRedis 的报错是连接超时,你在哨兵执行一下命令:

SENTINEL GET-MASTER-ADDR-BY-NAME sbcluster

看看返回什么,是不是可以连接的 IP,我猜返回的是内网IP,导致你的程序无法连接,连接超时。

csredis 的协议处理没有 FreeRedis 先进,对返回内容要求比较严格,我看你的截图返回的格式,应该是 TONG RDS 魔改过。

建议使用 FreeRedis

@edobnet
Copy link
Author

edobnet commented Nov 21, 2023

已经用FreeRedis, 不过多线程get性能测试慢50%左右

@2881099
Copy link
Owner

2881099 commented Nov 21, 2023

把测试代码和测试过程发一下

@edobnet
Copy link
Author

edobnet commented Nov 27, 2023

就并行一直读指定数量键值。

using XCRMS.Xcrs.PCL.Core;
using Xunit.Abstractions;

namespace XCRMS.DAL.Test.Cache {
    [TestCaseOrderer("XCRMS.DAL.Test.TestCaseOrderer", "XCRMS.DAL.Test")]
    public class TestRedis: BaseTest {
        public TestRedis(ITestOutputHelper output) : base(output) {
        }

        [Theory(DisplayName = "01.init")]
        [InlineData("aaa","11111")]
        public void Test0(string key,string v ) {
         
            RedisUtil.Set(key, v,36000);
           // var aa =  RedisUtil.Get2(key);
           // Assert.Equal(v, aa);
        }
        [Theory(DisplayName = "02_02.getPerformace")]
        [InlineData("aaa", 100)]
        public void Test1_1(string key, int count) {
          RedisUtil.Get<string>(key);
            Parallel.For(0, count, i => {
                var aa = RedisUtil.Get<string>(key);
                if (aa != "11111") {
                    Output.WriteLine(aa);
                }
            }
            );
        }

    }
}

RedisUtil 以前
public class RedisUtil : RedisHelper {
public static void Init(string conn) {

        //哨兵模式
        if (conn.StartsWith("[")) {
           int eIndex = conn.IndexOf("]");
           var servers = conn[1..eIndex].Split(new char[] { ','},StringSplitOptions.RemoveEmptyEntries);
            Initialization(new CSRedisClient(conn[(eIndex + 1)..], servers));
        }
        else {
             Initialization(new CSRedisClient(conn));
        }
    }
}

}

用FreeRedis
public class RedisUtil {

public static RedisClient cli;
public static void Init(string conn) {
    //哨兵模式
    if (conn.StartsWith("[")) {
        int eIndex = conn.IndexOf("]");
        var servers = conn[1..eIndex].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
        string connStr = conn[(eIndex + 1)..];
         cli = new RedisClient(connStr,servers, false);
    }
    else {
        cli = new RedisClient(conn);
    }
    cli.Serialize = obj => JsonConvert.SerializeObject(obj);
    cli.Deserialize = (json, type) => JsonConvert.DeserializeObject(json, type);
}


public static A Get<A>(string v) {
    return cli.Get<A>(v);
}

之前也测试了,StackExchange.Redis
还是csredis最高。

@2881099
Copy link
Owner

2881099 commented Nov 27, 2023

请提供一个可以直接运行测试的 console app

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

2 participants