windows单机 redis哨兵模式

windos下,redis哨兵模式配置和spring boot 读取使用:

    1、windows redis 下载  ,最好的下载方式是去redis的github上去下载,我简单浏览了一下官网,没有找到64位的下载。下载地址:https://github.com/ServiceStack/redis-windows/tree/master/downloads


     2、下载后解压文件夹目录可以看到内容如下:
    

    3、复制三个redis.windows.conf文件,分别命名为redis.conf, redis6479.conf, redis6579.conf,创建sentinel.conf, sentinel6479.conf, sentinel.6579.conf
           redis.conf    (作为主节点)
               port 6379
               bind 127.0.0.1

          redis6479.conf
               port 6479
               bind 127.0.0.1
               slaveof 127.0.0.1 6379 (注意:这里没有“:”)

          redis6579.conf
               port 6579
               bind 127.0.0.1
               slaveof 127.0.0.1 6379


          sentinel.conf            (mymaster是名字)
                port 26379 
      sentinel monitor mymaster 127.0.0.1 6379 2   
      sentinel down-after-milliseconds mymaster 5000 
      sentinel parallel-syncs mymaster 1 
      sentinel failover-timeout mymaster 15000

          sentinel6479.conf            
                port 26379 
      sentinel monitor mymaster 127.0.0.1 6479 2   
      sentinel down-after-milliseconds mymaster 5000 
      sentinel parallel-syncs mymaster 1 
      sentinel failover-timeout mymaster 15000

          sentinel6579.conf            
                port 26379 
      sentinel monitor mymaster 127.0.0.1 6579 2   
      sentinel down-after-milliseconds mymaster 5000 
      sentinel parallel-syncs mymaster 1 
      sentinel failover-timeout mymaster 15000

4、配置好以后,文件夹格局变成下图:
    

5、分别启动服务
       首先cmd进入到redis的文件夹目录
       执行以下命令:(容易出现问题的地方,在conf文件配置里面,首个字符不能是空格,否则会找不到对应的属性,我第一次启动找不到“bind”属性;第二个地方,在配置slaveof的时候,是配置“IP 空格 端口”,而不是像浏览器访问那样“IP:端口”)
          redis-server.exe redis6379.conf 
          redis-server.exe redis6479.conf 
          redis-server.exe redis6579.conf
      
          redis-server.exe sentinel26379.conf --sentinel
          redis-server.exe sentinel26479.conf --sentinel
          redis-server.exe sentinel26579.conf --sentinel

    6、启动正常显示如下图:(由于我电脑资源不够用,所以只启动了两个)我用的端口是6379和6380,所以截图和配置有点小区别,按照上面的配置端口分别是6379,6479,6579


    redis.conf启动


sentinel.conf启动
   

    7、测试部分,只需要使用redis-cli.exe进行常规测试即可。







猜你喜欢

转载自blog.csdn.net/fightxxl55/article/details/80558971