一站式学习Redis 从入门到高可用分布式实践(慕课)第八章 Redis Sentinel(哨兵,高可用)

  • 主从复制高可用?

          主从复制,主挂掉后需要手工来操作麻烦

          写能力和存储能力受限 (主从复制只是备份,单节点存储能力)  #其实分布式后面再讲

  • 架构说明

 

sentinel监控多套redis

  • 安装配置

 

sentinal的默认端口26379,形成如下的安装配置(其实就是单机多实例)

  • 客户端链接

 客户端链接流程:

                    1.Sentinel地址集合

                    2.masterName

                    3.不是代理模式

public static void main(String[] args) {
Set<String> IPS = new HashSet<String>();
IPS.add("192.168.136.158:26379");
JedisSentinelPool pool = new JedisSentinelPool("mymaster", IPS);
Jedis jedis=null;
try{
jedis = pool.getResource();
jedis.set("foo", "bar");
System.out.println(jedis.get("foo"));
} catch(Exception e){
e.printStackTrace();
// logger.error(e.getMessage(),e);
} finally {
if(jedis != null)
jedis.close();
}
  • 实现原理

 

故障转移尤sentinel领导者节点完成

  • 常见开发运维问题
原文地址:https://www.cnblogs.com/jiang910/p/10028645.html