二十二、Redis Sentinel模式搭建

#                           Redis Sentinel模式搭建



架构模型图: ![这里写图片描述](https://img-blog.csdn.net/20180819042500283?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L25ld2JpZV85MDc0ODY4NTI=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70)

###1、redis一主二从配置

redis7000.conf

port 7000
daemonize yes
protected-mode no
bind 192.168.1.108
pidfile /var/run/redis-7000.pid
logfile /opt/module/redis7000/data/"7000.log"
dir /opt/module/redis7000/data
slave-read-only yes

redis7001.conf

port 7001
daemonize yes
protected-mode no
bind 192.168.1.108
pidfile /var/run/redis-7001.pid
logfile /opt/module/redis7001/data/"7001.log"
dir /opt/module/redis7001/data
slave-read-only yes
slaveof 127.0.0.1 7000

redis7002.conf

port 7002
daemonize yes
protected-mode no
bind 192.168.1.108
pidfile /var/run/redis-7002.pid
logfile /opt/module/redis7002/data/"7002.log"
dir /opt/module/redis7002/data
slave-read-only yes
slaveof 127.0.0.1 7000

###2、三台Redis Sentinel 搭建

sentinel26379.conf

port 26379

daemonize yes

logfile /opt/module/redis-sentinel/data/"26379.log"

dir /opt/module/redis-sentinel/data

#sentinel通过主节点执行 info replication 命令来获取从节点信息
sentinel monitor mymaster 127.0.0.1 7000 2

#如果需要监视多套主从,就配置多个sentinel monitor mymaster2 127.0.0.1 7000 2

sentinel down-after-milliseconds mymaster 30000

sentinel parallel-syncs mymaster 1

sentinel failover-timeout mymaster 180000

启动命令:

redis-sentinel sentinel26379.conf

启动后配置文件:自动发现从节点


port 26379

daemonize yes

logfile "/opt/module/redis-sentinel/data/26379.log"

dir "/opt/module/redis-sentinel/data"

sentinel myid aa12fb6410798bb8fffe99fdbb1602d32c278c0c

sentinel deny-scripts-reconfig yes

sentinel monitor mymaster 127.0.0.1 7000 2

sentinel config-epoch mymaster 0
# Generated by CONFIG REWRITE
sentinel leader-epoch mymaster 0
sentinel known-slave mymaster 127.0.0.1 7001
sentinel known-slave mymaster 127.0.0.1 7002
sentinel current-epoch 0

多了从节点的配置信息。

其他两个sentinel配置文件:

sentinel26380.conf


port 26380

daemonize yes

logfile "/opt/module/redis-sentinel/data/26380.log"

dir "/opt/module/redis-sentinel/data"

sentinel monitor mymaster 127.0.0.1 7000 2

sentinel down-after-milliseconds mymaster 30000

sentinel parallel-syncs mymaster 1

sentinel failover-timeout mymaster 180000

sentinel26381.conf


port 26381

daemonize yes

logfile "/opt/module/redis-sentinel/data/26381.log"

dir "/opt/module/redis-sentinel/data"

sentinel monitor mymaster 127.0.0.1 7000 2

sentinel down-after-milliseconds mymaster 30000

sentinel parallel-syncs mymaster 1

sentinel failover-timeout mymaster 180000

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值