搭建主从 Redis
- 主机:
192.168.181.133:6379
- 从机:
192.168.181.132:6379
搭建 Sentinel
-
安装
make install PREFIX=/redis/sentinel cp /etc/redis/6379.conf /redis/sentinel/bin/
-
修改配置文件
sentinel.conf
daemonize yes sentinel monitor mymaster 192.168.181.133 6379 1
-
启动 Sentinel
/redis/sentinel/bin/redis-sentinel sentinel.conf
-
测试哨兵功能
- 关闭 133 主机,一段时间后,通过
info replication
命令查看 132 状态转变为主机 - 重启 133 主机,一段时间后,通过
info replication
命令查看 133 状态转变为从机
- 关闭 133 主机,一段时间后,通过