sentinel.conf 基本配置:port 26379 sentinel monitor mymaster 10.0.0.1 6379 2 sentinel down-after-milliseconds mymaster 5000 sentinel failover-timeout mymaster 60000 sentinel parallel-syncs mymaster 1 启动 Sentinel:redis-server /etc/redis/sentinel.conf --sentinel 查询主节点与从节点状态:redis-cli -h sentinel-host -p 26379 SENTINEL get-master-addr-by-name mymaster redis-cli -h sentinel-host -p 26379 SENTINEL masters redis-cli -h sentinel-host -p 26379 SENTINEL slaves mymaster 模拟主节点下线并观察故障转移:redis-cli -h 10.0.0.1 -p 6379 SHUTDOWN NOSAVE 客户端重定向(示例逻辑):# 通过 Sentinel 查询当前主地址再建立连接 redis-cli -h sentinel-host -p 26379 SENTINEL get-master-addr-by-name mymaster

发表评论 取消回复