在redis主从搭建基础上代码搭建哨兵
1、程序目录下创建sentinel目录
2、创建3配置文件
端口分别是26381、26382、26383,别名
mymaster
三个必须一致sentinel-26381.conf
daemonize yes
port 26381
logfile "sentinel-26381.log"
sentinel monitor mymaster 127.0.0.1 6381 2
sentinel auth-pass mymaster 123456
sentinel-26382.conf
daemonize yes
port 26382
logfile "sentinel-26382.log"
sentinel monitor mymaster 127.0.0.1 6382 2
sentinel auth-pass mymaster 123456
sentinel-26383.conf
daemonize yes
port 26383
logfile "sentinel-26383.log"
sentinel monitor mymaster 127.0.0.1 6383 2
sentinel auth-pass mymaster 123456
3、启动顺序,主节点->从节点->哨兵节点
./redis-sentinel sentinel/sentinel-26381.conf
./redis-sentinel sentinel/sentinel-26382.conf
./redis-sentinel sentinel/sentinel-26383.conf
4、验证,进入redis命令行
随便进一个redis节点:./redis-cli -p 6383
用命令查看节点详情:info replication
杀死主节点前后查看节点详情做对比
网友评论