redis哨兵实战

1.环境准备

先三台机器安装redis,从安装包下复制sentinel.conf文件到/usr/local/redis/bin/

192.168.56.10(主) 192.168.56.11(从) 192.168.56.12(从)

主 192.168.56.10

redis.conf修改

bind  0.0.0.0
protected-mode no
daemonize yes
从192.168.56.11 & 192.168.56.12

redis.conf修改

slaveof 192.168.56.10 9400
protected-mode no
daemonize yes
bind 0.0.0.0
主/从sentinel.conf修改
daemonize yes
port 26379
protected-mode no
dir "/usr/local/redis/sentinel-tmp"
logfile "/usr/local/redis/sentinel.log"
sentinel monitor redis-master 192.168.56.10 6379 2
sentinel down-after-milliseconds redis-master 30000
sentinel failover-timeout redis-master 180000
sentinel parallel-syncs redis-master 1

2.启动

进入

user/local
./redis-sentinel sentinel.conf
./redis-server redis.conf

3.主从测试

./redis-cli          #或者以下
./redis-cli -p 9400  #指定端口时
127.0.0.1:6379> info replication

posted @ 2020-09-21 10:15  馥郁  阅读(101)  评论(0编辑  收藏  举报