请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

.Net Core中使用Sentinel,连接这样写对吗?

ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("192.168.0.109:6379,192.168.0.109:6390,192.168.0.110:6379,192.168.0.111:6379,192.168.0.111:6380,192.168.0.111:6381")

正在回答 回答被采纳积分+3

1回答

carlosfu 2017-11-11 20:14:07

请问你用的哪个类库,虽然不太清楚.net的sentinel客户端,不过所有sentinel客户端都应该是sentinelSet和masterName作为参数,才可以实现高可用。

0 回复 有任何疑惑可以回复我~
  • 提问者 菠萝吹雪gz #1
    谢谢老师的解答。老师忙完双十一了(#^.^#),使用的库为:StackExchange.Redis,我在Github找到了下面的配置:
    private string ServiceName => TestConfig.Current.SentinelSeviceName;
    private ConnectionMultiplexer Conn { get; }
    private IServer Server { get; }
    
    public ITestOutputHelper Output { get; }
    public Sentinel(ITestOutputHelper output)
    {
    	Output = output;
    
    	Skip.IfNoConfig(nameof(TestConfig.Config.SentinelServer), TestConfig.Current.SentinelServer);
    	Skip.IfNoConfig(nameof(TestConfig.Config.SentinelSeviceName), TestConfig.Current.SentinelSeviceName);
    
    	var options = new ConfigurationOptions()
    	{
    		CommandMap = CommandMap.Sentinel,
    		EndPoints = { { TestConfig.Current.SentinelServer, TestConfig.Current.SentinelPort } },
    		AllowAdmin = true,
    		TieBreaker = "",
    		ServiceName = TestConfig.Current.SentinelSeviceName,
    		SyncTimeout = 5000
    	};
    	Conn = ConnectionMultiplexer.Connect(options, Console.Out);
    	Thread.Sleep(3000);
    	Assert.True(Conn.IsConnected);
    	Server = Conn.GetServer(TestConfig.Current.SentinelServer, TestConfig.Current.SentinelPort);
    }
    我先试试,遇到问题再请教老师
    回复 有任何疑惑可以回复我~ 2017-11-11 21:05:05
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信